@@ -92,24 +92,24 @@ def run_test(self):
9292 SCRIPT_PUB_KEY_OP_TRUE = b'\x51 \x75 ' * 15 + b'\x51 '
9393 tx_withhold = CTransaction ()
9494 tx_withhold .vin .append (CTxIn (outpoint = COutPoint (block1 .vtx [0 ].sha256 , 0 )))
95- tx_withhold .vout . append ( CTxOut (nValue = 50 * COIN - 12000 , scriptPubKey = SCRIPT_PUB_KEY_OP_TRUE ))
95+ tx_withhold .vout = [ CTxOut (nValue = 25 * COIN - 12000 , scriptPubKey = SCRIPT_PUB_KEY_OP_TRUE )] * 2
9696 tx_withhold .calc_sha256 ()
9797
9898 # Our first orphan tx with some outputs to create further orphan txs
9999 tx_orphan_1 = CTransaction ()
100100 tx_orphan_1 .vin .append (CTxIn (outpoint = COutPoint (tx_withhold .sha256 , 0 )))
101- tx_orphan_1 .vout = [CTxOut (nValue = 10 * COIN , scriptPubKey = SCRIPT_PUB_KEY_OP_TRUE )] * 3
101+ tx_orphan_1 .vout = [CTxOut (nValue = 8 * COIN , scriptPubKey = SCRIPT_PUB_KEY_OP_TRUE )] * 3
102102 tx_orphan_1 .calc_sha256 ()
103103
104104 # A valid transaction with low fee
105105 tx_orphan_2_no_fee = CTransaction ()
106106 tx_orphan_2_no_fee .vin .append (CTxIn (outpoint = COutPoint (tx_orphan_1 .sha256 , 0 )))
107- tx_orphan_2_no_fee .vout .append (CTxOut (nValue = 10 * COIN , scriptPubKey = SCRIPT_PUB_KEY_OP_TRUE ))
107+ tx_orphan_2_no_fee .vout .append (CTxOut (nValue = 8 * COIN , scriptPubKey = SCRIPT_PUB_KEY_OP_TRUE ))
108108
109109 # A valid transaction with sufficient fee
110110 tx_orphan_2_valid = CTransaction ()
111111 tx_orphan_2_valid .vin .append (CTxIn (outpoint = COutPoint (tx_orphan_1 .sha256 , 1 )))
112- tx_orphan_2_valid .vout .append (CTxOut (nValue = 10 * COIN - 12000 , scriptPubKey = SCRIPT_PUB_KEY_OP_TRUE ))
112+ tx_orphan_2_valid .vout .append (CTxOut (nValue = 8 * COIN - 12000 , scriptPubKey = SCRIPT_PUB_KEY_OP_TRUE ))
113113 tx_orphan_2_valid .calc_sha256 ()
114114
115115 # An invalid transaction with negative fee
@@ -168,6 +168,31 @@ def run_test(self):
168168 with node .assert_debug_log (['Erased 100 orphan tx from peer=25' ]):
169169 self .reconnect_p2p (num_connections = 1 )
170170
171+ self .log .info ('Test that a transaction in the orphan pool is included in a new tip block causes erase this transaction from the orphan pool' )
172+ tx_withhold_until_block_A = CTransaction ()
173+ tx_withhold_until_block_A .vin .append (CTxIn (outpoint = COutPoint (tx_withhold .sha256 , 1 )))
174+ tx_withhold_until_block_A .vout = [CTxOut (nValue = 12 * COIN , scriptPubKey = SCRIPT_PUB_KEY_OP_TRUE )] * 2
175+ tx_withhold_until_block_A .calc_sha256 ()
176+
177+ tx_orphan_include_by_block_A = CTransaction ()
178+ tx_orphan_include_by_block_A .vin .append (CTxIn (outpoint = COutPoint (tx_withhold_until_block_A .sha256 , 0 )))
179+ tx_orphan_include_by_block_A .vout .append (CTxOut (nValue = 12 * COIN - 12000 , scriptPubKey = SCRIPT_PUB_KEY_OP_TRUE ))
180+ tx_orphan_include_by_block_A .calc_sha256 ()
181+
182+ self .log .info ('Send the orphan ... ' )
183+ node .p2ps [0 ].send_txs_and_test ([tx_orphan_include_by_block_A ], node , success = False )
184+
185+ tip = int (node .getbestblockhash (), 16 )
186+ height = node .getblockcount () + 1
187+ block_A = create_block (tip , create_coinbase (height ))
188+ block_A .vtx .extend ([tx_withhold , tx_withhold_until_block_A , tx_orphan_include_by_block_A ])
189+ block_A .hashMerkleRoot = block_A .calc_merkle_root ()
190+ block_A .solve ()
191+
192+ self .log .info ('Send the block that includes the previous orphan ... ' )
193+ with node .assert_debug_log (["Erased 1 orphan tx included or conflicted by block" ]):
194+ node .p2ps [0 ].send_blocks_and_test ([block_A ], node , success = True )
195+
171196
172197if __name__ == '__main__' :
173198 InvalidTxRequestTest ().main ()
0 commit comments