From 17f74512f0d19cb452ed79a4bff5a222fcdb53c4 Mon Sep 17 00:00:00 2001 From: stickies-v Date: Thu, 25 Jan 2024 12:04:24 +0000 Subject: test: add bounds checking for submitpackage RPC --- test/functional/rpc_packages.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test') diff --git a/test/functional/rpc_packages.py b/test/functional/rpc_packages.py index 664f2df3f1..76a08171b5 100755 --- a/test/functional/rpc_packages.py +++ b/test/functional/rpc_packages.py @@ -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") -- cgit v1.2.3 From 1a875d4049574730d4a53a1b68bd29b80ad96d38 Mon Sep 17 00:00:00 2001 From: stickies-v Date: Mon, 22 Jan 2024 15:51:31 +0000 Subject: rpc: update min package size error message in submitpackage Currently, the only allowed package topology has a min size of 2. Update the error message to reflect that. --- test/functional/rpc_packages.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/functional/rpc_packages.py b/test/functional/rpc_packages.py index 76a08171b5..ab679eec9a 100755 --- a/test/functional/rpc_packages.py +++ b/test/functional/rpc_packages.py @@ -343,10 +343,10 @@ 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 2 and {MAX_PACKAGE_COUNT} transactions.", node.submitpackage, []) + assert_raises_rpc_error(-8, f"Array must contain between 2 and {MAX_PACKAGE_COUNT} transactions.", node.submitpackage, [chain_hex[0]] * 1) assert_raises_rpc_error( - -8, f"Array must contain between 1 and {MAX_PACKAGE_COUNT} transactions.", + -8, f"Array must contain between 2 and {MAX_PACKAGE_COUNT} transactions.", node.submitpackage, [chain_hex[0]] * (MAX_PACKAGE_COUNT + 1) ) -- cgit v1.2.3