mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-09 19:37:27 -03:00
test: refactor: introduce and use TRUC_CHILD_MAX_VSIZE
constant
This commit is contained in:
parent
c16ae71768
commit
940edd6ac2
1 changed files with 11 additions and 9 deletions
|
@ -22,6 +22,7 @@ from test_framework.wallet import (
|
|||
|
||||
MAX_REPLACEMENT_CANDIDATES = 100
|
||||
TRUC_MAX_VSIZE = 10000
|
||||
TRUC_CHILD_MAX_VSIZE = 1000
|
||||
|
||||
def cleanup(extra_args=None):
|
||||
def decorator(func):
|
||||
|
@ -72,10 +73,10 @@ class MempoolTRUC(BitcoinTestFramework):
|
|||
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"]])
|
||||
|
@ -87,10 +88,10 @@ class MempoolTRUC(BitcoinTestFramework):
|
|||
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(
|
||||
|
@ -100,7 +101,8 @@ class MempoolTRUC(BitcoinTestFramework):
|
|||
target_vsize=875,
|
||||
version=3
|
||||
)
|
||||
assert_greater_than_or_equal(tx_v3_child_almost_heavy["tx"].get_vsize() + tx_v3_child_almost_heavy_rbf["tx"].get_vsize(), 1000)
|
||||
assert_greater_than_or_equal(tx_v3_child_almost_heavy["tx"].get_vsize() + tx_v3_child_almost_heavy_rbf["tx"].get_vsize(),
|
||||
TRUC_CHILD_MAX_VSIZE)
|
||||
self.check_mempool([tx_v3_parent_normal["txid"], tx_v3_child_almost_heavy_rbf["txid"]])
|
||||
assert_equal(node.getmempoolentry(tx_v3_parent_normal["txid"])["descendantcount"], 2)
|
||||
|
||||
|
@ -199,7 +201,7 @@ class MempoolTRUC(BitcoinTestFramework):
|
|||
tx_v2_from_v3 = self.wallet.send_self_transfer(from_node=node, utxo_to_spend=tx_v3_block["new_utxo"], version=2)
|
||||
tx_v3_from_v2 = self.wallet.send_self_transfer(from_node=node, utxo_to_spend=tx_v2_block["new_utxo"], version=3)
|
||||
tx_v3_child_large = self.wallet.send_self_transfer(from_node=node, utxo_to_spend=tx_v3_block2["new_utxo"], target_vsize=1250, version=3)
|
||||
assert_greater_than(node.getmempoolentry(tx_v3_child_large["txid"])["vsize"], 1000)
|
||||
assert_greater_than(node.getmempoolentry(tx_v3_child_large["txid"])["vsize"], TRUC_CHILD_MAX_VSIZE)
|
||||
self.check_mempool([tx_v2_from_v3["txid"], tx_v3_from_v2["txid"], tx_v3_child_large["txid"]])
|
||||
node.invalidateblock(block[0])
|
||||
self.check_mempool([tx_v3_block["txid"], tx_v2_block["txid"], tx_v3_block2["txid"], tx_v2_from_v3["txid"], tx_v3_from_v2["txid"], tx_v3_child_large["txid"]])
|
||||
|
@ -231,7 +233,7 @@ class MempoolTRUC(BitcoinTestFramework):
|
|||
|
||||
# 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"])
|
||||
|
@ -254,7 +256,7 @@ class MempoolTRUC(BitcoinTestFramework):
|
|||
|
||||
# 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"])
|
||||
|
@ -281,7 +283,7 @@ class MempoolTRUC(BitcoinTestFramework):
|
|||
)
|
||||
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
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue