rpc: Allow single transaction through submitpackage

And under the hood suppoert single transactions
in AcceptPackage. This simplifies user experience
and paves the way for reducing number of codepaths
for transaction acceptance in the future.

Co-Authored-By: instagibbs <gsanders87@gmail.com>
This commit is contained in:
glozow
2024-11-22 07:06:23 -05:00
committed by Greg Sanders
parent 6463117a29
commit 32fc59796f
5 changed files with 155 additions and 54 deletions

View File

@ -377,8 +377,8 @@ class RPCPackagesTest(BitcoinTestFramework):
assert txid_list[0] not in node.getrawmempool()
assert txid_list[1] not in node.getrawmempool()
self.log.info("Submitpackage valid packages with 1 child and some number of parents")
for num_parents in [1, 2, 24]:
self.log.info("Submitpackage valid packages with 1 child and some number of parents (or none)")
for num_parents in [0, 1, 2, 24]:
self.test_submit_child_with_parents(num_parents, False)
self.test_submit_child_with_parents(num_parents, True)
@ -389,10 +389,9 @@ 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 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.", node.submitpackage, [])
assert_raises_rpc_error(
-8, f"Array must contain between 2 and {MAX_PACKAGE_COUNT} transactions.",
-8, f"Array must contain between 1 and {MAX_PACKAGE_COUNT} transactions.",
node.submitpackage, [chain_hex[0]] * (MAX_PACKAGE_COUNT + 1)
)