Skip to content

Commit

Permalink
qa: enhance the CPFP test
Browse files Browse the repository at this point in the history
Avoid two races, and sanity check the tx-cpfp pairs feerate.
  • Loading branch information
darosior committed Dec 14, 2021
1 parent 978d3dd commit 7050a96
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/daemon/bitcoind/poller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,8 @@ fn maybe_cpfp_txs(
// TODO: std transaction max size check and split
if !to_cpfp.is_empty() {
cpfp_package(revaultd, bitcoind, to_cpfp, current_feerate)?;
} else {
log::debug!("Nothing to CPFP");
}

Ok(())
Expand Down
20 changes: 12 additions & 8 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,17 @@ def test_cpfp_transaction(revault_network, bitcoind):
# Uh oh! The feerate is too low, miners aren't including our transaction...
bitcoind.generate_blocks_censor(1, unvault_txids)
man.wait_for_log("CPFPed transactions")
wait_for(lambda: len(bitcoind.rpc.getrawmempool()) == len(unvault_txids) + 1)
for unvault_txid in unvault_txids:
assert bitcoind.rpc.getmempoolentry(unvault_txid)["descendantcount"] == 2
entry = bitcoind.rpc.getmempoolentry(unvault_txid)
assert entry["descendantcount"] == 2
package_feerate = entry["fees"]["descendant"] * COIN / entry["descendantsize"]
assert package_feerate >= 50

# Alright, now let's do everything again for the spend :tada:

# Confirming the unvaults
bitcoind.generate_block(1)
bitcoind.generate_block(1, wait_for_mempool=unvault_txids)
for w in revault_network.participants():
wait_for(
lambda: len(w.rpc.listvaults(["unvaulted"])["vaults"]) == len(vaults),
Expand All @@ -291,7 +295,11 @@ def test_cpfp_transaction(revault_network, bitcoind):
man.wait_for_log(
f"CPFPed transactions with ids '{{{spend_txid}}}'",
)
assert bitcoind.rpc.getmempoolentry(spend_txid)["descendantcount"] == 2
wait_for(lambda: len(bitcoind.rpc.getrawmempool()) == 2)
entry = bitcoind.rpc.getmempoolentry(spend_txid)
assert entry["descendantcount"] == 2
package_feerate = entry["fees"]["descendant"] * COIN / entry["descendantsize"]
assert package_feerate >= 50

# Let's test that non-prioritized txs don't get cpfped
amount = 0.24
Expand All @@ -307,9 +315,5 @@ def test_cpfp_transaction(revault_network, bitcoind):
man.wait_for_log(
f"Succesfully broadcasted Spend tx '{spend_txid}'",
)

# Uh oh! The feerate is too low, miners aren't including our transaction...
bitcoind.generate_blocks_censor(1, [spend_txid])
man.wait_for_log("Checking if transactions need CPFP...")
# Nah, they don't
assert bitcoind.rpc.getmempoolentry(spend_txid)["descendantcount"] == 1
man.wait_for_logs(["Checking if transactions need CPFP...", "Nothing to CPFP"])

0 comments on commit 7050a96

Please sign in to comment.