@@ -432,27 +432,51 @@ def run_test(self):
432
432
433
433
self .log .info ('sendrawtransaction/testmempoolaccept with maxfeerate' )
434
434
435
+ # Test a transaction with small fee
435
436
txId = self .nodes [0 ].sendtoaddress (self .nodes [2 ].getnewaddress (), 1.0 )
436
437
rawTx = self .nodes [0 ].getrawtransaction (txId , True )
437
438
vout = next (o for o in rawTx ['vout' ] if o ['value' ] == Decimal ('1.00000000' ))
438
439
439
440
self .sync_all ()
440
441
inputs = [{ "txid" : txId , "vout" : vout ['n' ] }]
441
- outputs = { self .nodes [0 ].getnewaddress () : Decimal ("0.99999000 " ) } # 1000 sat fee
442
+ outputs = { self .nodes [0 ].getnewaddress () : Decimal ("0.999990000 " ) } # 10000 sat fee
442
443
rawTx = self .nodes [2 ].createrawtransaction (inputs , outputs )
443
444
rawTxSigned = self .nodes [2 ].signrawtransactionwithwallet (rawTx )
444
445
assert_equal (rawTxSigned ['complete' ], True )
445
- # 1000 sat fee, ~100 b transaction, fee rate should land around 10 sat/b = 0.00010000 BTC/kB
446
+ # 10000 sat fee, ~100 b transaction, fee rate should land around 100 sat/b = 0.00100000 BTC/kB
446
447
# Thus, testmempoolaccept should reject
447
448
testres = self .nodes [2 ].testmempoolaccept ([rawTxSigned ['hex' ]], 0.00001000 )[0 ]
448
449
assert_equal (testres ['allowed' ], False )
449
450
assert_equal (testres ['reject-reason' ], '256: absurdly-high-fee' )
450
451
# and sendrawtransaction should throw
451
452
assert_raises_rpc_error (- 26 , "absurdly-high-fee" , self .nodes [2 ].sendrawtransaction , rawTxSigned ['hex' ], 0.00001000 )
452
453
# And below calls should both succeed
453
- testres = self .nodes [2 ].testmempoolaccept (rawtxs = [rawTxSigned ['hex' ]], maxfeerate = '0.00070000' )[0 ]
454
+ testres = self .nodes [2 ].testmempoolaccept (rawtxs = [rawTxSigned ['hex' ]])[0 ]
454
455
assert_equal (testres ['allowed' ], True )
455
- self .nodes [2 ].sendrawtransaction (hexstring = rawTxSigned ['hex' ], maxfeerate = '0.00070000' )
456
+ self .nodes [2 ].sendrawtransaction (hexstring = rawTxSigned ['hex' ])
457
+
458
+ # Test a transaction with large fee
459
+ txId = self .nodes [0 ].sendtoaddress (self .nodes [2 ].getnewaddress (), 1.0 )
460
+ rawTx = self .nodes [0 ].getrawtransaction (txId , True )
461
+ vout = next (o for o in rawTx ['vout' ] if o ['value' ] == Decimal ('1.00000000' ))
462
+
463
+ self .sync_all ()
464
+ inputs = [{ "txid" : txId , "vout" : vout ['n' ] }]
465
+ outputs = { self .nodes [0 ].getnewaddress () : Decimal ("0.98000000" ) } # 2000000 sat fee
466
+ rawTx = self .nodes [2 ].createrawtransaction (inputs , outputs )
467
+ rawTxSigned = self .nodes [2 ].signrawtransactionwithwallet (rawTx )
468
+ assert_equal (rawTxSigned ['complete' ], True )
469
+ # 2000000 sat fee, ~100 b transaction, fee rate should land around 20000 sat/b = 0.20000000 BTC/kB
470
+ # Thus, testmempoolaccept should reject
471
+ testres = self .nodes [2 ].testmempoolaccept ([rawTxSigned ['hex' ]])[0 ]
472
+ assert_equal (testres ['allowed' ], False )
473
+ assert_equal (testres ['reject-reason' ], '256: absurdly-high-fee' )
474
+ # and sendrawtransaction should throw
475
+ assert_raises_rpc_error (- 26 , "absurdly-high-fee" , self .nodes [2 ].sendrawtransaction , rawTxSigned ['hex' ])
476
+ # And below calls should both succeed
477
+ testres = self .nodes [2 ].testmempoolaccept (rawtxs = [rawTxSigned ['hex' ]], maxfeerate = '0.20000000' )[0 ]
478
+ assert_equal (testres ['allowed' ], True )
479
+ self .nodes [2 ].sendrawtransaction (hexstring = rawTxSigned ['hex' ], maxfeerate = '0.20000000' )
456
480
457
481
458
482
if __name__ == '__main__' :
0 commit comments