diff --git a/test/functional/p2p_private_broadcast.py b/test/functional/p2p_private_broadcast.py index f43863eeb5f..b81b5aa483d 100755 --- a/test/functional/p2p_private_broadcast.py +++ b/test/functional/p2p_private_broadcast.py @@ -310,7 +310,7 @@ class P2PPrivateBroadcast(BitcoinTestFramework): peers = pending[0]["peers"] assert len(peers) >= NUM_PRIVATE_BROADCAST_PER_TX assert all("address" in p and "sent" in p for p in peers) - assert_greater_than_or_equal(sum(1 for p in peers if "received" in p), NUM_PRIVATE_BROADCAST_PER_TX) + assert_greater_than_or_equal(sum(1 for p in peers if "received" in p), broadcasts_to_expect) def run_test(self): tx_originator = self.nodes[0] @@ -382,25 +382,6 @@ class P2PPrivateBroadcast(BitcoinTestFramework): pending = [t for t in pbinfo["transactions"] if t["txid"] == txs[0]["txid"] and t["wtxid"] == txs[0]["wtxid"]] assert_equal(len(pending), 0) - self.log.info("Checking abortprivatebroadcast removes a pending private-broadcast transaction") - tx_abort = wallet.create_self_transfer() - tx_originator.sendrawtransaction(hexstring=tx_abort["hex"], maxfeerate=0.1) - assert any(t["wtxid"] == tx_abort["wtxid"] for t in tx_originator.getprivatebroadcastinfo()["transactions"]) - abort_res = tx_originator.abortprivatebroadcast(tx_abort["txid"]) - assert_equal(len(abort_res["removed_transactions"]), 1) - assert_equal(abort_res["removed_transactions"][0]["txid"], tx_abort["txid"]) - assert_equal(abort_res["removed_transactions"][0]["wtxid"], tx_abort["wtxid"]) - assert_equal(abort_res["removed_transactions"][0]["hex"].lower(), tx_abort["hex"].lower()) - assert all(t["wtxid"] != tx_abort["wtxid"] for t in tx_originator.getprivatebroadcastinfo()["transactions"]) - - self.log.info("Checking abortprivatebroadcast fails for non-existent transaction") - assert_raises_rpc_error( - -5, - "Transaction not in private broadcast queue", - tx_originator.abortprivatebroadcast, - "0" * 64, - ) - self.log.info("Sending a transaction that is already in the mempool") skip_destinations = len(self.destinations) tx_originator.sendrawtransaction(hexstring=txs[0]["hex"], maxfeerate=0) @@ -453,6 +434,25 @@ class P2PPrivateBroadcast(BitcoinTestFramework): tx_originator.sendrawtransaction(hexstring=sibling2.serialize_with_witness().hex(), maxfeerate=0.1) self.log.info(" - sent sibling2: ok") + self.log.info("Checking abortprivatebroadcast removes a pending private-broadcast transaction") + tx_abort = wallet.create_self_transfer() + tx_originator.sendrawtransaction(hexstring=tx_abort["hex"], maxfeerate=0.1) + assert any(t["wtxid"] == tx_abort["wtxid"] for t in tx_originator.getprivatebroadcastinfo()["transactions"]) + abort_res = tx_originator.abortprivatebroadcast(tx_abort["txid"]) + assert_equal(len(abort_res["removed_transactions"]), 1) + assert_equal(abort_res["removed_transactions"][0]["txid"], tx_abort["txid"]) + assert_equal(abort_res["removed_transactions"][0]["wtxid"], tx_abort["wtxid"]) + assert_equal(abort_res["removed_transactions"][0]["hex"].lower(), tx_abort["hex"].lower()) + assert all(t["wtxid"] != tx_abort["wtxid"] for t in tx_originator.getprivatebroadcastinfo()["transactions"]) + + self.log.info("Checking abortprivatebroadcast fails for non-existent transaction") + assert_raises_rpc_error( + -5, + "Transaction not in private broadcast queue", + tx_originator.abortprivatebroadcast, + "0" * 64, + ) + # Stop the SOCKS5 proxy server to avoid it being upset by the bitcoin # node disconnecting in the middle of the SOCKS5 handshake when we # restart below.