From 30e3e0864dbf34ecc8a1a6acdc0b636a1517fd7c Mon Sep 17 00:00:00 2001 From: Daniela Brozzoni Date: Mon, 7 Feb 2022 16:49:15 +0100 Subject: [PATCH 1/3] Update to latest coordinatord --- tests/servers/coordinatord | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/servers/coordinatord b/tests/servers/coordinatord index 9b90fcd3..94f0f899 160000 --- a/tests/servers/coordinatord +++ b/tests/servers/coordinatord @@ -1 +1 @@ -Subproject commit 9b90fcd3ad5dfb51bf50dcaef859c5cc00dbfe3a +Subproject commit 94f0f8996dab4dbf6b0c6968df0d933f5e481318 From b8b90a8e2e12d40acd4c14f17fc5b4161a4748c1 Mon Sep 17 00:00:00 2001 From: Daniela Brozzoni Date: Tue, 1 Feb 2022 20:00:14 +0100 Subject: [PATCH 2/3] Test that the coordinator broadcasts spend txs --- tests/test_framework/coordinatord.py | 9 ++++++++- tests/test_framework/revault_network.py | 2 ++ tests/test_spend.py | 27 +++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/tests/test_framework/coordinatord.py b/tests/test_framework/coordinatord.py index 5f047ed4..a11290c0 100644 --- a/tests/test_framework/coordinatord.py +++ b/tests/test_framework/coordinatord.py @@ -13,6 +13,8 @@ def __init__( stakeholders_keys, watchtowers_keys, listen_port, + bitcoind_rpc_port, + bitcoind_cookie_path, postgres_user, postgres_pass, postgres_host="localhost", @@ -69,7 +71,12 @@ def __init__( f.write(f'"{k.hex()}", ') f.write("]\n") - f.write(f'listen = "127.0.0.1:{listen_port}"') + f.write(f'listen = "127.0.0.1:{listen_port}"\n') + + f.write("[bitcoind_config]\n") + f.write(f"cookie_path = '{bitcoind_cookie_path}'\n") + f.write(f"addr = '127.0.0.1:{bitcoind_rpc_port}'\n") + f.write("broadcast_interval = 5\n") def postgres_exec(self, sql): conn = psycopg2.connect( diff --git a/tests/test_framework/revault_network.py b/tests/test_framework/revault_network.py index c71bb208..ec09f7c0 100644 --- a/tests/test_framework/revault_network.py +++ b/tests/test_framework/revault_network.py @@ -210,6 +210,8 @@ def deploy( stkonly_noisepubs + stkman_noisepubs, stkonly_wt_noisepubs + stkman_wt_noisepubs, self.coordinator_port, + bitcoind_rpcport, + bitcoind_cookie, self.postgres_user, self.postgres_pass, self.postgres_host, diff --git a/tests/test_spend.py b/tests/test_spend.py index b0f50b22..6b306b6c 100644 --- a/tests/test_spend.py +++ b/tests/test_spend.py @@ -694,3 +694,30 @@ def test_revaulted_spend(revault_network, bitcoind, executor): lambda: len(w.rpc.listvaults(["unvaulted"], deposits)["vaults"]) == len(deposits) ) + + +# Test that the coordinator will broadcast our spends +@pytest.mark.skipif(not POSTGRES_IS_SETUP, reason="Needs Postgres for servers db") +def test_coordinator_broadcast(revault_network, bitcoind, executor): + """ + Test that the coordinator broadcasts spend transactions when they become valid + """ + CSV = 12 + revault_network.deploy(2, 2, n_stkmanagers=1, csv=CSV) + + vault = revault_network.fund(0.05) + revault_network.secure_vault(vault) + revault_network.activate_vault(vault) + revault_network.unvault_vaults_anyhow([vault]) + + revault_network.stop_wallets() + + bitcoind.generate_block(CSV - 1) + bitcoind.generate_block(1, wait_for_mempool=1) + + revault_network.start_wallets() + + for w in revault_network.participants(): + wait_for( + lambda: len(w.rpc.listvaults(["spent"])["vaults"]) == 1, + ) From 5075f2384fc57036b6f5db32d0659e921c76161c Mon Sep 17 00:00:00 2001 From: Daniela Brozzoni Date: Wed, 9 Feb 2022 15:23:35 +0100 Subject: [PATCH 3/3] Lower the number of stks/mans in test_spend_threshold I'm not really sure why we would test with a deployment that big (I'm fairly convinced it was just bad copypasta from another test). This should reduce the amount of timeouts in CI. --- tests/test_spend.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_spend.py b/tests/test_spend.py index 6b306b6c..126d237c 100644 --- a/tests/test_spend.py +++ b/tests/test_spend.py @@ -386,8 +386,8 @@ def test_spends_conflicting(revault_network, bitcoind): @pytest.mark.skipif(not POSTGRES_IS_SETUP, reason="Needs Postgres for servers db") def test_spend_threshold(revault_network, bitcoind, executor): CSV = 20 - managers_threshold = 3 - revault_network.deploy(17, 8, csv=CSV, managers_threshold=managers_threshold) + managers_threshold = 2 + revault_network.deploy(4, 3, csv=CSV, managers_threshold=managers_threshold) man = revault_network.man(0) # Get some more funds