Skip to content

Commit

Permalink
test: add entry and expiration time checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tdb3 committed Oct 7, 2024
1 parent 6462732 commit 5d97188
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 14 additions & 2 deletions test/functional/rpc_orphans.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Tests for orphan related RPCs."""

from test_framework.mempool_util import tx_in_orphanage
import time

from test_framework.mempool_util import (
ORPHAN_MAX_RETENTION_TIME,
tx_in_orphanage,
)
from test_framework.messages import msg_tx
from test_framework.p2p import P2PInterface
from test_framework.util import assert_equal
from test_framework.util import (
assert_approx,
assert_equal,
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.wallet import MiniWallet

Expand Down Expand Up @@ -88,6 +96,7 @@ def test_orphan_details(self):
tx_child_2 = self.wallet.create_self_transfer(utxo_to_spend=tx_parent_2["new_utxo"])
peer_1 = node.add_p2p_connection(P2PInterface())
peer_2 = node.add_p2p_connection(P2PInterface())
entry_time = int(time.time())
peer_1.send_and_ping(msg_tx(tx_child_1["tx"]))
peer_2.send_and_ping(msg_tx(tx_child_2["tx"]))

Expand All @@ -107,6 +116,9 @@ def test_orphan_details(self):
assert_equal(len(node.getorphantxs()), 1)
orphan_1 = orphanage[0]
self.orphan_details_match(orphan_1, tx_child_1, verbosity=1)
self.log.info("Checking orphan entry/expiration times")
assert_approx(orphan_1["entry"], entry_time, 5)
assert_approx(orphan_1["expiration"], entry_time + ORPHAN_MAX_RETENTION_TIME, 5)

self.log.info("Checking orphan details (verbosity 2)")
orphanage = node.getorphantxs(verbosity=2)
Expand Down
2 changes: 2 additions & 0 deletions test/functional/test_framework/mempool_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
MiniWallet,
)

ORPHAN_MAX_RETENTION_TIME = 1200


def fill_mempool(test_framework, node, *, tx_sync_fun=None):
"""Fill mempool until eviction.
Expand Down

0 comments on commit 5d97188

Please sign in to comment.