@@ -193,6 +193,35 @@ def run_test(self):
193
193
with node .assert_debug_log (["Erased 1 orphan tx included or conflicted by block" ]):
194
194
node .p2ps [0 ].send_blocks_and_test ([block_A ], node , success = True )
195
195
196
+ self .log .info ('Test that a transaction in the orphan pool conflicts with a new tip block causes erase this transaction from the orphan pool' )
197
+ tx_withhold_until_block_B = CTransaction ()
198
+ tx_withhold_until_block_B .vin .append (CTxIn (outpoint = COutPoint (tx_withhold_until_block_A .sha256 , 1 )))
199
+ tx_withhold_until_block_B .vout .append (CTxOut (nValue = 11 * COIN , scriptPubKey = SCRIPT_PUB_KEY_OP_TRUE ))
200
+ tx_withhold_until_block_B .calc_sha256 ()
201
+
202
+ tx_orphan_include_by_block_B = CTransaction ()
203
+ tx_orphan_include_by_block_B .vin .append (CTxIn (outpoint = COutPoint (tx_withhold_until_block_B .sha256 , 0 )))
204
+ tx_orphan_include_by_block_B .vout .append (CTxOut (nValue = 10 * COIN , scriptPubKey = SCRIPT_PUB_KEY_OP_TRUE ))
205
+ tx_orphan_include_by_block_B .calc_sha256 ()
206
+
207
+ tx_orphan_conflict_by_block_B = CTransaction ()
208
+ tx_orphan_conflict_by_block_B .vin .append (CTxIn (outpoint = COutPoint (tx_withhold_until_block_B .sha256 , 0 )))
209
+ tx_orphan_conflict_by_block_B .vout .append (CTxOut (nValue = 9 * COIN , scriptPubKey = SCRIPT_PUB_KEY_OP_TRUE ))
210
+ tx_orphan_conflict_by_block_B .calc_sha256 ()
211
+ self .log .info ('Send the orphan ... ' )
212
+ node .p2ps [0 ].send_txs_and_test ([tx_orphan_conflict_by_block_B ], node , success = False )
213
+
214
+ tip = int (node .getbestblockhash (), 16 )
215
+ height = node .getblockcount () + 1
216
+ block_B = create_block (tip , create_coinbase (height ))
217
+ block_B .vtx .extend ([tx_withhold_until_block_B , tx_orphan_include_by_block_B ])
218
+ block_B .hashMerkleRoot = block_B .calc_merkle_root ()
219
+ block_B .solve ()
220
+
221
+ self .log .info ('Send the block that includes a transaction which conflicts with the previous orphan ... ' )
222
+ with node .assert_debug_log (["Erased 1 orphan tx included or conflicted by block" ]):
223
+ node .p2ps [0 ].send_blocks_and_test ([block_B ], node , success = True )
224
+
196
225
197
226
if __name__ == '__main__' :
198
227
InvalidTxRequestTest ().main ()
0 commit comments