2020-09-27 13:43:20 +03:00
|
|
|
# Integration tests, can be run without internet access.
|
2020-01-12 22:52:40 +03:00
|
|
|
|
2024-01-16 01:13:16 +03:00
|
|
|
lib: nixBitcoinModule:
|
2021-03-22 15:19:48 +03:00
|
|
|
let
|
2022-10-22 20:37:58 +03:00
|
|
|
# Included in all scenarios
|
|
|
|
baseConfig = { config, pkgs, ... }: with lib; let
|
2021-03-22 15:19:48 +03:00
|
|
|
cfg = config.services;
|
2022-10-22 20:37:56 +03:00
|
|
|
inherit (config.nix-bitcoin.lib.test) mkIfTest;
|
2021-03-22 15:19:48 +03:00
|
|
|
in {
|
2020-01-12 22:52:40 +03:00
|
|
|
imports = [
|
2020-09-27 13:43:20 +03:00
|
|
|
./lib/test-lib.nix
|
2024-01-16 01:13:16 +03:00
|
|
|
nixBitcoinModule
|
2020-09-28 14:09:04 +03:00
|
|
|
{
|
|
|
|
# Features required by the Python test suite
|
|
|
|
nix-bitcoin.secretsDir = "/secrets";
|
2021-03-10 16:08:34 +03:00
|
|
|
nix-bitcoin.generateSecrets = true;
|
2020-09-28 14:09:04 +03:00
|
|
|
nix-bitcoin.operator.enable = true;
|
|
|
|
environment.systemPackages = with pkgs; [ jq ];
|
|
|
|
}
|
2020-01-12 22:52:40 +03:00
|
|
|
];
|
|
|
|
|
2020-11-19 05:01:45 +03:00
|
|
|
options.test.features = {
|
|
|
|
clightningPlugins = mkEnableOption "all clightning plugins";
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkMerge [{
|
2022-07-07 17:08:27 +03:00
|
|
|
environment.systemPackages = mkMerge (with pkgs; [
|
|
|
|
# Needed to test macaroon creation
|
|
|
|
(mkIfTest "btcpayserver" [ openssl xxd ])
|
|
|
|
# Needed to test certificate creation
|
|
|
|
(mkIfTest "lnd" [ openssl ])
|
|
|
|
]);
|
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
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;
|
2022-01-06 15:40:52 +03:00
|
|
|
test.data.clightning-replication = cfg.clightning.replication.enable;
|
2023-06-25 12:08:57 +03:00
|
|
|
tests.trustedcoin = cfg.clightning.plugins.trustedcoin.enable;
|
2022-01-06 15:40:52 +03:00
|
|
|
|
2022-07-29 16:37:30 +03:00
|
|
|
# TODO-EXTERNAL:
|
2020-09-28 14:09:08 +03:00
|
|
|
# When WAN is disabled, DNS bootstrapping slows down service startup by ~15 s.
|
2024-06-30 23:20:21 +03:00
|
|
|
# TODO-EXTERNAL:
|
|
|
|
# When bitcoind is not fully synced, the offers plugin in clightning 24.05
|
|
|
|
# crashes (see https://github.com/ElementsProject/lightning/issues/7378).
|
|
|
|
services.clightning.extraConfig = ''
|
|
|
|
${optionalString config.test.noConnections "disable-dns"}
|
|
|
|
disable-plugin=offers
|
|
|
|
'';
|
2020-11-19 05:01:45 +03:00
|
|
|
test.data.clightning-plugins = let
|
|
|
|
plugins = config.services.clightning.plugins;
|
2023-06-25 12:08:56 +03:00
|
|
|
removed = [
|
|
|
|
# Only defined via `obsolete-options.nix`
|
|
|
|
"commando"
|
2024-04-08 16:54:24 +03:00
|
|
|
"helpme"
|
|
|
|
"prometheus"
|
|
|
|
"summary"
|
2023-06-25 12:08:56 +03:00
|
|
|
];
|
2023-06-25 12:08:54 +03:00
|
|
|
available = subtractLists removed (builtins.attrNames plugins);
|
|
|
|
enabled = builtins.filter (plugin: plugins.${plugin}.enable) available;
|
2021-04-11 15:39:41 +03:00
|
|
|
nbPkgs = config.nix-bitcoin.pkgs;
|
|
|
|
pluginPkgs = nbPkgs.clightning-plugins // {
|
2023-06-25 12:08:55 +03:00
|
|
|
clboss.path = "${plugins.clboss.package}/bin/clboss";
|
2023-06-25 12:08:56 +03:00
|
|
|
trustedcoin.path = "${plugins.trustedcoin.package}/bin/trustedcoin";
|
2021-04-11 15:39:41 +03:00
|
|
|
};
|
2020-11-19 05:01:45 +03:00
|
|
|
in map (plugin: pluginPkgs.${plugin}.path) enabled;
|
2020-09-27 13:43:20 +03:00
|
|
|
|
2022-05-05 22:56:16 +03:00
|
|
|
tests.clightning-rest = cfg.clightning-rest.enable;
|
|
|
|
|
2021-11-08 14:44:14 +03:00
|
|
|
tests.rtl = cfg.rtl.enable;
|
2022-05-14 16:21:36 +03:00
|
|
|
services.rtl = {
|
|
|
|
nodes = {
|
|
|
|
lnd = {
|
|
|
|
enable = mkDefault true;
|
|
|
|
loop = mkDefault true;
|
2022-05-14 16:21:37 +03:00
|
|
|
extraConfig.Settings.userPersona = "MERCHANT";
|
2022-05-14 16:21:36 +03:00
|
|
|
};
|
|
|
|
clightning.enable = mkDefault true;
|
|
|
|
};
|
|
|
|
extraCurrency = mkDefault "CHF";
|
|
|
|
};
|
2021-11-08 14:44:14 +03:00
|
|
|
# Use a simple, non-random password for manual web interface tests
|
|
|
|
nix-bitcoin.generateSecretsCmds.rtl = mkIf cfg.rtl.enable (mkForce ''
|
|
|
|
echo a > rtl-password
|
|
|
|
'');
|
|
|
|
|
2023-08-06 22:07:51 +03:00
|
|
|
tests.mempool = cfg.mempool.enable;
|
|
|
|
services.mempool.electrumServer = "fulcrum";
|
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
tests.lnd = cfg.lnd.enable;
|
2022-07-07 17:08:27 +03:00
|
|
|
services.lnd = {
|
|
|
|
port = 9736;
|
|
|
|
certificate = {
|
|
|
|
extraIPs = [ "10.0.0.1" "20.0.0.1" ];
|
|
|
|
extraDomains = [ "example.com" ];
|
|
|
|
};
|
|
|
|
};
|
2020-06-18 13:22:44 +03:00
|
|
|
|
2022-12-12 13:57:10 +03:00
|
|
|
nix-bitcoin.onionServices.lnd.public = true;
|
|
|
|
|
2023-01-22 18:18:03 +03:00
|
|
|
tests.lndconnect-onion-lnd = with cfg.lnd.lndconnect; enable && onion;
|
|
|
|
tests.lndconnect-onion-clightning = with cfg.clightning-rest.lndconnect; enable && onion;
|
2021-02-04 00:44:43 +03:00
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
tests.lightning-loop = cfg.lightning-loop.enable;
|
2022-07-07 17:08:28 +03:00
|
|
|
services.lightning-loop.certificate.extraIPs = [ "20.0.0.1" ];
|
2020-01-12 22:52:40 +03:00
|
|
|
|
2021-03-01 12:59:23 +03:00
|
|
|
tests.lightning-pool = cfg.lightning-pool.enable;
|
|
|
|
|
2021-06-02 04:11:26 +03:00
|
|
|
tests.charge-lnd = cfg.charge-lnd.enable;
|
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
tests.electrs = cfg.electrs.enable;
|
2020-01-12 22:52:40 +03:00
|
|
|
|
2022-07-04 13:15:44 +03:00
|
|
|
services.fulcrum.port = 50002;
|
|
|
|
tests.fulcrum = cfg.fulcrum.enable;
|
|
|
|
|
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;
|
2021-07-13 17:03:08 +03:00
|
|
|
services.btcpayserver = {
|
2021-10-30 15:55:55 +03:00
|
|
|
lightningBackend = mkDefault "lnd";
|
|
|
|
lbtc = mkDefault true;
|
2021-07-13 17:03:08 +03:00
|
|
|
};
|
2022-04-30 16:35:47 +03:00
|
|
|
test.data.btcpayserver-lbtc = config.services.btcpayserver.lbtc;
|
2020-09-27 13:43:20 +03:00
|
|
|
|
|
|
|
tests.joinmarket = cfg.joinmarket.enable;
|
2020-10-16 18:43:17 +03:00
|
|
|
tests.joinmarket-yieldgenerator = cfg.joinmarket.yieldgenerator.enable;
|
2021-01-17 15:24:57 +03:00
|
|
|
tests.joinmarket-ob-watcher = cfg.joinmarket-ob-watcher.enable;
|
2020-09-27 13:43:20 +03:00
|
|
|
services.joinmarket.yieldgenerator = {
|
|
|
|
enable = config.services.joinmarket.enable;
|
2021-02-10 17:02:05 +03:00
|
|
|
# Test a smattering of custom parameters
|
|
|
|
ordertype = "absoffer";
|
|
|
|
cjfee_a = 300;
|
|
|
|
cjfee_r = 0.00003;
|
2020-09-27 13:43:20 +03:00
|
|
|
};
|
|
|
|
|
2021-01-14 15:24:26 +03:00
|
|
|
tests.nodeinfo = config.nix-bitcoin.nodeinfo.enable;
|
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
tests.backups = cfg.backups.enable;
|
|
|
|
|
|
|
|
# To test that unused secrets are made inaccessible by 'setup-secrets'
|
2021-03-10 16:08:34 +03:00
|
|
|
systemd.services.setup-secrets.preStart = mkIfTest "security" ''
|
|
|
|
install -D -o nobody -g nogroup -m777 <(:) /secrets/dummy
|
2020-09-27 13:43:20 +03:00
|
|
|
'';
|
2021-08-05 01:49:10 +03:00
|
|
|
|
|
|
|
# Avoid timeout failures on slow CI nodes
|
2022-07-07 12:43:21 +03:00
|
|
|
systemd.services.postgresql.serviceConfig.TimeoutStartSec = "5min";
|
2020-11-19 05:01:45 +03:00
|
|
|
}
|
2022-12-12 13:57:09 +03:00
|
|
|
(mkIf config.services.clightning.plugins.clboss.enable {
|
|
|
|
# Torified 'dig' subprocesses of clboss don't respond to SIGTERM and keep
|
|
|
|
# running for a long time when WAN is disabled, which prevents clightning units
|
|
|
|
# from stopping quickly.
|
|
|
|
# Set TimeoutStopSec for faster stopping.
|
|
|
|
systemd.services.clightning.serviceConfig.TimeoutStopSec = "500ms";
|
|
|
|
})
|
2020-11-19 05:01:45 +03:00
|
|
|
(mkIf config.test.features.clightningPlugins {
|
|
|
|
services.clightning.plugins = {
|
2021-04-11 15:39:41 +03:00
|
|
|
clboss.enable = true;
|
2022-05-27 12:13:53 +03:00
|
|
|
feeadjuster.enable = true;
|
2020-11-19 05:01:45 +03:00
|
|
|
monitor.enable = true;
|
|
|
|
rebalance.enable = true;
|
|
|
|
zmq = let tcpEndpoint = "tcp://127.0.0.1:5501"; in {
|
|
|
|
enable = true;
|
|
|
|
channel-opened = tcpEndpoint;
|
|
|
|
connect = tcpEndpoint;
|
|
|
|
disconnect = tcpEndpoint;
|
|
|
|
invoice-payment = tcpEndpoint;
|
|
|
|
warning = tcpEndpoint;
|
|
|
|
forward-event = tcpEndpoint;
|
|
|
|
sendpay-success = tcpEndpoint;
|
|
|
|
sendpay-failure = tcpEndpoint;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
2020-09-27 13:43:20 +03:00
|
|
|
};
|
2020-01-12 22:52:40 +03:00
|
|
|
|
2022-10-22 20:37:58 +03:00
|
|
|
scenarios = with lib; {
|
|
|
|
# Included in all scenarios by ./lib/make-test.nix
|
|
|
|
base = baseConfig;
|
2020-09-27 13:43:20 +03:00
|
|
|
|
|
|
|
default = scenarios.secureNode;
|
|
|
|
|
|
|
|
# All available basic services and tests
|
|
|
|
full = {
|
|
|
|
tests.security = true;
|
|
|
|
|
|
|
|
services.clightning.enable = true;
|
2022-01-06 15:40:52 +03:00
|
|
|
services.clightning.replication = {
|
|
|
|
enable = true;
|
|
|
|
encrypt = true;
|
|
|
|
local.directory = "/var/backup/clightning";
|
|
|
|
};
|
2020-11-19 05:01:45 +03:00
|
|
|
test.features.clightningPlugins = true;
|
2021-11-08 14:44:14 +03:00
|
|
|
services.rtl.enable = true;
|
2022-05-05 22:56:16 +03:00
|
|
|
services.clightning-rest.enable = true;
|
2023-01-22 18:18:03 +03:00
|
|
|
services.clightning-rest.lndconnect = { enable = true; onion = true; };
|
2020-09-27 13:43:20 +03:00
|
|
|
services.lnd.enable = true;
|
2023-01-22 18:18:03 +03:00
|
|
|
services.lnd.lndconnect = { enable = true; onion = true; };
|
2020-09-27 13:43:20 +03:00
|
|
|
services.lightning-loop.enable = true;
|
2021-03-01 12:59:23 +03:00
|
|
|
services.lightning-pool.enable = true;
|
2021-06-02 04:11:26 +03:00
|
|
|
services.charge-lnd.enable = true;
|
2023-08-06 22:07:51 +03:00
|
|
|
services.mempool.enable = true;
|
2020-09-27 13:43:20 +03:00
|
|
|
services.electrs.enable = true;
|
2022-07-04 13:15:44 +03:00
|
|
|
services.fulcrum.enable = true;
|
2020-09-27 13:43:20 +03:00
|
|
|
services.liquidd.enable = true;
|
|
|
|
services.btcpayserver.enable = true;
|
|
|
|
services.joinmarket.enable = true;
|
2021-01-17 15:24:57 +03:00
|
|
|
services.joinmarket-ob-watcher.enable = true;
|
2020-09-27 13:43:20 +03:00
|
|
|
services.backups.enable = true;
|
|
|
|
|
2021-01-14 15:24:26 +03:00
|
|
|
nix-bitcoin.nodeinfo.enable = true;
|
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
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
|
|
|
|
];
|
|
|
|
tests.secure-node = true;
|
2022-07-15 01:04:03 +03:00
|
|
|
tests.restart-bitcoind = true;
|
2020-10-16 18:43:18 +03:00
|
|
|
|
2023-08-06 22:07:51 +03:00
|
|
|
nix-bitcoin.onionServices.mempool-frontend.enable = true;
|
|
|
|
|
2020-10-16 18:43:18 +03:00
|
|
|
# Stop electrs from spamming the test log with 'WARN - wait until IBD is over' messages
|
|
|
|
tests.stop-electrs = true;
|
2020-09-27 13:43:20 +03:00
|
|
|
};
|
2020-01-12 22:52:40 +03:00
|
|
|
|
2020-09-27 13:43:20 +03:00
|
|
|
netns = {
|
2020-10-29 23:20:28 +03:00
|
|
|
imports = with scenarios; [ netnsBase secureNode ];
|
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-10-16 18:43:19 +03:00
|
|
|
# All regtest-enabled services
|
|
|
|
regtest = {
|
|
|
|
imports = [ scenarios.regtestBase ];
|
|
|
|
services.clightning.enable = true;
|
2020-11-19 05:01:45 +03:00
|
|
|
test.features.clightningPlugins = true;
|
2022-05-05 22:56:16 +03:00
|
|
|
services.clightning-rest.enable = true;
|
2021-07-13 16:59:56 +03:00
|
|
|
services.liquidd.enable = true;
|
2021-11-08 14:44:14 +03:00
|
|
|
services.rtl.enable = true;
|
2023-08-06 22:07:51 +03:00
|
|
|
services.mempool.enable = true;
|
2020-10-16 18:43:19 +03:00
|
|
|
services.lnd.enable = true;
|
|
|
|
services.lightning-loop.enable = true;
|
2021-03-01 12:59:23 +03:00
|
|
|
services.lightning-pool.enable = true;
|
2021-06-02 04:11:26 +03:00
|
|
|
services.charge-lnd.enable = true;
|
2020-10-16 18:43:19 +03:00
|
|
|
services.electrs.enable = true;
|
2022-07-04 13:15:44 +03:00
|
|
|
services.fulcrum.enable = true;
|
2020-10-16 18:43:19 +03:00
|
|
|
services.btcpayserver.enable = true;
|
|
|
|
services.joinmarket.enable = true;
|
|
|
|
};
|
|
|
|
|
2020-10-29 23:20:28 +03:00
|
|
|
# netns and regtest, without secure-node.nix
|
|
|
|
netnsRegtest = {
|
|
|
|
imports = with scenarios; [ netnsBase regtest ];
|
|
|
|
};
|
|
|
|
|
2020-12-18 15:27:20 +03:00
|
|
|
hardened = {
|
|
|
|
imports = [
|
|
|
|
scenarios.secureNode
|
2021-01-31 01:08:35 +03:00
|
|
|
../modules/presets/hardened-extended.nix
|
2020-12-18 15:27:20 +03:00
|
|
|
];
|
2024-01-16 01:08:08 +03:00
|
|
|
|
|
|
|
# Patch clightning to increase the plugin init timeout.
|
|
|
|
# Otherwise this test can fail on slower hardware.
|
|
|
|
nix-bitcoin.pkgOverlays = super: self: {
|
|
|
|
clightning = super.clightning.overrideAttrs (old: {
|
|
|
|
postPatch = old.postPatch + ''
|
|
|
|
substituteInPlace lightningd/plugin.c \
|
2024-05-21 13:41:15 +03:00
|
|
|
--replace-fail "#define PLUGIN_MANIFEST_TIMEOUT 60" "#define PLUGIN_MANIFEST_TIMEOUT 200"
|
2024-01-16 01:08:08 +03:00
|
|
|
'';
|
|
|
|
});
|
|
|
|
};
|
2020-12-18 15:27:20 +03:00
|
|
|
};
|
|
|
|
|
2021-03-22 15:19:48 +03:00
|
|
|
netnsBase = { config, pkgs, ... }: {
|
2020-10-29 23:20:28 +03:00
|
|
|
nix-bitcoin.netns-isolation.enable = true;
|
|
|
|
test.data.netns = config.nix-bitcoin.netns-isolation.netns;
|
|
|
|
tests.netns-isolation = true;
|
|
|
|
environment.systemPackages = [ pkgs.fping ];
|
|
|
|
};
|
|
|
|
|
2022-10-22 20:37:58 +03:00
|
|
|
regtestBase = { config, pkgs, ... }: {
|
2020-10-16 18:43:19 +03:00
|
|
|
tests.regtest = true;
|
2021-11-02 15:07:40 +03:00
|
|
|
test.data.num_blocks = 100;
|
2020-10-16 18:43:19 +03:00
|
|
|
|
|
|
|
services.bitcoind.regtest = true;
|
|
|
|
systemd.services.bitcoind.postStart = mkAfter ''
|
2020-10-29 23:20:29 +03:00
|
|
|
cli=${config.services.bitcoind.cli}/bin/bitcoin-cli
|
2021-11-02 15:07:39 +03:00
|
|
|
if ! $cli listwallets | ${pkgs.jq}/bin/jq -e 'index("test")'; then
|
2022-08-01 00:32:12 +03:00
|
|
|
"$cli" -named createwallet wallet_name=test load_on_startup=true
|
2021-11-02 15:07:39 +03:00
|
|
|
address=$($cli -rpcwallet=test getnewaddress)
|
2022-08-01 00:32:12 +03:00
|
|
|
"$cli" generatetoaddress ${toString config.test.data.num_blocks} "$address"
|
2021-11-02 15:07:39 +03:00
|
|
|
fi
|
2020-10-16 18:43:19 +03:00
|
|
|
'';
|
|
|
|
|
|
|
|
# lightning-loop contains no builtin swap server for regtest.
|
|
|
|
# Add a dummy definition.
|
|
|
|
services.lightning-loop.extraConfig = ''
|
2023-07-29 19:58:55 +03:00
|
|
|
server.host=127.0.0.1
|
2020-10-16 18:43:19 +03:00
|
|
|
'';
|
|
|
|
|
2021-03-01 12:59:23 +03:00
|
|
|
# lightning-pool contains no builtin auction server for regtest.
|
|
|
|
# Add a dummy definition
|
|
|
|
services.lightning-pool.extraConfig = ''
|
2023-07-29 19:58:55 +03:00
|
|
|
auctionserver=127.0.0.1
|
2021-03-01 12:59:23 +03:00
|
|
|
'';
|
2021-11-02 17:15:29 +03:00
|
|
|
|
|
|
|
# `validatepegin` is incompatible with regtest
|
|
|
|
services.liquidd.validatepegin = mkForce false;
|
2022-04-30 16:35:47 +03:00
|
|
|
|
|
|
|
# TODO-EXTERNAL:
|
|
|
|
# Reenable `btcpayserver.lbtc` in regtest (and add test in tests.py)
|
|
|
|
# when nbxplorer can parse liquidd regtest blocks.
|
|
|
|
#
|
|
|
|
# When `btcpayserver.lbtc` is enabled in regtest, nxbplorer tries to
|
|
|
|
# generate regtest blocks, which fails because no liquidd wallet exists.
|
|
|
|
# When blocks are pre-generated via `liquidd.postStart`, nbxplorer
|
|
|
|
# fails to parse the blocks:
|
|
|
|
# info: NBXplorer.Indexer.LBTC: Full node version detected: 210002
|
|
|
|
# info: NBXplorer.Indexer.LBTC: NBXplorer is correctly whitelisted by the node
|
|
|
|
# fail: NBXplorer.Indexer.LBTC: Unhandled exception in the indexer, retrying in 10 seconds
|
|
|
|
# System.IO.EndOfStreamException: No more byte to read
|
|
|
|
# at NBitcoin.BitcoinStream.ReadWriteBytes(Span`1 data)
|
|
|
|
services.btcpayserver.lbtc = mkForce false;
|
2020-10-16 18:43:19 +03:00
|
|
|
};
|
|
|
|
|
2022-10-25 23:35:31 +03:00
|
|
|
# Test the special bitcoin RPC setup that lnd uses when bitcoin is pruned
|
|
|
|
lndPruned = {
|
|
|
|
services.lnd.enable = true;
|
|
|
|
services.bitcoind.prune = 1000;
|
|
|
|
};
|
2023-03-03 23:00:00 +03:00
|
|
|
|
|
|
|
trustedcoin = {
|
2023-08-03 18:26:15 +03:00
|
|
|
imports = [ scenarios.regtestBase ];
|
|
|
|
|
2023-03-03 23:00:00 +03:00
|
|
|
services.clightning = {
|
|
|
|
enable = true;
|
|
|
|
plugins.trustedcoin.enable = true;
|
|
|
|
};
|
|
|
|
};
|
2023-01-15 22:27:51 +03:00
|
|
|
} // (import ../dev/dev-scenarios.nix {
|
|
|
|
inherit lib scenarios;
|
|
|
|
});
|
2022-10-25 23:35:31 +03:00
|
|
|
|
2022-10-22 20:37:58 +03:00
|
|
|
## Example scenarios that showcase extra features
|
|
|
|
exampleScenarios = with lib; {
|
2020-09-27 13:43:20 +03:00
|
|
|
# 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;
|
|
|
|
};
|
2023-01-15 22:27:48 +03:00
|
|
|
|
|
|
|
## Scenarios with a custom Python test
|
|
|
|
|
|
|
|
# Variant 1: Define testing code that always runs
|
|
|
|
customTestSimple = {
|
|
|
|
networking.hostName = "myhost";
|
|
|
|
|
|
|
|
# Variant 1: Define testing code that always runs
|
|
|
|
test.extraTestScript = ''
|
|
|
|
succeed("[[ $(hostname) == myhost ]]")
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
# Variant 2: Define a test that can be enabled/disabled
|
|
|
|
# via the Nix module system.
|
|
|
|
customTestExtended = {
|
|
|
|
networking.hostName = "myhost";
|
|
|
|
|
|
|
|
tests.hostName = true;
|
|
|
|
test.extraTestScript = ''
|
|
|
|
@test("hostName")
|
|
|
|
def _():
|
|
|
|
succeed("[[ $(hostname) == myhost ]]")
|
|
|
|
'';
|
|
|
|
};
|
2020-01-12 22:52:40 +03:00
|
|
|
};
|
2022-10-22 20:37:58 +03:00
|
|
|
in {
|
|
|
|
inherit scenarios;
|
|
|
|
|
|
|
|
pkgs = flake: pkgs: rec {
|
|
|
|
# A basic test using the nix-bitcoin test framework
|
|
|
|
makeTestBasic = import ./lib/make-test.nix flake pkgs makeTestVM;
|
|
|
|
|
|
|
|
# Wraps `makeTest` in NixOS' testing-python.nix so that the drv includes the
|
|
|
|
# log output and the test driver
|
|
|
|
makeTestVM = import ./lib/make-test-vm.nix pkgs;
|
|
|
|
|
|
|
|
# A test using the nix-bitcoin test framework, with some helpful defaults
|
|
|
|
makeTest = { name ? "nix-bitcoin-test", config }:
|
|
|
|
makeTestBasic {
|
|
|
|
inherit name;
|
|
|
|
config = {
|
|
|
|
imports = [
|
|
|
|
scenarios.base
|
|
|
|
config
|
|
|
|
];
|
|
|
|
# Share the same pkgs instance among tests
|
2023-07-08 16:33:00 +03:00
|
|
|
# Set priority slightly higher (i.e. to a slightly lower number) than `mkDefault`,
|
|
|
|
# so that this module can be used with function `pkgs.nixos`, which already
|
|
|
|
# sets `nixpkgs.pkgs` with prio `mkDefault`.
|
|
|
|
nixpkgs.pkgs = lib.mkOverride 900 pkgs;
|
2022-10-22 20:37:58 +03:00
|
|
|
};
|
|
|
|
};
|
2021-03-22 15:19:48 +03:00
|
|
|
|
2022-10-22 20:37:58 +03:00
|
|
|
# A test using the nix-bitcoin test framework, with defaults specific to nix-bitcoin
|
|
|
|
makeTestNixBitcoin = { name, config }:
|
|
|
|
makeTest {
|
|
|
|
name = "nix-bitcoin-${name}";
|
|
|
|
config = {
|
|
|
|
imports = [ config ];
|
|
|
|
test.shellcheckServices.sourcePrefix = toString ./..;
|
|
|
|
};
|
|
|
|
};
|
2021-03-22 15:19:48 +03:00
|
|
|
|
2022-10-22 20:37:58 +03:00
|
|
|
makeTests = scenarios: let
|
|
|
|
mainTests = builtins.mapAttrs (name: config:
|
|
|
|
makeTestNixBitcoin { inherit name config; }
|
|
|
|
) scenarios;
|
|
|
|
in
|
|
|
|
{
|
2022-12-12 13:57:13 +03:00
|
|
|
clightning-replication = import ./clightning-replication.nix makeTestVM pkgs;
|
2023-01-22 23:23:18 +03:00
|
|
|
wireguard-lndconnect = import ./wireguard-lndconnect.nix makeTestVM pkgs;
|
2022-10-22 20:37:58 +03:00
|
|
|
} // mainTests;
|
|
|
|
|
|
|
|
tests = makeTests scenarios;
|
|
|
|
|
|
|
|
## Helper for ./run-tests.sh
|
|
|
|
|
|
|
|
getTest = { name, extraScenariosFile ? null }:
|
|
|
|
let
|
|
|
|
tests = makeTests (scenarios // (
|
|
|
|
lib.optionalAttrs (extraScenariosFile != null)
|
|
|
|
(import extraScenariosFile {
|
|
|
|
inherit scenarios lib pkgs;
|
|
|
|
nix-bitcoin = flake;
|
|
|
|
})
|
|
|
|
));
|
|
|
|
in
|
|
|
|
tests.${name} or (makeTestNixBitcoin {
|
|
|
|
inherit name;
|
|
|
|
config = {
|
|
|
|
services.${name}.enable = true;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
instantiateTests = testNames:
|
|
|
|
let
|
|
|
|
testNames' = lib.splitString " " testNames;
|
|
|
|
in
|
|
|
|
map (name:
|
|
|
|
let
|
|
|
|
test = tests.${name};
|
|
|
|
in
|
|
|
|
builtins.seq (builtins.trace "Evaluating test '${name}'" test.outPath)
|
|
|
|
test
|
|
|
|
) testNames';
|
2022-01-06 15:40:52 +03:00
|
|
|
};
|
2022-10-22 20:37:58 +03:00
|
|
|
}
|