Merge #12001: [RPC] Adding ::minRelayTxFee amount to getmempoolinfo and updating...
[bitcoinplatinum.git] / test / functional / mempool_limit.py
blobe7ce3820d23690259eca4a307b0fec430d497c1e
1 #!/usr/bin/env python3
2 # Copyright (c) 2014-2017 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 """Test mempool limiting together/eviction with the wallet."""
7 from test_framework.test_framework import BitcoinTestFramework
8 from test_framework.util import *
10 class MempoolLimitTest(BitcoinTestFramework):
11 def set_test_params(self):
12 self.setup_clean_chain = True
13 self.num_nodes = 1
14 self.extra_args = [["-maxmempool=5", "-spendzeroconfchange=0"]]
16 def run_test(self):
17 txouts = gen_return_txouts()
18 relayfee = self.nodes[0].getnetworkinfo()['relayfee']
20 self.log.info('Check that mempoolminfee is minrelytxfee')
21 assert_equal(self.nodes[0].getmempoolinfo()['minrelaytxfee'], Decimal('0.00001000'))
22 assert_equal(self.nodes[0].getmempoolinfo()['mempoolminfee'], Decimal('0.00001000'))
24 txids = []
25 utxos = create_confirmed_utxos(relayfee, self.nodes[0], 91)
27 self.log.info('Create a mempool tx that will be evicted')
28 us0 = utxos.pop()
29 inputs = [{ "txid" : us0["txid"], "vout" : us0["vout"]}]
30 outputs = {self.nodes[0].getnewaddress() : 0.0001}
31 tx = self.nodes[0].createrawtransaction(inputs, outputs)
32 self.nodes[0].settxfee(relayfee) # specifically fund this tx with low fee
33 txF = self.nodes[0].fundrawtransaction(tx)
34 self.nodes[0].settxfee(0) # return to automatic fee selection
35 txFS = self.nodes[0].signrawtransaction(txF['hex'])
36 txid = self.nodes[0].sendrawtransaction(txFS['hex'])
38 relayfee = self.nodes[0].getnetworkinfo()['relayfee']
39 base_fee = relayfee*100
40 for i in range (3):
41 txids.append([])
42 txids[i] = create_lots_of_big_transactions(self.nodes[0], txouts, utxos[30*i:30*i+30], 30, (i+1)*base_fee)
44 self.log.info('The tx should be evicted by now')
45 assert(txid not in self.nodes[0].getrawmempool())
46 txdata = self.nodes[0].gettransaction(txid)
47 assert(txdata['confirmations'] == 0) #confirmation should still be 0
49 self.log.info('Check that mempoolminfee is larger than minrelytxfee')
50 assert_equal(self.nodes[0].getmempoolinfo()['minrelaytxfee'], Decimal('0.00001000'))
51 assert_greater_than(self.nodes[0].getmempoolinfo()['mempoolminfee'], Decimal('0.00001000'))
53 if __name__ == '__main__':
54 MempoolLimitTest().main()