16
16
CTxOut ,
17
17
sha256 ,
18
18
)
19
+ from test_framework .p2p import P2PTxInvStore
19
20
from test_framework .script import (
20
21
CScript ,
21
22
OP_0 ,
@@ -62,6 +63,8 @@ def run_test(self):
62
63
parent_txid = node .sendrawtransaction (hexstring = raw_parent , maxfeerate = 0 )
63
64
node .generate (1 )
64
65
66
+ peer_wtxid_relay = node .add_p2p_connection (P2PTxInvStore ())
67
+
65
68
# Create a new transaction with witness solving first branch
66
69
child_witness_script = CScript ([OP_TRUE ])
67
70
child_witness_program = sha256 (child_witness_script )
@@ -87,10 +90,13 @@ def run_test(self):
87
90
assert_equal (child_one_txid , child_two_txid )
88
91
assert child_one_wtxid != child_two_wtxid
89
92
90
- self .log .info ("Submit one child to the mempool" )
93
+ self .log .info ("Submit child_one to the mempool" )
91
94
txid_submitted = node .sendrawtransaction (child_one .serialize ().hex ())
92
95
assert_equal (node .getrawmempool (True )[txid_submitted ]['wtxid' ], child_one_wtxid )
93
96
97
+ peer_wtxid_relay .wait_for_broadcast ([child_one_wtxid ])
98
+ assert_equal (node .getmempoolinfo ()["unbroadcastcount" ], 0 )
99
+
94
100
# testmempoolaccept reports the "already in mempool" error
95
101
assert_equal (node .testmempoolaccept ([child_one .serialize ().hex ()]), [{
96
102
"txid" : child_one_txid ,
@@ -108,9 +114,18 @@ def run_test(self):
108
114
109
115
# sendrawtransaction will not throw but quits early when the exact same transaction is already in mempool
110
116
node .sendrawtransaction (child_one .serialize ().hex ())
117
+
118
+ self .log .info ("Connect another peer that hasn't seen child_one before" )
119
+ peer_wtxid_relay_2 = node .add_p2p_connection (P2PTxInvStore ())
120
+
121
+ self .log .info ("Submit child_two to the mempool" )
111
122
# sendrawtransaction will not throw but quits early when a transaction with the same non-witness data is already in mempool
112
123
node .sendrawtransaction (child_two .serialize ().hex ())
113
124
125
+ # The node should rebroadcast the transaction using the wtxid of the correct transaction
126
+ # (child_one, which is in its mempool).
127
+ peer_wtxid_relay_2 .wait_for_broadcast ([child_one_wtxid ])
128
+ assert_equal (node .getmempoolinfo ()["unbroadcastcount" ], 0 )
114
129
115
130
if __name__ == '__main__' :
116
131
MempoolWtxidTest ().main ()
0 commit comments