@@ -94,6 +94,7 @@ def run_test(self):
94
94
self .test_address_reuse ()
95
95
self .test_option_subtract_fee_from_outputs ()
96
96
self .test_subtract_fee_with_presets ()
97
+ self .test_transaction_too_large ()
97
98
98
99
def test_change_position (self ):
99
100
"""Ensure setting changePosition in fundraw with an exact match is handled properly."""
@@ -907,5 +908,24 @@ def test_subtract_fee_with_presets(self):
907
908
signedtx = self .nodes [0 ].signrawtransactionwithwallet (fundedtx ['hex' ])
908
909
self .nodes [0 ].sendrawtransaction (signedtx ['hex' ])
909
910
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
+
910
930
if __name__ == '__main__' :
911
931
RawTransactionsTest ().main ()
0 commit comments