Skip to content

Commit

Permalink
Test that the coordinator broadcasts spend txs
Browse files Browse the repository at this point in the history
  • Loading branch information
danielabrozzoni committed Feb 7, 2022
1 parent c46954a commit cf12dba
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/servers/coordinatord
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
29 changes: 29 additions & 0 deletions tests/test_spend.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,3 +694,32 @@ 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):
"""
Revault an ongoing Spend transaction carried out by the managers, under misc
circumstances.
"""
CSV = 12
revault_network.deploy(2, 2, n_stkmanagers=1, csv=CSV)

# Simple case. Managers Spend a single vault.
vault = revault_network.fund(0.05)
revault_network.secure_vault(vault)
revault_network.activate_vault(vault)
revault_network.unvault_vaults_anyhow([vault])

for w in revault_network.participants():
w.stop()

bitcoind.generate_block(CSV - 1)
bitcoind.generate_block(1, wait_for_mempool=1)

for w in revault_network.participants():
w.start()
wait_for(
lambda: len(w.rpc.listvaults(["spent"])["vaults"]) == 1,
)

0 comments on commit cf12dba

Please sign in to comment.