@@ -92,24 +92,24 @@ def run_test(self):
92
92
SCRIPT_PUB_KEY_OP_TRUE = b'\x51 \x75 ' * 15 + b'\x51 '
93
93
tx_withhold = CTransaction ()
94
94
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
96
96
tx_withhold .calc_sha256 ()
97
97
98
98
# Our first orphan tx with some outputs to create further orphan txs
99
99
tx_orphan_1 = CTransaction ()
100
100
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
102
102
tx_orphan_1 .calc_sha256 ()
103
103
104
104
# A valid transaction with low fee
105
105
tx_orphan_2_no_fee = CTransaction ()
106
106
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 ))
108
108
109
109
# A valid transaction with sufficient fee
110
110
tx_orphan_2_valid = CTransaction ()
111
111
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 ))
113
113
tx_orphan_2_valid .calc_sha256 ()
114
114
115
115
# An invalid transaction with negative fee
@@ -168,6 +168,31 @@ def run_test(self):
168
168
with node .assert_debug_log (['Erased 100 orphan tx from peer=25' ]):
169
169
self .reconnect_p2p (num_connections = 1 )
170
170
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
+
171
196
172
197
if __name__ == '__main__' :
173
198
InvalidTxRequestTest ().main ()
0 commit comments