@@ -210,9 +210,9 @@ def test_orphan_rejected_parents_exceptions(self):
210
210
211
211
# Relay the child. It should not be accepted because it has missing inputs.
212
212
# Its parent should not be requested because its hash (txid == wtxid) has been added to the rejection filter.
213
- with node .assert_debug_log (['not keeping orphan with rejected parents {}' .format (child_nonsegwit ["txid" ])]):
214
- self .relay_transaction (peer2 , child_nonsegwit ["tx" ])
213
+ self .relay_transaction (peer2 , child_nonsegwit ["tx" ])
215
214
assert child_nonsegwit ["txid" ] not in node .getrawmempool ()
215
+ assert not tx_in_orphanage (node , child_nonsegwit ["tx" ])
216
216
217
217
# No parents are requested.
218
218
self .nodes [0 ].bumpmocktime (GETDATA_TX_INTERVAL )
@@ -231,6 +231,7 @@ def test_orphan_rejected_parents_exceptions(self):
231
231
# Relay the child. It should not be accepted because it has missing inputs.
232
232
self .relay_transaction (peer2 , child_low_fee ["tx" ])
233
233
assert child_low_fee ["txid" ] not in node .getrawmempool ()
234
+ assert tx_in_orphanage (node , child_low_fee ["tx" ])
234
235
235
236
# The parent should be requested because even though the txid commits to the fee, it doesn't
236
237
# commit to the feerate. Delayed because it's by txid and this is not a preferred relay peer.
@@ -250,6 +251,7 @@ def test_orphan_rejected_parents_exceptions(self):
250
251
# Relay the child. It should not be accepted because it has missing inputs.
251
252
self .relay_transaction (peer2 , child_invalid_witness ["tx" ])
252
253
assert child_invalid_witness ["txid" ] not in node .getrawmempool ()
254
+ assert tx_in_orphanage (node , child_invalid_witness ["tx" ])
253
255
254
256
# The parent should be requested since the unstripped wtxid would differ. Delayed because
255
257
# it's by txid and this is not a preferred relay peer.
@@ -298,6 +300,7 @@ def test_orphan_multiple_parents(self):
298
300
self .relay_transaction (peer , orphan ["tx" ])
299
301
self .nodes [0 ].bumpmocktime (NONPREF_PEER_TX_DELAY + TXID_RELAY_DELAY )
300
302
peer .sync_with_ping ()
303
+ assert tx_in_orphanage (node , orphan ["tx" ])
301
304
assert_equal (len (peer .last_message ["getdata" ].inv ), 2 )
302
305
peer .wait_for_parent_requests ([int (txid_conf_old , 16 ), int (missing_tx ["txid" ], 16 )])
303
306
@@ -347,6 +350,7 @@ def test_orphans_overlapping_parents(self):
347
350
# Relay orphan child_A
348
351
self .relay_transaction (peer_orphans , child_A ["tx" ])
349
352
self .nodes [0 ].bumpmocktime (NONPREF_PEER_TX_DELAY + TXID_RELAY_DELAY )
353
+ assert tx_in_orphanage (node , child_A ["tx" ])
350
354
# There are 3 missing parents. missing_parent_A and missing_parent_AB should be requested.
351
355
# But inflight_parent_AB should not, because there is already an in-flight request for it.
352
356
peer_orphans .wait_for_parent_requests ([int (missing_parent_A ["txid" ], 16 ), int (missing_parent_AB ["txid" ], 16 )])
@@ -355,6 +359,7 @@ def test_orphans_overlapping_parents(self):
355
359
# Relay orphan child_B
356
360
self .relay_transaction (peer_orphans , child_B ["tx" ])
357
361
self .nodes [0 ].bumpmocktime (NONPREF_PEER_TX_DELAY + TXID_RELAY_DELAY )
362
+ assert tx_in_orphanage (node , child_B ["tx" ])
358
363
# Only missing_parent_B should be requested. Not inflight_parent_AB or missing_parent_AB
359
364
# because they are already being requested from peer_txrequest and peer_orphans respectively.
360
365
peer_orphans .wait_for_parent_requests ([int (missing_parent_B ["txid" ], 16 )])
@@ -374,12 +379,14 @@ def test_orphan_of_orphan(self):
374
379
# The node should put missing_parent_orphan into the orphanage and request missing_grandparent
375
380
self .relay_transaction (peer , missing_parent_orphan ["tx" ])
376
381
self .nodes [0 ].bumpmocktime (NONPREF_PEER_TX_DELAY + TXID_RELAY_DELAY )
382
+ assert tx_in_orphanage (node , missing_parent_orphan ["tx" ])
377
383
peer .wait_for_parent_requests ([int (missing_grandparent ["txid" ], 16 )])
378
384
379
385
# The node should put the orphan into the orphanage and request missing_parent, skipping
380
386
# missing_parent_orphan because it already has it in the orphanage.
381
387
self .relay_transaction (peer , orphan ["tx" ])
382
388
self .nodes [0 ].bumpmocktime (NONPREF_PEER_TX_DELAY + TXID_RELAY_DELAY )
389
+ assert tx_in_orphanage (node , orphan ["tx" ])
383
390
peer .wait_for_parent_requests ([int (missing_parent ["txid" ], 16 )])
384
391
385
392
@cleanup
@@ -399,18 +406,19 @@ def test_orphan_inherit_rejection(self):
399
406
400
407
# Relay the parent. It should be rejected because it pays 0 fees.
401
408
self .relay_transaction (peer1 , parent_low_fee_nonsegwit ["tx" ])
409
+ assert parent_low_fee_nonsegwit ["txid" ] not in node .getrawmempool ()
402
410
403
411
# Relay the child. It should be rejected for having missing parents, and this rejection is
404
412
# cached by txid and wtxid.
405
- with node .assert_debug_log (['not keeping orphan with rejected parents {}' .format (child ["txid" ])]):
406
- self .relay_transaction (peer1 , child ["tx" ])
413
+ self .relay_transaction (peer1 , child ["tx" ])
407
414
assert_equal (0 , len (node .getrawmempool ()))
415
+ assert not tx_in_orphanage (node , child ["tx" ])
408
416
peer1 .assert_never_requested (parent_low_fee_nonsegwit ["txid" ])
409
417
410
418
# Grandchild should also not be kept in orphanage because its parent has been rejected.
411
- with node .assert_debug_log (['not keeping orphan with rejected parents {}' .format (grandchild ["txid" ])]):
412
- self .relay_transaction (peer2 , grandchild ["tx" ])
419
+ self .relay_transaction (peer2 , grandchild ["tx" ])
413
420
assert_equal (0 , len (node .getrawmempool ()))
421
+ assert not tx_in_orphanage (node , grandchild ["tx" ])
414
422
peer2 .assert_never_requested (child ["txid" ])
415
423
peer2 .assert_never_requested (child ["tx" ].getwtxid ())
416
424
@@ -438,6 +446,7 @@ def test_same_txid_orphan(self):
438
446
439
447
# 1. Fake orphan is received first. It is missing an input.
440
448
bad_peer .send_and_ping (msg_tx (tx_orphan_bad_wit ))
449
+ assert tx_in_orphanage (node , tx_orphan_bad_wit )
441
450
442
451
# 2. Node requests the missing parent by txid.
443
452
parent_txid_int = int (tx_parent ["txid" ], 16 )
@@ -446,8 +455,9 @@ def test_same_txid_orphan(self):
446
455
447
456
# 3. Honest peer relays the real child, which is also missing parents and should be placed
448
457
# in the orphanage.
449
- with node .assert_debug_log (["missingorspent" , "stored orphan tx" ]):
458
+ with node .assert_debug_log (["missingorspent" ]):
450
459
honest_peer .send_and_ping (msg_tx (tx_child ["tx" ]))
460
+ assert tx_in_orphanage (node , tx_child ["tx" ])
451
461
452
462
# Time out the previous request for the parent (node will not request the same transaction
453
463
# from multiple nodes at the same time)
@@ -487,6 +497,7 @@ def test_same_txid_orphan_of_orphan(self):
487
497
488
498
# 1. Fake orphan is received first. It is missing an input.
489
499
bad_peer .send_and_ping (msg_tx (tx_orphan_bad_wit ))
500
+ assert tx_in_orphanage (node , tx_orphan_bad_wit )
490
501
491
502
# 2. Node requests missing tx_grandparent by txid.
492
503
grandparent_txid_int = int (tx_grandparent ["txid" ], 16 )
@@ -496,16 +507,16 @@ def test_same_txid_orphan_of_orphan(self):
496
507
# 3. Honest peer relays the grandchild, which is missing a parent. The parent by txid already
497
508
# exists in orphanage, but should be re-requested because the node shouldn't assume that the
498
509
# witness data is the same. In this case, a same-txid-different-witness transaction exists!
499
- with node . assert_debug_log ([ "stored orphan tx" ]):
500
- honest_peer . send_and_ping ( msg_tx ( tx_grandchild ["tx" ]) )
510
+ honest_peer . send_and_ping ( msg_tx ( tx_grandchild [ " tx" ]))
511
+ assert tx_in_orphanage ( node , tx_grandchild ["tx" ])
501
512
middle_txid_int = int (tx_middle ["txid" ], 16 )
502
513
node .bumpmocktime (NONPREF_PEER_TX_DELAY + TXID_RELAY_DELAY )
503
514
honest_peer .wait_for_getdata ([middle_txid_int ])
504
515
505
516
# 4. Honest peer relays the real child, which is also missing parents and should be placed
506
517
# in the orphanage.
507
- with node . assert_debug_log ([ "stored orphan tx" ]):
508
- honest_peer . send_and_ping ( msg_tx ( tx_middle ["tx" ]) )
518
+ honest_peer . send_and_ping ( msg_tx ( tx_middle [ " tx" ]))
519
+ assert tx_in_orphanage ( node , tx_middle ["tx" ])
509
520
assert_equal (len (node .getrawmempool ()), 0 )
510
521
511
522
# 5. Honest peer sends tx_grandparent
@@ -518,6 +529,7 @@ def test_same_txid_orphan_of_orphan(self):
518
529
assert tx_middle ["txid" ] in node_mempool
519
530
assert tx_grandchild ["txid" ] in node_mempool
520
531
assert_equal (node .getmempoolentry (tx_middle ["txid" ])["wtxid" ], tx_middle ["wtxid" ])
532
+ assert_equal (len (node .getorphantxs ()), 0 )
521
533
522
534
@cleanup
523
535
def test_orphan_txid_inv (self ):
@@ -536,6 +548,7 @@ def test_orphan_txid_inv(self):
536
548
537
549
# 1. Fake orphan is received first. It is missing an input.
538
550
bad_peer .send_and_ping (msg_tx (tx_orphan_bad_wit ))
551
+ assert tx_in_orphanage (node , tx_orphan_bad_wit )
539
552
540
553
# 2. Node requests the missing parent by txid.
541
554
parent_txid_int = int (tx_parent ["txid" ], 16 )
@@ -550,8 +563,8 @@ def test_orphan_txid_inv(self):
550
563
# 4. The child is requested. Honest peer sends it.
551
564
node .bumpmocktime (TXREQUEST_TIME_SKIP )
552
565
honest_peer .wait_for_getdata ([child_txid_int ])
553
- with node . assert_debug_log ([ "stored orphan tx" ]):
554
- honest_peer . send_and_ping ( msg_tx ( tx_child ["tx" ]) )
566
+ honest_peer . send_and_ping ( msg_tx ( tx_child [ " tx" ]))
567
+ assert tx_in_orphanage ( node , tx_child ["tx" ])
555
568
556
569
# 5. After first parent request times out, the node sends another one for the missing parent
557
570
# of the real orphan child.
@@ -568,6 +581,7 @@ def test_orphan_txid_inv(self):
568
581
assert tx_parent ["txid" ] in node_mempool
569
582
assert tx_child ["txid" ] in node_mempool
570
583
assert_equal (node .getmempoolentry (tx_child ["txid" ])["wtxid" ], tx_child ["wtxid" ])
584
+ assert_equal (len (node .getorphantxs ()), 0 )
571
585
572
586
@cleanup
573
587
def test_max_orphan_amount (self ):
0 commit comments