Skip to content

Commit

Permalink
Merge #361: Test that the coordinator broadcasts spend txs
Browse files Browse the repository at this point in the history
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
  • Loading branch information
darosior committed Feb 9, 2022
2 parents 843e513 + 5075f23 commit 3ab3c6a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
9 changes: 8 additions & 1 deletion tests/test_framework/coordinatord.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions tests/test_framework/revault_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
31 changes: 29 additions & 2 deletions tests/test_spend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
)

0 comments on commit 3ab3c6a

Please sign in to comment.