27
27
)
28
28
from test_framework .wallet_util import bytes_to_wif
29
29
30
+ ERR_NOT_ENOUGH_PRESET_INPUTS = "The preselected coins total amount does not cover the transaction target. " \
31
+ "Please allow other inputs to be automatically selected or include more coins manually"
30
32
31
33
def get_unspent (listunspent , amount ):
32
34
for utx in listunspent :
@@ -328,7 +330,7 @@ def test_coin_selection(self):
328
330
assert_equal ("00" , dec_tx ['vin' ][0 ]['scriptSig' ]['hex' ])
329
331
330
332
# Should fail without add_inputs:
331
- assert_raises_rpc_error (- 4 , "Insufficient funds" , self .nodes [2 ].fundrawtransaction , rawtx , {"add_inputs" : False })
333
+ assert_raises_rpc_error (- 4 , ERR_NOT_ENOUGH_PRESET_INPUTS , self .nodes [2 ].fundrawtransaction , rawtx , {"add_inputs" : False })
332
334
# add_inputs is enabled by default
333
335
rawtxfund = self .nodes [2 ].fundrawtransaction (rawtx )
334
336
@@ -360,7 +362,7 @@ def test_two_vin(self):
360
362
assert_equal (utx ['txid' ], dec_tx ['vin' ][0 ]['txid' ])
361
363
362
364
# Should fail without add_inputs:
363
- assert_raises_rpc_error (- 4 , "Insufficient funds" , self .nodes [2 ].fundrawtransaction , rawtx , {"add_inputs" : False })
365
+ assert_raises_rpc_error (- 4 , ERR_NOT_ENOUGH_PRESET_INPUTS , self .nodes [2 ].fundrawtransaction , rawtx , {"add_inputs" : False })
364
366
rawtxfund = self .nodes [2 ].fundrawtransaction (rawtx , {"add_inputs" : True })
365
367
366
368
dec_tx = self .nodes [2 ].decoderawtransaction (rawtxfund ['hex' ])
@@ -394,7 +396,7 @@ def test_two_vin_two_vout(self):
394
396
assert_equal (utx ['txid' ], dec_tx ['vin' ][0 ]['txid' ])
395
397
396
398
# Should fail without add_inputs:
397
- assert_raises_rpc_error (- 4 , "Insufficient funds" , self .nodes [2 ].fundrawtransaction , rawtx , {"add_inputs" : False })
399
+ assert_raises_rpc_error (- 4 , ERR_NOT_ENOUGH_PRESET_INPUTS , self .nodes [2 ].fundrawtransaction , rawtx , {"add_inputs" : False })
398
400
rawtxfund = self .nodes [2 ].fundrawtransaction (rawtx , {"add_inputs" : True })
399
401
400
402
dec_tx = self .nodes [2 ].decoderawtransaction (rawtxfund ['hex' ])
@@ -987,7 +989,9 @@ def test_transaction_too_large(self):
987
989
outputs [recipient .getnewaddress ()] = 0.1
988
990
wallet .sendmany ("" , outputs )
989
991
self .generate (self .nodes [0 ], 10 )
990
- assert_raises_rpc_error (- 4 , "Insufficient funds" , recipient .fundrawtransaction , rawtx )
992
+ assert_raises_rpc_error (- 4 , "The inputs size exceeds the maximum weight. "
993
+ "Please try sending a smaller amount or manually consolidating your wallet's UTXOs" ,
994
+ recipient .fundrawtransaction , rawtx )
991
995
self .nodes [0 ].unloadwallet ("large" )
992
996
993
997
def test_external_inputs (self ):
@@ -1128,7 +1132,7 @@ def test_add_inputs_default_value(self):
1128
1132
}
1129
1133
]
1130
1134
}
1131
- assert_raises_rpc_error (- 4 , "Insufficient funds" , wallet .send , outputs = [{addr1 : 8 }], options = options )
1135
+ assert_raises_rpc_error (- 4 , ERR_NOT_ENOUGH_PRESET_INPUTS , wallet .send , outputs = [{addr1 : 8 }], options = options )
1132
1136
1133
1137
# Case (3), Explicit add_inputs=true and preset inputs (with preset inputs not-covering the target amount)
1134
1138
options ["add_inputs" ] = True
@@ -1156,7 +1160,7 @@ def test_add_inputs_default_value(self):
1156
1160
1157
1161
# 6. Explicit add_inputs=false, no preset inputs:
1158
1162
options = {"add_inputs" : False }
1159
- assert_raises_rpc_error (- 4 , "Insufficient funds" , wallet .send , outputs = [{addr1 : 3 }], options = options )
1163
+ assert_raises_rpc_error (- 4 , ERR_NOT_ENOUGH_PRESET_INPUTS , wallet .send , outputs = [{addr1 : 3 }], options = options )
1160
1164
1161
1165
################################################
1162
1166
@@ -1173,7 +1177,7 @@ def test_add_inputs_default_value(self):
1173
1177
"vout" : 1 # change position was hardcoded to index 0
1174
1178
}]
1175
1179
outputs = {self .nodes [1 ].getnewaddress (): 8 }
1176
- assert_raises_rpc_error (- 4 , "Insufficient funds" , wallet .walletcreatefundedpsbt , inputs = inputs , outputs = outputs )
1180
+ assert_raises_rpc_error (- 4 , ERR_NOT_ENOUGH_PRESET_INPUTS , wallet .walletcreatefundedpsbt , inputs = inputs , outputs = outputs )
1177
1181
1178
1182
# Case (3), Explicit add_inputs=true and preset inputs (with preset inputs not-covering the target amount)
1179
1183
options ["add_inputs" ] = True
@@ -1200,7 +1204,7 @@ def test_add_inputs_default_value(self):
1200
1204
1201
1205
# Case (6). Explicit add_inputs=false, no preset inputs:
1202
1206
options = {"add_inputs" : False }
1203
- assert_raises_rpc_error (- 4 , "Insufficient funds" , wallet .walletcreatefundedpsbt , inputs = [], outputs = outputs , options = options )
1207
+ assert_raises_rpc_error (- 4 , ERR_NOT_ENOUGH_PRESET_INPUTS , wallet .walletcreatefundedpsbt , inputs = [], outputs = outputs , options = options )
1204
1208
1205
1209
self .nodes [2 ].unloadwallet ("test_preset_inputs" )
1206
1210
0 commit comments