您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

mempool_limit.py 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 set_test_params(self):
  10. self.setup_clean_chain = True
  11. self.num_nodes = 1
  12. self.extra_args = [["-maxmempool=5", "-spendzeroconfchange=0"]]
  13. def run_test(self):
  14. txouts = gen_return_txouts()
  15. relayfee = self.nodes[0].getnetworkinfo()['relayfee']
  16. txids = []
  17. utxos = create_confirmed_utxos(relayfee, self.nodes[0], 91)
  18. #create a mempool tx that will be evicted
  19. us0 = utxos.pop()
  20. inputs = [{ "txid" : us0["txid"], "vout" : us0["vout"]}]
  21. outputs = {self.nodes[0].getnewaddress() : 0.0001}
  22. tx = self.nodes[0].createrawtransaction(inputs, outputs)
  23. self.nodes[0].settxfee(relayfee) # specifically fund this tx with low fee
  24. txF = self.nodes[0].fundrawtransaction(tx)
  25. self.nodes[0].settxfee(0) # return to automatic fee selection
  26. txFS = self.nodes[0].signrawtransaction(txF['hex'])
  27. txid = self.nodes[0].sendrawtransaction(txFS['hex'])
  28. relayfee = self.nodes[0].getnetworkinfo()['relayfee']
  29. base_fee = relayfee*100
  30. for i in range (3):
  31. txids.append([])
  32. txids[i] = create_lots_of_big_transactions(self.nodes[0], txouts, utxos[30*i:30*i+30], 30, (i+1)*base_fee)
  33. # by now, the tx should be evicted, check confirmation state
  34. assert(txid not in self.nodes[0].getrawmempool())
  35. txdata = self.nodes[0].gettransaction(txid)
  36. assert(txdata['confirmations'] == 0) #confirmation should still be 0
  37. if __name__ == '__main__':
  38. MempoolLimitTest().main()