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 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..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 @@ -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, + )