mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-12 11:19:08 -05:00
test: add bounds checking for submitpackage RPC
This commit is contained in:
parent
7143d43884
commit
17f74512f0
1 changed files with 10 additions and 0 deletions
|
@ -25,6 +25,9 @@ from test_framework.wallet import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
MAX_PACKAGE_COUNT = 25
|
||||||
|
|
||||||
|
|
||||||
class RPCPackagesTest(BitcoinTestFramework):
|
class RPCPackagesTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.num_nodes = 1
|
self.num_nodes = 1
|
||||||
|
@ -340,6 +343,13 @@ class RPCPackagesTest(BitcoinTestFramework):
|
||||||
assert_raises_rpc_error(-25, "package topology disallowed", node.submitpackage, chain_hex)
|
assert_raises_rpc_error(-25, "package topology disallowed", node.submitpackage, chain_hex)
|
||||||
assert_equal(legacy_pool, node.getrawmempool())
|
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
|
# 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.
|
# 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")
|
self.log.info("If a package is partially submitted, transactions included in mempool get broadcast")
|
||||||
|
|
Loading…
Add table
Reference in a new issue