Skip to content

Commit 3ab3c6a

Browse files
committed
Merge #361: Test that the coordinator broadcasts spend txs
5075f23 Lower the number of stks/mans in test_spend_threshold (Daniela Brozzoni) b8b90a8 Test that the coordinator broadcasts spend txs (Daniela Brozzoni) 30e3e08 Update to latest coordinatord (Daniela Brozzoni) Pull request description: Needs revault/coordinatord#46 ACKs for top commit: darosior: utACK 5075f23 Tree-SHA512: 7c8382b489dd51fb2090a3d82c300fdc35beae08b907b6a1c2b138c709576a1c989bf071f30605cc652e5e627b9ac7fab059ce90f5a2ec08bc514789bbe78992
2 parents 843e513 + 5075f23 commit 3ab3c6a

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
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: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ def test_spends_conflicting(revault_network, bitcoind):
386386
@pytest.mark.skipif(not POSTGRES_IS_SETUP, reason="Needs Postgres for servers db")
387387
def test_spend_threshold(revault_network, bitcoind, executor):
388388
CSV = 20
389-
managers_threshold = 3
390-
revault_network.deploy(17, 8, csv=CSV, managers_threshold=managers_threshold)
389+
managers_threshold = 2
390+
revault_network.deploy(4, 3, csv=CSV, managers_threshold=managers_threshold)
391391
man = revault_network.man(0)
392392

393393
# Get some more funds
@@ -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)