Skip to content

Commit b8b90a8

Browse files
Test that the coordinator broadcasts spend txs
1 parent 30e3e08 commit b8b90a8

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

tests/test_framework/coordinatord.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ def __init__(
1313
stakeholders_keys,
1414
watchtowers_keys,
1515
listen_port,
16+
bitcoind_rpc_port,
17+
bitcoind_cookie_path,
1618
postgres_user,
1719
postgres_pass,
1820
postgres_host="localhost",
@@ -69,7 +71,12 @@ def __init__(
6971
f.write(f'"{k.hex()}", ')
7072
f.write("]\n")
7173

72-
f.write(f'listen = "127.0.0.1:{listen_port}"')
74+
f.write(f'listen = "127.0.0.1:{listen_port}"\n')
75+
76+
f.write("[bitcoind_config]\n")
77+
f.write(f"cookie_path = '{bitcoind_cookie_path}'\n")
78+
f.write(f"addr = '127.0.0.1:{bitcoind_rpc_port}'\n")
79+
f.write("broadcast_interval = 5\n")
7380

7481
def postgres_exec(self, sql):
7582
conn = psycopg2.connect(

tests/test_framework/revault_network.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ def deploy(
210210
stkonly_noisepubs + stkman_noisepubs,
211211
stkonly_wt_noisepubs + stkman_wt_noisepubs,
212212
self.coordinator_port,
213+
bitcoind_rpcport,
214+
bitcoind_cookie,
213215
self.postgres_user,
214216
self.postgres_pass,
215217
self.postgres_host,

tests/test_spend.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,3 +694,30 @@ def test_revaulted_spend(revault_network, bitcoind, executor):
694694
lambda: len(w.rpc.listvaults(["unvaulted"], deposits)["vaults"])
695695
== len(deposits)
696696
)
697+
698+
699+
# Test that the coordinator will broadcast our spends
700+
@pytest.mark.skipif(not POSTGRES_IS_SETUP, reason="Needs Postgres for servers db")
701+
def test_coordinator_broadcast(revault_network, bitcoind, executor):
702+
"""
703+
Test that the coordinator broadcasts spend transactions when they become valid
704+
"""
705+
CSV = 12
706+
revault_network.deploy(2, 2, n_stkmanagers=1, csv=CSV)
707+
708+
vault = revault_network.fund(0.05)
709+
revault_network.secure_vault(vault)
710+
revault_network.activate_vault(vault)
711+
revault_network.unvault_vaults_anyhow([vault])
712+
713+
revault_network.stop_wallets()
714+
715+
bitcoind.generate_block(CSV - 1)
716+
bitcoind.generate_block(1, wait_for_mempool=1)
717+
718+
revault_network.start_wallets()
719+
720+
for w in revault_network.participants():
721+
wait_for(
722+
lambda: len(w.rpc.listvaults(["spent"])["vaults"]) == 1,
723+
)

0 commit comments

Comments
 (0)