2 # Copyright (c) 2014-2016 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
14 self
.extra_args
= [["-maxmempool=5", "-spendzeroconfchange=0"]]
17 txouts
= gen_return_txouts()
18 relayfee
= self
.nodes
[0].getnetworkinfo()['relayfee']
21 utxos
= create_confirmed_utxos(relayfee
, self
.nodes
[0], 91)
23 #create a mempool tx that will be evicted
25 inputs
= [{ "txid" : us0
["txid"], "vout" : us0
["vout"]}]
26 outputs
= {self
.nodes
[0].getnewaddress() : 0.0001}
27 tx
= self
.nodes
[0].createrawtransaction(inputs
, outputs
)
28 self
.nodes
[0].settxfee(relayfee
) # specifically fund this tx with low fee
29 txF
= self
.nodes
[0].fundrawtransaction(tx
)
30 self
.nodes
[0].settxfee(0) # return to automatic fee selection
31 txFS
= self
.nodes
[0].signrawtransaction(txF
['hex'])
32 txid
= self
.nodes
[0].sendrawtransaction(txFS
['hex'])
34 relayfee
= self
.nodes
[0].getnetworkinfo()['relayfee']
35 base_fee
= relayfee
*100
38 txids
[i
] = create_lots_of_big_transactions(self
.nodes
[0], txouts
, utxos
[30*i
:30*i
+30], 30, (i
+1)*base_fee
)
40 # by now, the tx should be evicted, check confirmation state
41 assert(txid
not in self
.nodes
[0].getrawmempool())
42 txdata
= self
.nodes
[0].gettransaction(txid
)
43 assert(txdata
['confirmations'] == 0) #confirmation should still be 0
45 if __name__
== '__main__':
46 MempoolLimitTest().main()