Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test that the coordinator broadcasts spend txs #361

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment about the commit message, not this line.

I'm not really sure why we would test with a deployment that
big (I'm fairly convinced it was just bad copypasta from another
test). This should reduce the amount of timeouts in CI.

My rationale was testing larger setups. It should be an explicitly dedicated test, instead so ACK for decreasing it.

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,
)