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.
54 lines
2.1 KiB
54 lines
2.1 KiB
9 years ago
|
#!/usr/bin/env python3
|
||
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||
9 years ago
|
# Distributed under the MIT software license, see the accompanying
|
||
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||
8 years ago
|
"""Test mempool limiting together/eviction with the wallet."""
|
||
9 years ago
|
|
||
|
from test_framework.test_framework import BitcoinTestFramework
|
||
|
from test_framework.util import *
|
||
|
|
||
|
class MempoolLimitTest(BitcoinTestFramework):
|
||
|
|
||
|
def setup_network(self):
|
||
|
self.nodes = []
|
||
8 years ago
|
self.nodes.append(start_node(0, self.options.tmpdir, ["-maxmempool=5", "-spendzeroconfchange=0"]))
|
||
9 years ago
|
self.is_network_split = False
|
||
|
self.sync_all()
|
||
|
self.relayfee = self.nodes[0].getnetworkinfo()['relayfee']
|
||
|
|
||
9 years ago
|
def __init__(self):
|
||
|
super().__init__()
|
||
|
self.setup_clean_chain = True
|
||
9 years ago
|
self.num_nodes = 1
|
||
9 years ago
|
|
||
|
self.txouts = gen_return_txouts()
|
||
9 years ago
|
|
||
|
def run_test(self):
|
||
|
txids = []
|
||
8 years ago
|
utxos = create_confirmed_utxos(self.relayfee, self.nodes[0], 91)
|
||
9 years ago
|
|
||
|
#create a mempool tx that will be evicted
|
||
|
us0 = utxos.pop()
|
||
|
inputs = [{ "txid" : us0["txid"], "vout" : us0["vout"]}]
|
||
9 years ago
|
outputs = {self.nodes[0].getnewaddress() : 0.0001}
|
||
9 years ago
|
tx = self.nodes[0].createrawtransaction(inputs, outputs)
|
||
9 years ago
|
self.nodes[0].settxfee(self.relayfee) # specifically fund this tx with low fee
|
||
9 years ago
|
txF = self.nodes[0].fundrawtransaction(tx)
|
||
9 years ago
|
self.nodes[0].settxfee(0) # return to automatic fee selection
|
||
9 years ago
|
txFS = self.nodes[0].signrawtransaction(txF['hex'])
|
||
|
txid = self.nodes[0].sendrawtransaction(txFS['hex'])
|
||
|
|
||
|
relayfee = self.nodes[0].getnetworkinfo()['relayfee']
|
||
|
base_fee = relayfee*100
|
||
8 years ago
|
for i in range (3):
|
||
9 years ago
|
txids.append([])
|
||
8 years ago
|
txids[i] = create_lots_of_big_transactions(self.nodes[0], self.txouts, utxos[30*i:30*i+30], 30, (i+1)*base_fee)
|
||
9 years ago
|
|
||
|
# by now, the tx should be evicted, check confirmation state
|
||
|
assert(txid not in self.nodes[0].getrawmempool())
|
||
9 years ago
|
txdata = self.nodes[0].gettransaction(txid)
|
||
9 years ago
|
assert(txdata['confirmations'] == 0) #confirmation should still be 0
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
MempoolLimitTest().main()
|