Dash Core  0.12.2.1
P2P Digital Currency
mempool_limit.py
Go to the documentation of this file.
1 #!/usr/bin/env python2
2 # Copyright (c) 2014-2015 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 
6 # Test mempool limiting together/eviction with the wallet
7 
8 from test_framework.test_framework import BitcoinTestFramework
9 from test_framework.util import *
10 
12 
13  def __init__(self):
15 
16  def setup_network(self):
17  self.nodes = []
18  self.nodes.append(start_node(0, self.options.tmpdir, ["-maxmempool=5", "-spendzeroconfchange=0", "-debug"]))
19  self.is_network_split = False
20  self.sync_all()
21  self.relayfee = self.nodes[0].getnetworkinfo()['relayfee']
22 
23  def setup_chain(self):
24  print("Initializing test directory "+self.options.tmpdir)
25  initialize_chain_clean(self.options.tmpdir, 2)
26 
27  def run_test(self):
28  txids = []
29  utxos = create_confirmed_utxos(self.relayfee, self.nodes[0], 490)
30 
31  #create a mempool tx that will be evicted
32  us0 = utxos.pop()
33  inputs = [{ "txid" : us0["txid"], "vout" : us0["vout"]}]
34  outputs = {self.nodes[0].getnewaddress() : 0.0001}
35  tx = self.nodes[0].createrawtransaction(inputs, outputs)
36  self.nodes[0].settxfee(self.relayfee) # specifically fund this tx with low fee
37  txF = self.nodes[0].fundrawtransaction(tx)
38  self.nodes[0].settxfee(0) # return to automatic fee selection
39  txFS = self.nodes[0].signrawtransaction(txF['hex'])
40  txid = self.nodes[0].sendrawtransaction(txFS['hex'])
41 
42  relayfee = self.nodes[0].getnetworkinfo()['relayfee']
43  base_fee = relayfee*100
44  for i in xrange (4):
45  txids.append([])
46  txids[i] = create_lots_of_big_transactions(self.nodes[0], self.txouts, utxos[30*i:30*i+30], (i+1)*base_fee)
47 
48  # by now, the tx should be evicted, check confirmation state
49  assert(txid not in self.nodes[0].getrawmempool())
50  txdata = self.nodes[0].gettransaction(txid)
51  assert(txdata['confirmations'] == 0) #confirmation should still be 0
52 
53 if __name__ == '__main__':
UniValue settxfee(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2349
UniValue getnewaddress(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:113
def initialize_chain_clean(test_dir, num_nodes)
Definition: util.py:252
UniValue signrawtransaction(const UniValue &params, bool fHelp)
UniValue createrawtransaction(const UniValue &params, bool fHelp)
def gen_return_txouts()
Definition: util.py:559
def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None)
Definition: util.py:281
UniValue sendrawtransaction(const UniValue &params, bool fHelp)
UniValue getrawmempool(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:234
def create_confirmed_utxos(fee, node, count)
Definition: util.py:530
UniValue getnetworkinfo(const UniValue &params, bool fHelp)
Definition: net.cpp:392
UniValue gettransaction(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1821
def create_lots_of_big_transactions(node, txouts, utxos, fee)
Definition: util.py:587