Skip to content

Commit 17f7451

Browse files
committed
test: add bounds checking for submitpackage RPC
1 parent 7143d43 commit 17f7451

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/functional/rpc_packages.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
)
2626

2727

28+
MAX_PACKAGE_COUNT = 25
29+
30+
2831
class RPCPackagesTest(BitcoinTestFramework):
2932
def set_test_params(self):
3033
self.num_nodes = 1
@@ -340,6 +343,13 @@ def test_submitpackage(self):
340343
assert_raises_rpc_error(-25, "package topology disallowed", node.submitpackage, chain_hex)
341344
assert_equal(legacy_pool, node.getrawmempool())
342345

346+
assert_raises_rpc_error(-8, f"Array must contain between 1 and {MAX_PACKAGE_COUNT} transactions.", node.submitpackage, [])
347+
assert_raises_rpc_error(-25, "package topology disallowed", node.submitpackage, [chain_hex[0]] * 1)
348+
assert_raises_rpc_error(
349+
-8, f"Array must contain between 1 and {MAX_PACKAGE_COUNT} transactions.",
350+
node.submitpackage, [chain_hex[0]] * (MAX_PACKAGE_COUNT + 1)
351+
)
352+
343353
# Create a transaction chain such as only the parent gets accepted (by making the child's
344354
# version non-standard). Make sure the parent does get broadcast.
345355
self.log.info("If a package is partially submitted, transactions included in mempool get broadcast")

0 commit comments

Comments
 (0)