From 847b6ed48d7bacec9024618922e9b339d2d97676 Mon Sep 17 00:00:00 2001 From: Duncan Dean Date: Wed, 7 Jul 2021 10:06:27 +0100 Subject: [test] Test transactions are not re-added to unbroadcast set --- test/functional/mempool_unbroadcast.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test') diff --git a/test/functional/mempool_unbroadcast.py b/test/functional/mempool_unbroadcast.py index b475b65e68..7d9e6c306d 100755 --- a/test/functional/mempool_unbroadcast.py +++ b/test/functional/mempool_unbroadcast.py @@ -92,6 +92,12 @@ class MempoolUnbroadcastTest(BitcoinTestFramework): self.disconnect_nodes(0, 1) node.disconnect_p2ps() + self.log.info("Rebroadcast transaction and ensure it is not added to unbroadcast set when already in mempool") + rpc_tx_hsh = node.sendrawtransaction(txFS["hex"]) + mempool = node.getrawmempool(True) + assert rpc_tx_hsh in mempool + assert not mempool[rpc_tx_hsh]['unbroadcast'] + def test_txn_removal(self): self.log.info("Test that transactions removed from mempool are removed from unbroadcast set") node = self.nodes[0] -- cgit v1.2.3 From 7282d4c0363ab5152baa34af626cb49afbfddc32 Mon Sep 17 00:00:00 2001 From: glozow Date: Fri, 11 Jun 2021 14:49:19 +0100 Subject: [test] Allow rebroadcast for same-txid-different-wtxid transactions Co-authored-by: John Newbery --- test/functional/mempool_accept_wtxid.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/functional/mempool_accept_wtxid.py b/test/functional/mempool_accept_wtxid.py index dd1f8997ad..63ecc8ee2a 100755 --- a/test/functional/mempool_accept_wtxid.py +++ b/test/functional/mempool_accept_wtxid.py @@ -16,6 +16,7 @@ from test_framework.messages import ( CTxOut, sha256, ) +from test_framework.p2p import P2PTxInvStore from test_framework.script import ( CScript, OP_0, @@ -62,6 +63,8 @@ class MempoolWtxidTest(BitcoinTestFramework): parent_txid = node.sendrawtransaction(hexstring=raw_parent, maxfeerate=0) node.generate(1) + peer_wtxid_relay = node.add_p2p_connection(P2PTxInvStore()) + # Create a new transaction with witness solving first branch child_witness_script = CScript([OP_TRUE]) child_witness_program = sha256(child_witness_script) @@ -87,10 +90,13 @@ class MempoolWtxidTest(BitcoinTestFramework): assert_equal(child_one_txid, child_two_txid) assert child_one_wtxid != child_two_wtxid - self.log.info("Submit one child to the mempool") + self.log.info("Submit child_one to the mempool") txid_submitted = node.sendrawtransaction(child_one.serialize().hex()) assert_equal(node.getrawmempool(True)[txid_submitted]['wtxid'], child_one_wtxid) + peer_wtxid_relay.wait_for_broadcast([child_one_wtxid]) + assert_equal(node.getmempoolinfo()["unbroadcastcount"], 0) + # testmempoolaccept reports the "already in mempool" error assert_equal(node.testmempoolaccept([child_one.serialize().hex()]), [{ "txid": child_one_txid, @@ -108,9 +114,18 @@ class MempoolWtxidTest(BitcoinTestFramework): # sendrawtransaction will not throw but quits early when the exact same transaction is already in mempool node.sendrawtransaction(child_one.serialize().hex()) + + self.log.info("Connect another peer that hasn't seen child_one before") + peer_wtxid_relay_2 = node.add_p2p_connection(P2PTxInvStore()) + + self.log.info("Submit child_two to the mempool") # sendrawtransaction will not throw but quits early when a transaction with the same non-witness data is already in mempool node.sendrawtransaction(child_two.serialize().hex()) + # The node should rebroadcast the transaction using the wtxid of the correct transaction + # (child_one, which is in its mempool). + peer_wtxid_relay_2.wait_for_broadcast([child_one_wtxid]) + assert_equal(node.getmempoolinfo()["unbroadcastcount"], 0) if __name__ == '__main__': MempoolWtxidTest().main() -- cgit v1.2.3