aboutsummaryrefslogtreecommitdiff
path: root/test/functional/wallet_create_tx.py
diff options
context:
space:
mode:
authorMarcoFalke <[email protected]>2019-07-02 11:50:44 -0400
committerJoão Barbosa <[email protected]>2019-08-25 02:51:50 +0100
commitd3b3bb8c9fb3a2ff1cd3a8776552c649aaf19dc2 (patch)
tree6da4ad0852697efc1cad16e2d64b5485cfa7e87d /test/functional/wallet_create_tx.py
parent0.18: wallet: Fix -maxtxfee check by moving it to CWallet::CreateTransaction (diff)
downloaddiscoin-d3b3bb8c9fb3a2ff1cd3a8776552c649aaf19dc2.tar.xz
discoin-d3b3bb8c9fb3a2ff1cd3a8776552c649aaf19dc2.zip
0.18: test: Add test for maxtxfee option
Github-Pull: #16322 Rebased-From: 0d101a340c44841cbbc5982d55354b1787bc39e2
Diffstat (limited to 'test/functional/wallet_create_tx.py')
-rwxr-xr-xtest/functional/wallet_create_tx.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/functional/wallet_create_tx.py b/test/functional/wallet_create_tx.py
index 7b749235e..7222fb9f9 100755
--- a/test/functional/wallet_create_tx.py
+++ b/test/functional/wallet_create_tx.py
@@ -6,6 +6,7 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
+ assert_raises_rpc_error,
)
from test_framework.blocktools import (
TIME_GENESIS_BLOCK,
@@ -26,6 +27,10 @@ class CreateTxWalletTest(BitcoinTestFramework):
self.nodes[0].generate(200)
self.nodes[0].setmocktime(0)
+ self.test_anti_fee_sniping()
+ self.test_tx_size_too_large()
+
+ def test_anti_fee_sniping(self):
self.log.info('Check that we have some (old) blocks and that anti-fee-sniping is disabled')
assert_equal(self.nodes[0].getblockchaininfo()['blocks'], 200)
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
@@ -38,6 +43,40 @@ class CreateTxWalletTest(BitcoinTestFramework):
tx = self.nodes[0].decoderawtransaction(self.nodes[0].gettransaction(txid)['hex'])
assert 0 < tx['locktime'] <= 201
+ def test_tx_size_too_large(self):
+ # More than 10kB of outputs, so that we hit -maxtxfee with a high feerate
+ outputs = {self.nodes[0].getnewaddress(address_type='bech32'): 0.000025 for i in range(400)}
+ raw_tx = self.nodes[0].createrawtransaction(inputs=[], outputs=outputs)
+
+ for fee_setting in ['-minrelaytxfee=0.01', '-mintxfee=0.01', '-paytxfee=0.01']:
+ self.log.info('Check maxtxfee in combination with {}'.format(fee_setting))
+ self.restart_node(0, extra_args=[fee_setting])
+ assert_raises_rpc_error(
+ -6,
+ "Fee exceeds maximum configured by -maxtxfee",
+ lambda: self.nodes[0].sendmany(dummy="", amounts=outputs),
+ )
+ assert_raises_rpc_error(
+ -4,
+ "Fee exceeds maximum configured by -maxtxfee",
+ lambda: self.nodes[0].fundrawtransaction(hexstring=raw_tx),
+ )
+
+ self.log.info('Check maxtxfee in combination with settxfee')
+ self.restart_node(0)
+ self.nodes[0].settxfee(0.01)
+ assert_raises_rpc_error(
+ -6,
+ "Fee exceeds maximum configured by -maxtxfee",
+ lambda: self.nodes[0].sendmany(dummy="", amounts=outputs),
+ )
+ assert_raises_rpc_error(
+ -4,
+ "Fee exceeds maximum configured by -maxtxfee",
+ lambda: self.nodes[0].fundrawtransaction(hexstring=raw_tx),
+ )
+ self.nodes[0].settxfee(0)
+
if __name__ == '__main__':
CreateTxWalletTest().main()