From d5ce1c43a81869dacb25c0c9fd537ad226afd547 Mon Sep 17 00:00:00 2001 From: nixbitcoin Date: Mon, 25 Oct 2021 13:30:53 +0000 Subject: [PATCH] test: make joinmarket work with regtest --- modules/joinmarket.nix | 11 ++++++----- test/tests.nix | 3 --- test/tests.py | 9 ++++++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/modules/joinmarket.nix b/modules/joinmarket.nix index 4801e4d..58ca77a 100644 --- a/modules/joinmarket.nix +++ b/modules/joinmarket.nix @@ -169,8 +169,8 @@ let use_ssl = false [BLOCKCHAIN] - blockchain_source = bitcoin-rpc - network = ${bitcoind.network} + blockchain_source = ${bitcoind.makeNetworkName "bitcoin-rpc" "regtest"} + network = ${bitcoind.makeNetworkName "mainnet" "testnet"} rpc_host = ${nbLib.address bitcoind.rpc.address} rpc_port = ${toString bitcoind.rpc.port} rpc_user = ${bitcoind.rpc.users.privileged.name} @@ -282,15 +282,16 @@ in { echo "rpc_password = $(cat ${secretsDir}/bitcoin-rpcpassword-privileged)" } > '${cfg.dataDir}/joinmarket.cfg' ''; - # Generating wallets (jmclient/wallet.py) is only supported for mainnet or testnet - postStart = mkIf (bitcoind.network == "mainnet") '' + postStart = '' walletname=wallet.jmdat wallet=${cfg.dataDir}/wallets/$walletname if [[ ! -f $wallet ]]; then ${optionalString (cfg.rpcWalletFile != null) '' echo "Create watch-only wallet ${cfg.rpcWalletFile}" if ! output=$(${bitcoind.cli}/bin/bitcoin-cli -named createwallet \ - wallet_name="${cfg.rpcWalletFile}" disable_private_keys=true 2>&1); then + wallet_name="${cfg.rpcWalletFile}" \ + ${optionalString (!bitcoind.regtest) "disable_private_keys=true"} 2>&1 + ); then # Ignore error if bitcoind wallet already exists if [[ $output != *"already exists"* ]]; then echo "$output" diff --git a/test/tests.nix b/test/tests.nix index 6f5d741..6e0710f 100644 --- a/test/tests.nix +++ b/test/tests.nix @@ -248,9 +248,6 @@ let services.lightning-pool.extraConfig = '' auctionserver=localhost ''; - - # Needs wallet support which is unavailable for regtest - services.joinmarket.yieldgenerator.enable = mkForce false; }; ## Examples / debug helper diff --git a/test/tests.py b/test/tests.py index e8a9534..163e147 100644 --- a/test/tests.py +++ b/test/tests.py @@ -218,9 +218,12 @@ def _(): @test("joinmarket-yieldgenerator") def _(): - machine.wait_until_succeeds( - log_has_string("joinmarket-yieldgenerator", "Critical error updating blockheight.") - ) + if "regtest" in enabled_tests: + expected_log_msg = "You do not have the minimum required amount of coins to be a maker" + else: + expected_log_msg = "Critical error updating blockheight." + + machine.wait_until_succeeds(log_has_string("joinmarket-yieldgenerator", expected_log_msg)) @test("joinmarket-ob-watcher") def _():