Skip to content

Commit 33af14b

Browse files
committed
test: reduce assert_debug_log reliance
p2p_orphan_handling now uses tx_in_orphanage to more directly check for inclusion/exclusion in the orphanage.
1 parent 25dacae commit 33af14b

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

test/functional/p2p_orphan_handling.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ def test_orphan_rejected_parents_exceptions(self):
210210

211211
# Relay the child. It should not be accepted because it has missing inputs.
212212
# 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"])
215214
assert child_nonsegwit["txid"] not in node.getrawmempool()
215+
assert not tx_in_orphanage(node, child_nonsegwit["tx"])
216216

217217
# No parents are requested.
218218
self.nodes[0].bumpmocktime(GETDATA_TX_INTERVAL)
@@ -402,15 +402,15 @@ def test_orphan_inherit_rejection(self):
402402

403403
# Relay the child. It should be rejected for having missing parents, and this rejection is
404404
# 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"])
405+
self.relay_transaction(peer1, child["tx"])
407406
assert_equal(0, len(node.getrawmempool()))
407+
assert not tx_in_orphanage(node, child["tx"])
408408
peer1.assert_never_requested(parent_low_fee_nonsegwit["txid"])
409409

410410
# 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"])
411+
self.relay_transaction(peer2, grandchild["tx"])
413412
assert_equal(0, len(node.getrawmempool()))
413+
assert not tx_in_orphanage(node, grandchild["tx"])
414414
peer2.assert_never_requested(child["txid"])
415415
peer2.assert_never_requested(child["tx"].getwtxid())
416416

@@ -446,8 +446,9 @@ def test_same_txid_orphan(self):
446446

447447
# 3. Honest peer relays the real child, which is also missing parents and should be placed
448448
# in the orphanage.
449-
with node.assert_debug_log(["missingorspent", "stored orphan tx"]):
449+
with node.assert_debug_log(["missingorspent"]):
450450
honest_peer.send_and_ping(msg_tx(tx_child["tx"]))
451+
assert tx_in_orphanage(node, tx_child["tx"])
451452

452453
# Time out the previous request for the parent (node will not request the same transaction
453454
# from multiple nodes at the same time)
@@ -496,16 +497,16 @@ def test_same_txid_orphan_of_orphan(self):
496497
# 3. Honest peer relays the grandchild, which is missing a parent. The parent by txid already
497498
# exists in orphanage, but should be re-requested because the node shouldn't assume that the
498499
# 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"]))
500+
honest_peer.send_and_ping(msg_tx(tx_grandchild["tx"]))
501+
assert tx_in_orphanage(node, tx_grandchild["tx"])
501502
middle_txid_int = int(tx_middle["txid"], 16)
502503
node.bumpmocktime(NONPREF_PEER_TX_DELAY + TXID_RELAY_DELAY)
503504
honest_peer.wait_for_getdata([middle_txid_int])
504505

505506
# 4. Honest peer relays the real child, which is also missing parents and should be placed
506507
# in the orphanage.
507-
with node.assert_debug_log(["stored orphan tx"]):
508-
honest_peer.send_and_ping(msg_tx(tx_middle["tx"]))
508+
honest_peer.send_and_ping(msg_tx(tx_middle["tx"]))
509+
assert tx_in_orphanage(node, tx_middle["tx"])
509510
assert_equal(len(node.getrawmempool()), 0)
510511

511512
# 5. Honest peer sends tx_grandparent
@@ -550,8 +551,8 @@ def test_orphan_txid_inv(self):
550551
# 4. The child is requested. Honest peer sends it.
551552
node.bumpmocktime(TXREQUEST_TIME_SKIP)
552553
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"]))
554+
honest_peer.send_and_ping(msg_tx(tx_child["tx"]))
555+
assert tx_in_orphanage(node, tx_child["tx"])
555556

556557
# 5. After first parent request times out, the node sends another one for the missing parent
557558
# of the real orphan child.

0 commit comments

Comments
 (0)