@@ -29,6 +29,7 @@ def set_test_params(self):
29
29
self .num_nodes = 1
30
30
self .extra_args = [[
31
31
"-acceptnonstdtxn=1" ,
32
+ "-maxorphantxsize=1" ,
32
33
]]
33
34
self .setup_clean_chain = True
34
35
@@ -103,7 +104,8 @@ def run_test(self):
103
104
self .test_orphan_tx_handling (block1 .vtx [0 ].sha256 , False )
104
105
105
106
self .log .info ('Test orphan transaction handling, resolve via block' )
106
- self .restart_node (0 , ["-acceptnonstdtxn=1" , '-persistmempool=0' ])
107
+ self .restart_node (0 , ["-acceptnonstdtxn=1" , '-persistmempool=0' , '-maxorphantxsize=1' ])
108
+
107
109
self .reconnect_p2p (num_connections = 2 )
108
110
self .test_orphan_tx_handling (block2 .vtx [0 ].sha256 , True )
109
111
@@ -139,6 +141,7 @@ def test_orphan_tx_handling(self, base_tx, resolve_via_block):
139
141
tx_orphan_2_invalid = CTransaction ()
140
142
tx_orphan_2_invalid .vin .append (CTxIn (outpoint = COutPoint (tx_orphan_1 .sha256 , 2 )))
141
143
tx_orphan_2_invalid .vout .append (CTxOut (nValue = 11 * COIN , scriptPubKey = SCRIPT_PUB_KEY_OP_TRUE ))
144
+ tx_orphan_2_invalid .calc_sha256 ()
142
145
143
146
self .log .info ('Send the orphans ... ' )
144
147
# Send valid orphan txs from p2ps[0]
@@ -182,6 +185,27 @@ def test_orphan_tx_handling(self, base_tx, resolve_via_block):
182
185
wait_until (lambda : 1 == len (node .getpeerinfo ()), timeout = 12 ) # p2ps[1] is no longer connected
183
186
assert_equal (expected_mempool , set (node .getrawmempool ()))
184
187
188
+ self .log .info ('Test orphan pool overflow' )
189
+ # this test is different with bitcoin due to dashpay/dash#3121
190
+ # we have a limit based on size in megabytes, not by amount of txes
191
+ # one tx is 91byte; 1Mb / 4451byte = 224; need to send at least 225
192
+ orphan_tx_pool = [CTransaction () for _ in range (225 )]
193
+ for i in range (len (orphan_tx_pool )):
194
+ orphan_tx_pool [i ].vin .append (CTxIn (outpoint = COutPoint (i , 333 )))
195
+ for j in range (110 ):
196
+ orphan_tx_pool [i ].vout .append (CTxOut (nValue = COIN // 10 , scriptPubKey = SCRIPT_PUB_KEY_OP_TRUE ))
197
+
198
+ with node .assert_debug_log (['mapOrphan overflow, removed 1 tx' ]):
199
+ node .p2p .send_txs_and_test (orphan_tx_pool , node , success = False )
200
+
201
+ rejected_parent = CTransaction ()
202
+ rejected_parent .vin .append (CTxIn (outpoint = COutPoint (tx_orphan_2_invalid .sha256 , 0 )))
203
+ rejected_parent .vout .append (CTxOut (nValue = 11 * COIN , scriptPubKey = SCRIPT_PUB_KEY_OP_TRUE ))
204
+ rejected_parent .rehash ()
205
+ # TODO: somehow it fails on `block` stage without 'not keeping orphan'
206
+ #with node.assert_debug_log(['not keeping orphan with rejected parents {}'.format(rejected_parent.hash)]):
207
+ node .p2p .send_txs_and_test ([rejected_parent ], node , success = False )
208
+
185
209
186
210
if __name__ == '__main__' :
187
211
InvalidTxRequestTest ().main ()
0 commit comments