6
6
from test_framework .test_framework import BitcoinTestFramework
7
7
from test_framework .util import (
8
8
assert_equal ,
9
+ assert_raises_rpc_error ,
9
10
)
10
11
from test_framework .blocktools import (
11
12
TIME_GENESIS_BLOCK ,
@@ -26,6 +27,10 @@ def run_test(self):
26
27
self .nodes [0 ].generate (200 )
27
28
self .nodes [0 ].setmocktime (0 )
28
29
30
+ self .test_anti_fee_sniping ()
31
+ self .test_tx_size_too_large ()
32
+
33
+ def test_anti_fee_sniping (self ):
29
34
self .log .info ('Check that we have some (old) blocks and that anti-fee-sniping is disabled' )
30
35
assert_equal (self .nodes [0 ].getblockchaininfo ()['blocks' ], 200 )
31
36
txid = self .nodes [0 ].sendtoaddress (self .nodes [0 ].getnewaddress (), 1 )
@@ -38,6 +43,40 @@ def run_test(self):
38
43
tx = self .nodes [0 ].decoderawtransaction (self .nodes [0 ].gettransaction (txid )['hex' ])
39
44
assert 0 < tx ['locktime' ] <= 201
40
45
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
+
41
80
42
81
if __name__ == '__main__' :
43
82
CreateTxWalletTest ().main ()
0 commit comments