@@ -150,6 +150,7 @@ def run_test(self):
150150 self .test_feerate_rounding ()
151151 self .test_input_confs_control ()
152152 self .test_duplicate_outputs ()
153+ self .test_cannot_cover_fees ()
153154
154155 def test_duplicate_outputs (self ):
155156 self .log .info ("Test deserializing and funding a transaction with duplicate outputs" )
@@ -1426,7 +1427,8 @@ def test_feerate_rounding(self):
14261427 # To test this does not happen, we subtract 202 sats from the input value. If working correctly, this should
14271428 # fail with insufficient funds rather than bitcoind asserting.
14281429 rawtx = w .createrawtransaction (inputs = [], outputs = [{self .nodes [0 ].getnewaddress (address_type = "bech32" ): 1 - 0.00000202 }])
1429- assert_raises_rpc_error (- 4 , "Insufficient funds" , w .fundrawtransaction , rawtx , fee_rate = 1.85 )
1430+ expected_err_msg = "The total transaction amount exceeds your balance when fees are included"
1431+ assert_raises_rpc_error (- 4 , expected_err_msg , w .fundrawtransaction , rawtx , fee_rate = 1.85 )
14301432
14311433 def test_input_confs_control (self ):
14321434 self .nodes [0 ].createwallet ("minconf" )
@@ -1489,5 +1491,20 @@ def test_input_confs_control(self):
14891491
14901492 wallet .unloadwallet ()
14911493
1494+ def test_cannot_cover_fees (self ):
1495+ self .log .info ("Test tx amount exceeds available balance when fees are included" )
1496+
1497+ self .nodes [1 ].createwallet ("cannot_cover_fees" )
1498+ wallet = self .nodes [1 ].get_wallet_rpc ("cannot_cover_fees" )
1499+
1500+ self .nodes [0 ].sendtoaddress (wallet .getnewaddress (), 0.3 )
1501+ self .generate (self .nodes [0 ], 1 )
1502+
1503+ rawtx = wallet .createrawtransaction (inputs = [], outputs = [{self .nodes [0 ].getnewaddress (): 0.3 }])
1504+ expected_err_msg = "The total transaction amount exceeds your balance when fees are included"
1505+ assert_raises_rpc_error (- 4 , expected_err_msg , wallet .fundrawtransaction , rawtx )
1506+ wallet .unloadwallet ()
1507+
1508+
14921509if __name__ == '__main__' :
14931510 RawTransactionsTest ().main ()
0 commit comments