Skip to content

Commit 48a0319

Browse files
committed
Add a test that selects too large if BnB is used
If BnB is used, the test will fail because the transaction is too large.
1 parent 3e69939 commit 48a0319

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/functional/rpc_fundrawtransaction.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def run_test(self):
9494
self.test_address_reuse()
9595
self.test_option_subtract_fee_from_outputs()
9696
self.test_subtract_fee_with_presets()
97+
self.test_transaction_too_large()
9798

9899
def test_change_position(self):
99100
"""Ensure setting changePosition in fundraw with an exact match is handled properly."""
@@ -907,5 +908,24 @@ def test_subtract_fee_with_presets(self):
907908
signedtx = self.nodes[0].signrawtransactionwithwallet(fundedtx['hex'])
908909
self.nodes[0].sendrawtransaction(signedtx['hex'])
909910

911+
def test_transaction_too_large(self):
912+
self.log.info("Test fundrawtx where BnB solution would result in a too large transaction, but Knapsack would not")
913+
914+
self.nodes[0].createwallet("large")
915+
wallet = self.nodes[0].get_wallet_rpc(self.default_wallet_name)
916+
recipient = self.nodes[0].get_wallet_rpc("large")
917+
outputs = {}
918+
rawtx = recipient.createrawtransaction([], {wallet.getnewaddress(): 147.99899260})
919+
920+
# Make 1500 0.1 BTC outputs
921+
# The amount that we target for funding is in the BnB range when these outputs are used.
922+
# However if these outputs are selected, the transaction will end up being too large, so it shouldn't use BnB and instead fallback to Knapsack
923+
# but that behavior is not implemented yet. For now we just check that we get an error.
924+
for i in range(0, 1500):
925+
outputs[recipient.getnewaddress()] = 0.1
926+
wallet.sendmany("", outputs)
927+
self.nodes[0].generate(10)
928+
assert_raises_rpc_error(-4, "Transaction too large", recipient.fundrawtransaction, rawtx)
929+
910930
if __name__ == '__main__':
911931
RawTransactionsTest().main()

0 commit comments

Comments
 (0)