Skip to content

Commit 0d101a3

Browse files
MarcoFalkepromag
authored andcommitted
test: Add test for maxtxfee option
1 parent 1775501 commit 0d101a3

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/functional/wallet_create_tx.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from test_framework.test_framework import BitcoinTestFramework
77
from test_framework.util import (
88
assert_equal,
9+
assert_raises_rpc_error,
910
)
1011
from test_framework.blocktools import (
1112
TIME_GENESIS_BLOCK,
@@ -26,6 +27,10 @@ def run_test(self):
2627
self.nodes[0].generate(200)
2728
self.nodes[0].setmocktime(0)
2829

30+
self.test_anti_fee_sniping()
31+
self.test_tx_size_too_large()
32+
33+
def test_anti_fee_sniping(self):
2934
self.log.info('Check that we have some (old) blocks and that anti-fee-sniping is disabled')
3035
assert_equal(self.nodes[0].getblockchaininfo()['blocks'], 200)
3136
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
@@ -38,6 +43,40 @@ def run_test(self):
3843
tx = self.nodes[0].decoderawtransaction(self.nodes[0].gettransaction(txid)['hex'])
3944
assert 0 < tx['locktime'] <= 201
4045

46+
def test_tx_size_too_large(self):
47+
# More than 10kB of outputs, so that we hit -maxtxfee with a high feerate
48+
outputs = {self.nodes[0].getnewaddress(address_type='bech32'): 0.000025 for i in range(400)}
49+
raw_tx = self.nodes[0].createrawtransaction(inputs=[], outputs=outputs)
50+
51+
for fee_setting in ['-minrelaytxfee=0.01', '-mintxfee=0.01', '-paytxfee=0.01']:
52+
self.log.info('Check maxtxfee in combination with {}'.format(fee_setting))
53+
self.restart_node(0, extra_args=[fee_setting])
54+
assert_raises_rpc_error(
55+
-6,
56+
"Fee exceeds maximum configured by -maxtxfee",
57+
lambda: self.nodes[0].sendmany(dummy="", amounts=outputs),
58+
)
59+
assert_raises_rpc_error(
60+
-4,
61+
"Fee exceeds maximum configured by -maxtxfee",
62+
lambda: self.nodes[0].fundrawtransaction(hexstring=raw_tx),
63+
)
64+
65+
self.log.info('Check maxtxfee in combination with settxfee')
66+
self.restart_node(0)
67+
self.nodes[0].settxfee(0.01)
68+
assert_raises_rpc_error(
69+
-6,
70+
"Fee exceeds maximum configured by -maxtxfee",
71+
lambda: self.nodes[0].sendmany(dummy="", amounts=outputs),
72+
)
73+
assert_raises_rpc_error(
74+
-4,
75+
"Fee exceeds maximum configured by -maxtxfee",
76+
lambda: self.nodes[0].fundrawtransaction(hexstring=raw_tx),
77+
)
78+
self.nodes[0].settxfee(0)
79+
4180

4281
if __name__ == '__main__':
4382
CreateTxWalletTest().main()

0 commit comments

Comments
 (0)