mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-08-04 05:54:48 +02:00
test: add setfeerate functional coverage in wallet_bumpfee.py
Github-Pull: #20391 Rebased-From: c907f158a6bf3cad782d4441e02abcbda210265b
This commit is contained in:
parent
e3bad6d0d2
commit
70a334ddaf
@ -19,6 +19,7 @@ from test_framework.blocktools import (
|
|||||||
COINBASE_MATURITY,
|
COINBASE_MATURITY,
|
||||||
)
|
)
|
||||||
from test_framework.messages import (
|
from test_framework.messages import (
|
||||||
|
COIN,
|
||||||
MAX_BIP125_RBF_SEQUENCE,
|
MAX_BIP125_RBF_SEQUENCE,
|
||||||
)
|
)
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
@ -61,6 +62,7 @@ class BumpFeeTest(BitcoinTestFramework):
|
|||||||
"-addresstype=bech32",
|
"-addresstype=bech32",
|
||||||
"-whitelist=noban@127.0.0.1",
|
"-whitelist=noban@127.0.0.1",
|
||||||
] for i in range(self.num_nodes)]
|
] for i in range(self.num_nodes)]
|
||||||
|
self.wallet_names = [self.default_wallet_name, "RBF wallet"]
|
||||||
|
|
||||||
def skip_test_if_missing_module(self):
|
def skip_test_if_missing_module(self):
|
||||||
self.skip_if_no_wallet()
|
self.skip_if_no_wallet()
|
||||||
@ -105,6 +107,7 @@ class BumpFeeTest(BitcoinTestFramework):
|
|||||||
test_bumpfee_metadata(self, rbf_node, dest_address)
|
test_bumpfee_metadata(self, rbf_node, dest_address)
|
||||||
test_locked_wallet_fails(self, rbf_node, dest_address)
|
test_locked_wallet_fails(self, rbf_node, dest_address)
|
||||||
test_change_script_match(self, rbf_node, dest_address)
|
test_change_script_match(self, rbf_node, dest_address)
|
||||||
|
test_setfeerate(self, rbf_node, dest_address)
|
||||||
test_settxfee(self, rbf_node, dest_address)
|
test_settxfee(self, rbf_node, dest_address)
|
||||||
test_maxtxfee_fails(self, rbf_node, dest_address)
|
test_maxtxfee_fails(self, rbf_node, dest_address)
|
||||||
# These tests wipe out a number of utxos that are expected in other tests
|
# These tests wipe out a number of utxos that are expected in other tests
|
||||||
@ -530,6 +533,42 @@ def test_dust_to_fee(self, rbf_node, dest_address):
|
|||||||
self.clear_mempool()
|
self.clear_mempool()
|
||||||
|
|
||||||
|
|
||||||
|
def test_setfeerate(self, rbf_node, dest_address):
|
||||||
|
self.log.info("Test setfeerate")
|
||||||
|
|
||||||
|
def test_response(*, wallet="RBF wallet", requested=0, expected=0, error=None, msg):
|
||||||
|
assert_equal(rbf_node.setfeerate(requested), {"wallet_name": wallet, "fee_rate": expected, ("error" if error else "result"): msg})
|
||||||
|
|
||||||
|
# Test setfeerate with too high/low values returns expected errors
|
||||||
|
new = Decimal("10000.001")
|
||||||
|
test_response(requested=new, error=True, msg=f"The requested fee rate of {new} sat/vB cannot be greater than the wallet max fee rate of 10000.000 sat/vB. The current setting of 0 (unset) for this wallet remains unchanged.")
|
||||||
|
new = Decimal("0.999")
|
||||||
|
test_response(requested=new, error=True, msg=f"The requested fee rate of {new} sat/vB cannot be less than the minimum relay fee rate of 1.000 sat/vB. The current setting of 0 (unset) for this wallet remains unchanged.")
|
||||||
|
fee_rate = Decimal("2.001")
|
||||||
|
test_response(requested=fee_rate, expected=fee_rate, msg=f"Fee rate for transactions with this wallet successfully set to {fee_rate} sat/vB")
|
||||||
|
new = Decimal("1.999")
|
||||||
|
test_response(requested=new, expected=fee_rate, error=True, msg=f"The requested fee rate of {new} sat/vB cannot be less than the wallet min fee rate of 2.000 sat/vB. The current setting of {fee_rate} sat/vB for this wallet remains unchanged.")
|
||||||
|
|
||||||
|
# Test setfeerate with valid values returns expected results
|
||||||
|
rbfid = spend_one_input(rbf_node, dest_address)
|
||||||
|
fee_rate = 25
|
||||||
|
test_response(requested=fee_rate, expected=fee_rate, msg="Fee rate for transactions with this wallet successfully set to 25.000 sat/vB")
|
||||||
|
bumped_tx = rbf_node.bumpfee(rbfid)
|
||||||
|
actual_feerate = bumped_tx["fee"] * COIN / rbf_node.getrawtransaction(bumped_tx["txid"], True)["vsize"]
|
||||||
|
assert_greater_than(Decimal("0.01"), abs(fee_rate - actual_feerate))
|
||||||
|
test_response(msg="Fee rate for transactions with this wallet successfully unset. By default, automatic fee selection will be used.")
|
||||||
|
|
||||||
|
# Test setfeerate with a different -maxtxfee
|
||||||
|
self.restart_node(1, ["-maxtxfee=0.000025"] + self.extra_args[1])
|
||||||
|
new = "2.501"
|
||||||
|
test_response(requested=new, error=True, msg=f"The requested fee rate of {new} sat/vB cannot be greater than the wallet max fee rate of 2.500 sat/vB. The current setting of 0 (unset) for this wallet remains unchanged.")
|
||||||
|
|
||||||
|
self.restart_node(1, self.extra_args[1])
|
||||||
|
rbf_node.walletpassphrase(WALLET_PASSPHRASE, WALLET_PASSPHRASE_TIMEOUT)
|
||||||
|
self.connect_nodes(1, 0)
|
||||||
|
self.clear_mempool()
|
||||||
|
|
||||||
|
|
||||||
def test_settxfee(self, rbf_node, dest_address):
|
def test_settxfee(self, rbf_node, dest_address):
|
||||||
self.log.info('Test settxfee')
|
self.log.info('Test settxfee')
|
||||||
assert_raises_rpc_error(-8, "txfee cannot be less than min relay tx fee", rbf_node.settxfee, Decimal('0.000005'))
|
assert_raises_rpc_error(-8, "txfee cannot be less than min relay tx fee", rbf_node.settxfee, Decimal('0.000005'))
|
||||||
|
Loading…
Reference in New Issue
Block a user