@@ -118,6 +118,7 @@ def run_test(self):
118
118
tx_orphan_2_invalid = CTransaction ()
119
119
tx_orphan_2_invalid .vin .append (CTxIn (outpoint = COutPoint (tx_orphan_1 .sha256 , 2 )))
120
120
tx_orphan_2_invalid .vout .append (CTxOut (nValue = 11 * COIN , scriptPubKey = SCRIPT_PUB_KEY_OP_TRUE ))
121
+ tx_orphan_2_invalid .calc_sha256 ()
121
122
122
123
self .log .info ('Send the orphans ... ' )
123
124
# Send valid orphan txs from p2ps[0]
@@ -148,6 +149,22 @@ def run_test(self):
148
149
wait_until (lambda : 1 == len (node .getpeerinfo ()), timeout = 12 ) # p2ps[1] is no longer connected
149
150
assert_equal (expected_mempool , set (node .getrawmempool ()))
150
151
152
+ self .log .info ('Test orphan pool overflow' )
153
+ orphan_tx_pool = [CTransaction () for _ in range (101 )]
154
+ for i in range (len (orphan_tx_pool )):
155
+ orphan_tx_pool [i ].vin .append (CTxIn (outpoint = COutPoint (i , 333 )))
156
+ orphan_tx_pool [i ].vout .append (CTxOut (nValue = 11 * COIN , scriptPubKey = SCRIPT_PUB_KEY_OP_TRUE ))
157
+
158
+ with node .assert_debug_log (['mapOrphan overflow, removed 1 tx' ]):
159
+ node .p2p .send_txs_and_test (orphan_tx_pool , node , success = False )
160
+
161
+ rejected_parent = CTransaction ()
162
+ rejected_parent .vin .append (CTxIn (outpoint = COutPoint (tx_orphan_2_invalid .sha256 , 0 )))
163
+ rejected_parent .vout .append (CTxOut (nValue = 11 * COIN , scriptPubKey = SCRIPT_PUB_KEY_OP_TRUE ))
164
+ rejected_parent .rehash ()
165
+ with node .assert_debug_log (['not keeping orphan with rejected parents {}' .format (rejected_parent .hash )]):
166
+ node .p2p .send_txs_and_test ([rejected_parent ], node , success = False )
167
+
151
168
152
169
if __name__ == '__main__' :
153
170
InvalidTxRequestTest ().main ()
0 commit comments