You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mempool_limit.py 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env python3
  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."""
  6. from test_framework.test_framework import BitcoinTestFramework
  7. from test_framework.util import *
  8. class MempoolLimitTest(BitcoinTestFramework):
  9. def setup_network(self):
  10. self.nodes = []
  11. self.nodes.append(start_node(0, self.options.tmpdir, ["-maxmempool=5", "-spendzeroconfchange=0"]))
  12. self.is_network_split = False
  13. self.sync_all()
  14. self.relayfee = self.nodes[0].getnetworkinfo()['relayfee']
  15. def __init__(self):
  16. super().__init__()
  17. self.setup_clean_chain = True
  18. self.num_nodes = 1
  19. self.txouts = gen_return_txouts()
  20. def run_test(self):
  21. txids = []
  22. utxos = create_confirmed_utxos(self.relayfee, self.nodes[0], 91)
  23. #create a mempool tx that will be evicted
  24. us0 = utxos.pop()
  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(self.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'])
  33. relayfee = self.nodes[0].getnetworkinfo()['relayfee']
  34. base_fee = relayfee*100
  35. for i in range (3):
  36. txids.append([])
  37. txids[i] = create_lots_of_big_transactions(self.nodes[0], self.txouts, utxos[30*i:30*i+30], 30, (i+1)*base_fee)
  38. # by now, the tx should be evicted, check confirmation state
  39. assert(txid not in self.nodes[0].getrawmempool())
  40. txdata = self.nodes[0].gettransaction(txid)
  41. assert(txdata['confirmations'] == 0) #confirmation should still be 0
  42. if __name__ == '__main__':
  43. MempoolLimitTest().main()