Skip to content

Commit 5c998a6

Browse files
committed
[refactor] use MAX_PUBKEYS_PER_MULTISIG instead of magic numbers in test
1 parent a934642 commit 5c998a6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/functional/mempool_sigoplimit.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from test_framework.wallet_util import generate_keypair
4040

4141
DEFAULT_BYTES_PER_SIGOP = 20 # default setting
42-
42+
MAX_PUBKEYS_PER_MULTISIG = 20
4343

4444
class BytesPerSigOpTest(BitcoinTestFramework):
4545
def set_test_params(self):
@@ -159,13 +159,13 @@ def create_bare_multisig_tx(utxo_to_spend=None):
159159
# Separately, the parent tx is ok
160160
parent_individual_testres = self.nodes[0].testmempoolaccept([tx_parent.serialize().hex()])[0]
161161
assert parent_individual_testres["allowed"]
162-
# Multisig is counted as MAX_PUBKEYS_PER_MULTISIG = 20 sigops
163-
assert_equal(parent_individual_testres["vsize"], 5000 * 20)
162+
max_multisig_vsize = MAX_PUBKEYS_PER_MULTISIG * 5000
163+
assert_equal(parent_individual_testres["vsize"], max_multisig_vsize)
164164

165165
# But together, it's exceeding limits in the *package* context. If sigops adjusted vsize wasn't being checked
166166
# here, it would get further in validation and give too-long-mempool-chain error instead.
167167
packet_test = self.nodes[0].testmempoolaccept([tx_parent.serialize().hex(), tx_child.serialize().hex()])
168-
expected_package_error = f"package-mempool-limits, package size {2*20*5000} exceeds ancestor size limit [limit: 101000]"
168+
expected_package_error = f"package-mempool-limits, package size {2*max_multisig_vsize} exceeds ancestor size limit [limit: 101000]"
169169
assert_equal([x["package-error"] for x in packet_test], [expected_package_error] * 2)
170170

171171
# When we actually try to submit, the parent makes it into the mempool, but the child would exceed ancestor vsize limits

0 commit comments

Comments
 (0)