0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-08 10:31:50 -05:00

test: add bounds checking for submitpackage RPC

This commit is contained in:
stickies-v 2024-01-25 12:04:24 +00:00
parent 7143d43884
commit 17f74512f0
No known key found for this signature in database
GPG key ID: 5CB1CE6E5E66A757

View file

@ -25,6 +25,9 @@ from test_framework.wallet import (
)
MAX_PACKAGE_COUNT = 25
class RPCPackagesTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
@ -340,6 +343,13 @@ class RPCPackagesTest(BitcoinTestFramework):
assert_raises_rpc_error(-25, "package topology disallowed", node.submitpackage, chain_hex)
assert_equal(legacy_pool, node.getrawmempool())
assert_raises_rpc_error(-8, f"Array must contain between 1 and {MAX_PACKAGE_COUNT} transactions.", node.submitpackage, [])
assert_raises_rpc_error(-25, "package topology disallowed", node.submitpackage, [chain_hex[0]] * 1)
assert_raises_rpc_error(
-8, f"Array must contain between 1 and {MAX_PACKAGE_COUNT} transactions.",
node.submitpackage, [chain_hex[0]] * (MAX_PACKAGE_COUNT + 1)
)
# Create a transaction chain such as only the parent gets accepted (by making the child's
# version non-standard). Make sure the parent does get broadcast.
self.log.info("If a package is partially submitted, transactions included in mempool get broadcast")