5
5
"""Test the send RPC command."""
6
6
7
7
from decimal import Decimal , getcontext
8
+ from itertools import product
9
+
8
10
from test_framework .authproxy import JSONRPCException
9
11
from test_framework .test_framework import BitcoinTestFramework
10
12
from test_framework .util import (
11
13
assert_equal ,
12
14
assert_fee_amount ,
13
15
assert_greater_than ,
14
- assert_raises_rpc_error
16
+ assert_raises_rpc_error ,
15
17
)
16
18
17
19
class WalletSendTest (BitcoinTestFramework ):
@@ -271,8 +273,9 @@ def run_test(self):
271
273
fee = self .nodes [1 ].decodepsbt (res ["psbt" ])["fee" ]
272
274
assert_fee_amount (fee , Decimal (len (res ["hex" ]) / 2 ), Decimal ("0.00003" ))
273
275
274
- # TODO: This test should pass with all modes, e.g. with the next line uncommented, for consistency with the other explicit feerate RPCs.
275
- # for mode in ["unset", "economical", "conservative", "btc/kb", "sat/b"]:
276
+ for target , mode in product ([- 1 , 0 , 1009 ], ["economical" , "conservative" ]):
277
+ self .test_send (from_wallet = w0 , to_wallet = w1 , amount = 1 , conf_target = target , estimate_mode = mode ,
278
+ expect_error = (- 8 , "Invalid conf_target, must be between 1 and 1008" ))
276
279
for mode in ["btc/kb" , "sat/b" ]:
277
280
self .test_send (from_wallet = w0 , to_wallet = w1 , amount = 1 , conf_target = - 1 , estimate_mode = mode ,
278
281
expect_error = (- 3 , "Amount out of range" ))
@@ -282,17 +285,15 @@ def run_test(self):
282
285
for mode in ["foo" , Decimal ("3.141592" )]:
283
286
self .test_send (from_wallet = w0 , to_wallet = w1 , amount = 1 , conf_target = 0.1 , estimate_mode = mode ,
284
287
expect_error = (- 8 , "Invalid estimate_mode parameter" ))
285
- # TODO: these 2 equivalent sends with an invalid estimate_mode arg should both fail, but they do not...why?
286
- # self.test_send(from_wallet=w0, to_wallet=w1, amount=1, arg_conf_target=0.1, arg_estimate_mode=mode,
287
- # expect_error=(-8, "Invalid estimate_mode parameter"))
288
- # assert_raises_rpc_error(-8, "Invalid estimate_mode parameter", lambda: w0.send({w1.getnewaddress(): 1}, 0.1, mode))
289
-
290
- # TODO: These tests should pass for consistency with the other explicit feerate RPCs, but they do not.
291
- # for mode in ["unset", "economical", "conservative", "btc/kb", "sat/b"]:
292
- # self.log.debug("{}".format(mode))
293
- # for k, v in {"string": "", "object": {"foo": "bar"}}.items():
294
- # self.test_send(from_wallet=w0, to_wallet=w1, amount=1, conf_target=v, estimate_mode=mode,
295
- # expect_error=(-3, "Expected type number for conf_target, got {}".format(k)))
288
+ self .test_send (from_wallet = w0 , to_wallet = w1 , amount = 1 , arg_conf_target = 0.1 , arg_estimate_mode = mode ,
289
+ expect_error = (- 8 , "Invalid estimate_mode parameter" ))
290
+ assert_raises_rpc_error (- 8 , "Invalid estimate_mode parameter" , lambda : w0 .send ({w1 .getnewaddress (): 1 }, 0.1 , mode ))
291
+
292
+ for mode in ["economical" , "conservative" , "btc/kb" , "sat/b" ]:
293
+ self .log .debug ("{}" .format (mode ))
294
+ for k , v in {"string" : "true" , "object" : {"foo" : "bar" }}.items ():
295
+ self .test_send (from_wallet = w0 , to_wallet = w1 , amount = 1 , conf_target = v , estimate_mode = mode ,
296
+ expect_error = (- 3 , "Expected type number for conf_target, got {}" .format (k )))
296
297
297
298
# TODO: error should use sat/B instead of BTC/kB if sat/B is selected.
298
299
# Test setting explicit fee rate just below the minimum.
0 commit comments