mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 02:33:24 -03:00
test: type error and out of range fee rates where missing
This commit is contained in:
parent
c5fd4344f7
commit
b503327597
3 changed files with 20 additions and 4 deletions
|
@ -15,6 +15,7 @@ from test_framework.util import (
|
|||
)
|
||||
from test_framework.wallet_util import test_address
|
||||
|
||||
NOT_A_NUMBER_OR_STRING = "Amount is not a number or string"
|
||||
OUT_OF_RANGE = "Amount out of range"
|
||||
|
||||
|
||||
|
@ -277,6 +278,9 @@ class WalletTest(BitcoinTestFramework):
|
|||
assert_raises_rpc_error(-3, msg, self.nodes[2].sendmany, amounts={address: 1.0}, fee_rate=invalid_value)
|
||||
# Test fee_rate out of range (negative number).
|
||||
assert_raises_rpc_error(-3, OUT_OF_RANGE, self.nodes[2].sendmany, amounts={address: 10}, fee_rate=-1)
|
||||
# Test type error.
|
||||
for invalid_value in [True, {"foo": "bar"}]:
|
||||
assert_raises_rpc_error(-3, NOT_A_NUMBER_OR_STRING, self.nodes[2].sendmany, amounts={address: 10}, fee_rate=invalid_value)
|
||||
|
||||
self.log.info("Test sendmany raises if an invalid conf_target or estimate_mode is passed")
|
||||
for target, mode in product([-1, 0, 1009], ["economical", "conservative"]):
|
||||
|
@ -467,6 +471,9 @@ class WalletTest(BitcoinTestFramework):
|
|||
assert_raises_rpc_error(-3, msg, self.nodes[2].sendtoaddress, address=address, amount=1.0, fee_rate=invalid_value)
|
||||
# Test fee_rate out of range (negative number).
|
||||
assert_raises_rpc_error(-3, OUT_OF_RANGE, self.nodes[2].sendtoaddress, address=address, amount=1.0, fee_rate=-1)
|
||||
# Test type error.
|
||||
for invalid_value in [True, {"foo": "bar"}]:
|
||||
assert_raises_rpc_error(-3, NOT_A_NUMBER_OR_STRING, self.nodes[2].sendtoaddress, address=address, amount=1.0, fee_rate=invalid_value)
|
||||
|
||||
self.log.info("Test sendtoaddress raises if an invalid conf_target or estimate_mode is passed")
|
||||
for target, mode in product([-1, 0, 1009], ["economical", "conservative"]):
|
||||
|
|
|
@ -122,6 +122,7 @@ class BumpFeeTest(BitcoinTestFramework):
|
|||
assert_raises_rpc_error(-3, msg, rbf_node.bumpfee, rbfid, {"fee_rate": invalid_value})
|
||||
# Test fee_rate out of range (negative number).
|
||||
assert_raises_rpc_error(-3, "Amount out of range", rbf_node.bumpfee, rbfid, {"fee_rate": -1})
|
||||
# Test type error.
|
||||
for value in [{"foo": "bar"}, True]:
|
||||
assert_raises_rpc_error(-3, "Amount is not a number or string", rbf_node.bumpfee, rbfid, {"fee_rate": value})
|
||||
|
||||
|
|
|
@ -343,11 +343,10 @@ class WalletSendTest(BitcoinTestFramework):
|
|||
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, arg_conf_target=0.1, arg_estimate_mode=mode, expect_error=(-8, msg))
|
||||
assert_raises_rpc_error(-8, msg, w0.send, {w1.getnewaddress(): 1}, 0.1, mode)
|
||||
|
||||
for mode in ["economical", "conservative", "btc/kb", "sat/b"]:
|
||||
self.log.debug("{}".format(mode))
|
||||
for k, v in {"string": "true", "object": {"foo": "bar"}}.items():
|
||||
for mode in ["economical", "conservative"]:
|
||||
for k, v in {"string": "true", "bool": True, "object": {"foo": "bar"}}.items():
|
||||
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, conf_target=v, estimate_mode=mode,
|
||||
expect_error=(-3, "Expected type number for conf_target, got {}".format(k)))
|
||||
expect_error=(-3, f"Expected type number for conf_target, got {k}"))
|
||||
|
||||
# Test setting explicit fee rate just below the minimum of 1 sat/vB.
|
||||
self.log.info("Explicit fee rate raises RPC error 'fee rate too low' if fee_rate of 0.99999999 is passed")
|
||||
|
@ -365,6 +364,15 @@ class WalletSendTest(BitcoinTestFramework):
|
|||
for invalid_value in ["", 0.000000001, 1e-09, 1.111111111, 1111111111111111, "31.999999999999999999999"]:
|
||||
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, fee_rate=invalid_value, expect_error=(-3, msg))
|
||||
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, arg_fee_rate=invalid_value, expect_error=(-3, msg))
|
||||
# Test fee_rate out of range (negative number).
|
||||
msg = "Amount out of range"
|
||||
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, fee_rate=-1, expect_error=(-3, msg))
|
||||
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, arg_fee_rate=-1, expect_error=(-3, msg))
|
||||
# Test type error.
|
||||
msg = "Amount is not a number or string"
|
||||
for invalid_value in [True, {"foo": "bar"}]:
|
||||
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, fee_rate=invalid_value, expect_error=(-3, msg))
|
||||
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, arg_fee_rate=invalid_value, expect_error=(-3, msg))
|
||||
|
||||
# TODO: Return hex if fee rate is below -maxmempool
|
||||
# res = self.test_send(from_wallet=w0, to_wallet=w1, amount=1, conf_target=0.1, estimate_mode="sat/b", add_to_wallet=False)
|
||||
|
|
Loading…
Add table
Reference in a new issue