Skip to content

Commit

Permalink
test: refactor: introduce and use TRUC_CHILD_MAX_VSIZE constant
Browse files Browse the repository at this point in the history
  • Loading branch information
theStack committed Aug 26, 2024
1 parent b61541d commit ced04bc
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/functional/mempool_truc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

MAX_REPLACEMENT_CANDIDATES = 100
TRUC_MAX_VSIZE = 10000
TRUC_CHILD_MAX_VSIZE = 1000

def cleanup(extra_args=None):
def decorator(func):
Expand Down Expand Up @@ -72,10 +73,10 @@ def test_truc_acceptance(self):
self.check_mempool([tx_v3_parent_normal["txid"]])
tx_v3_child_heavy = self.wallet.create_self_transfer(
utxo_to_spend=tx_v3_parent_normal["new_utxo"],
target_vsize=1001,
target_vsize=TRUC_CHILD_MAX_VSIZE + 1,
version=3
)
assert_greater_than_or_equal(tx_v3_child_heavy["tx"].get_vsize(), 1000)
assert_greater_than_or_equal(tx_v3_child_heavy["tx"].get_vsize(), TRUC_CHILD_MAX_VSIZE)
expected_error_child_heavy = f"TRUC-violation, version=3 child tx {tx_v3_child_heavy['txid']} (wtxid={tx_v3_child_heavy['wtxid']}) is too big"
assert_raises_rpc_error(-26, expected_error_child_heavy, node.sendrawtransaction, tx_v3_child_heavy["hex"])
self.check_mempool([tx_v3_parent_normal["txid"]])
Expand All @@ -87,10 +88,10 @@ def test_truc_acceptance(self):
from_node=node,
fee_rate=DEFAULT_FEE,
utxo_to_spend=tx_v3_parent_normal["new_utxo"],
target_vsize=997,
target_vsize=TRUC_CHILD_MAX_VSIZE - 3,
version=3
)
assert_greater_than_or_equal(1000, tx_v3_child_almost_heavy["tx"].get_vsize())
assert_greater_than_or_equal(TRUC_CHILD_MAX_VSIZE, tx_v3_child_almost_heavy["tx"].get_vsize())
self.check_mempool([tx_v3_parent_normal["txid"], tx_v3_child_almost_heavy["txid"]])
assert_equal(node.getmempoolentry(tx_v3_parent_normal["txid"])["descendantcount"], 2)
tx_v3_child_almost_heavy_rbf = self.wallet.send_self_transfer(
Expand Down Expand Up @@ -231,7 +232,7 @@ def test_nondefault_package_limits(self):

# Parent and child are within v3 limits, but parent's 10kvB descendant limit is exceeded
assert_greater_than_or_equal(TRUC_MAX_VSIZE, tx_v3_parent_large1["tx"].get_vsize())
assert_greater_than_or_equal(1000, tx_v3_child_large1["tx"].get_vsize())
assert_greater_than_or_equal(TRUC_CHILD_MAX_VSIZE, tx_v3_child_large1["tx"].get_vsize())
assert_greater_than(tx_v3_parent_large1["tx"].get_vsize() + tx_v3_child_large1["tx"].get_vsize(), 10000)

assert_raises_rpc_error(-26, f"too-long-mempool-chain, exceeds descendant size limit for tx {tx_v3_parent_large1['txid']}", node.sendrawtransaction, tx_v3_child_large1["hex"])
Expand All @@ -254,7 +255,7 @@ def test_nondefault_package_limits(self):

# Parent and child are within TRUC limits
assert_greater_than_or_equal(TRUC_MAX_VSIZE, tx_v3_parent_large2["tx"].get_vsize())
assert_greater_than_or_equal(1000, tx_v3_child_large2["tx"].get_vsize())
assert_greater_than_or_equal(TRUC_CHILD_MAX_VSIZE, tx_v3_child_large2["tx"].get_vsize())
assert_greater_than(tx_v3_parent_large2["tx"].get_vsize() + tx_v3_child_large2["tx"].get_vsize(), 10000)

assert_raises_rpc_error(-26, f"too-long-mempool-chain, exceeds ancestor size limit", node.sendrawtransaction, tx_v3_child_large2["hex"])
Expand All @@ -281,7 +282,7 @@ def test_truc_ancestors_package(self):
)
tx_v3_child_heavy = self.wallet.create_self_transfer_multi(
utxos_to_spend=[tx_v3_parent_normal["new_utxo"]],
target_vsize=1001,
target_vsize=TRUC_CHILD_MAX_VSIZE + 1,
fee_per_output=10000,
version=3
)
Expand Down

0 comments on commit ced04bc

Please sign in to comment.