2020-09-27 13:43:20 +03:00
|
|
|
# Integration tests, can be run without internet access.
|
2020-01-12 22:52:40 +03:00
|
|
|
|
2020-07-16 17:48:41 +03:00
|
|
|
{ scenario ? "default" }:
|
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
import ./lib/make-test.nix scenario (
|
|
|
|
{ config, pkgs, lib, ... }: with lib;
|
|
|
|
let testEnv = rec {
|
|
|
|
cfg = config.services;
|
|
|
|
mkIfTest = test: mkIf (config.tests.${test} or false);
|
2020-01-12 22:52:40 +03:00
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
baseConfig = {
|
2020-01-12 22:52:40 +03:00
|
|
|
imports = [
|
2020-09-27 13:43:20 +03:00
|
|
|
./lib/test-lib.nix
|
|
|
|
../modules/modules.nix
|
2020-01-12 22:52:40 +03:00
|
|
|
../modules/secrets/generate-secrets.nix
|
2020-09-28 14:09:04 +03:00
|
|
|
{
|
|
|
|
# Features required by the Python test suite
|
|
|
|
nix-bitcoin.secretsDir = "/secrets";
|
|
|
|
nix-bitcoin.operator.enable = true;
|
|
|
|
environment.systemPackages = with pkgs; [ jq ];
|
|
|
|
}
|
2020-01-12 22:52:40 +03:00
|
|
|
];
|
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
config = {
|
|
|
|
tests.bitcoind = cfg.bitcoind.enable;
|
|
|
|
services.bitcoind = {
|
|
|
|
enable = true;
|
2020-09-27 13:43:21 +03:00
|
|
|
extraConfig = mkIf config.test.noConnections "connect=0";
|
2020-09-27 13:43:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
tests.clightning = cfg.clightning.enable;
|
2020-09-28 14:09:08 +03:00
|
|
|
# When WAN is disabled, DNS bootstrapping slows down service startup by ~15 s.
|
|
|
|
services.clightning.extraConfig = mkIf config.test.noConnections "disable-dns";
|
2020-09-27 13:43:20 +03:00
|
|
|
|
|
|
|
tests.spark-wallet = cfg.spark-wallet.enable;
|
|
|
|
|
|
|
|
tests.nanopos = cfg.nanopos.enable;
|
2020-09-24 19:54:54 +03:00
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
tests.lnd = cfg.lnd.enable;
|
|
|
|
services.lnd.listenPort = 9736;
|
2020-06-18 13:22:44 +03:00
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
tests.lightning-loop = cfg.lightning-loop.enable;
|
2020-01-12 22:52:40 +03:00
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
tests.electrs = cfg.electrs.enable;
|
2020-01-12 22:52:40 +03:00
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
tests.liquidd = cfg.liquidd.enable;
|
2020-09-27 13:43:21 +03:00
|
|
|
services.liquidd.extraConfig = mkIf config.test.noConnections "connect=0";
|
2020-01-12 22:52:40 +03:00
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
tests.btcpayserver = cfg.btcpayserver.enable;
|
|
|
|
services.btcpayserver.lightningBackend = "lnd";
|
|
|
|
# Needed to test macaroon creation
|
|
|
|
environment.systemPackages = mkIfTest "btcpayserver" (with pkgs; [ openssl xxd ]);
|
|
|
|
|
|
|
|
tests.joinmarket = cfg.joinmarket.enable;
|
2020-10-16 18:43:17 +03:00
|
|
|
tests.joinmarket-yieldgenerator = cfg.joinmarket.yieldgenerator.enable;
|
2020-09-27 13:43:20 +03:00
|
|
|
services.joinmarket.yieldgenerator = {
|
|
|
|
enable = config.services.joinmarket.enable;
|
|
|
|
customParameters = ''
|
|
|
|
txfee = 200
|
|
|
|
cjfee_a = 300
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
tests.backups = cfg.backups.enable;
|
|
|
|
|
|
|
|
# To test that unused secrets are made inaccessible by 'setup-secrets'
|
|
|
|
systemd.services.generate-secrets.postStart = mkIfTest "security" ''
|
|
|
|
install -o nobody -g nogroup -m777 <(:) /secrets/dummy
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2020-01-12 22:52:40 +03:00
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
scenarios = {
|
|
|
|
base = baseConfig; # Included in all scenarios
|
|
|
|
|
|
|
|
default = scenarios.secureNode;
|
|
|
|
|
|
|
|
# All available basic services and tests
|
|
|
|
full = {
|
|
|
|
tests.security = true;
|
|
|
|
|
|
|
|
services.clightning.enable = true;
|
|
|
|
services.spark-wallet.enable = true;
|
|
|
|
services.lightning-charge.enable = true;
|
|
|
|
services.nanopos.enable = true;
|
|
|
|
services.lnd.enable = true;
|
|
|
|
services.lightning-loop.enable = true;
|
|
|
|
services.electrs.enable = true;
|
|
|
|
services.liquidd.enable = true;
|
|
|
|
services.btcpayserver.enable = true;
|
|
|
|
services.joinmarket.enable = true;
|
|
|
|
services.backups.enable = true;
|
|
|
|
|
|
|
|
services.hardware-wallets = {
|
|
|
|
trezor = true;
|
|
|
|
ledger = true;
|
|
|
|
};
|
2020-01-12 22:52:40 +03:00
|
|
|
};
|
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
secureNode = {
|
|
|
|
imports = [
|
|
|
|
scenarios.full
|
|
|
|
../modules/presets/secure-node.nix
|
|
|
|
];
|
|
|
|
services.nix-bitcoin-webindex.enable = true;
|
|
|
|
tests.secure-node = true;
|
|
|
|
tests.banlist-and-restart = true;
|
|
|
|
};
|
2020-01-12 22:52:40 +03:00
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
netns = {
|
|
|
|
imports = [ scenarios.secureNode ];
|
|
|
|
nix-bitcoin.netns-isolation.enable = true;
|
2020-09-27 13:43:31 +03:00
|
|
|
test.data.netns = config.nix-bitcoin.netns-isolation.netns;
|
2020-09-27 13:43:20 +03:00
|
|
|
tests.netns-isolation = true;
|
2020-09-27 13:43:29 +03:00
|
|
|
|
|
|
|
# This test is rather slow and unaffected by netns settings
|
|
|
|
tests.backups = mkForce false;
|
2020-01-12 22:52:40 +03:00
|
|
|
};
|
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
## Examples / debug helper
|
|
|
|
|
|
|
|
# Run a selection of tests in scenario 'netns'
|
|
|
|
selectedTests = {
|
|
|
|
imports = [ scenarios.netns ];
|
|
|
|
tests = mkForce {
|
|
|
|
btcpayserver = true;
|
|
|
|
netns-isolation = true;
|
|
|
|
};
|
2020-05-18 12:51:18 +03:00
|
|
|
};
|
2020-08-12 17:16:22 +03:00
|
|
|
|
2020-09-27 13:43:28 +03:00
|
|
|
# Container-specific features
|
|
|
|
containerFeatures = {
|
|
|
|
# Container has WAN access and bitcoind connects to external nodes
|
|
|
|
test.container.enableWAN = true;
|
|
|
|
# See ./lib/test-lib.nix for a description
|
|
|
|
test.container.exposeLocalhost = true;
|
|
|
|
};
|
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
adhoc = {
|
|
|
|
# <Add your config here>
|
|
|
|
# You can also set the env var `scenarioOverridesFile` (used below) to define custom scenarios.
|
|
|
|
};
|
2020-01-12 22:52:40 +03:00
|
|
|
};
|
2020-09-27 13:43:20 +03:00
|
|
|
};
|
|
|
|
in
|
|
|
|
let
|
|
|
|
overrides = builtins.getEnv "scenarioOverridesFile";
|
|
|
|
scenarios = testEnv.scenarios // (optionalAttrs (overrides != "") (import overrides {
|
|
|
|
inherit testEnv config pkgs lib;
|
|
|
|
}));
|
|
|
|
autoScenario = {
|
|
|
|
services.${scenario}.enable = true;
|
|
|
|
};
|
|
|
|
in {
|
|
|
|
imports = [
|
|
|
|
scenarios.base
|
|
|
|
(scenarios.${scenario} or autoScenario)
|
|
|
|
];
|
|
|
|
}
|
|
|
|
)
|