Changeset View
Changeset View
Standalone View
Standalone View
test/functional/mempool_limit.py
Show All 9 Lines | |||||
from test_framework.blocktools import send_big_transactions, create_confirmed_utxos | from test_framework.blocktools import send_big_transactions, create_confirmed_utxos | ||||
class MempoolLimitTest(BitcoinTestFramework): | class MempoolLimitTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
self.extra_args = [ | self.extra_args = [["-maxmempool=5", "-spendzeroconfchange=0"]] | ||||
["-maxmempool=5", "-spendzeroconfchange=0", "-deprecatedrpc=signrawtransaction"]] | |||||
def run_test(self): | def run_test(self): | ||||
relayfee = self.nodes[0].getnetworkinfo()['relayfee'] | relayfee = self.nodes[0].getnetworkinfo()['relayfee'] | ||||
txids = [] | txids = [] | ||||
utxo_groups = 4 | utxo_groups = 4 | ||||
utxos = create_confirmed_utxos(self.nodes[0], 1 + 30 * utxo_groups) | utxos = create_confirmed_utxos(self.nodes[0], 1 + 30 * utxo_groups) | ||||
# create a mempool tx that will be evicted | # create a mempool tx that will be evicted | ||||
us0 = utxos.pop() | us0 = utxos.pop() | ||||
inputs = [{"txid": us0["txid"], "vout": us0["vout"]}] | inputs = [{"txid": us0["txid"], "vout": us0["vout"]}] | ||||
outputs = {self.nodes[0].getnewaddress(): 0.0001} | outputs = {self.nodes[0].getnewaddress(): 0.0001} | ||||
tx = self.nodes[0].createrawtransaction(inputs, outputs) | tx = self.nodes[0].createrawtransaction(inputs, outputs) | ||||
# specifically fund this tx with low fee | # specifically fund this tx with low fee | ||||
self.nodes[0].settxfee(relayfee) | self.nodes[0].settxfee(relayfee) | ||||
txF = self.nodes[0].fundrawtransaction(tx) | txF = self.nodes[0].fundrawtransaction(tx) | ||||
# return to automatic fee selection | # return to automatic fee selection | ||||
self.nodes[0].settxfee(0) | self.nodes[0].settxfee(0) | ||||
txFS = self.nodes[0].signrawtransaction(txF['hex']) | txFS = self.nodes[0].signrawtransactionwithwallet(txF['hex']) | ||||
txid = self.nodes[0].sendrawtransaction(txFS['hex']) | txid = self.nodes[0].sendrawtransaction(txFS['hex']) | ||||
for i in range(utxo_groups): | for i in range(utxo_groups): | ||||
txids.append([]) | txids.append([]) | ||||
txids[i] = send_big_transactions( | txids[i] = send_big_transactions( | ||||
self.nodes[0], utxos[30 * i:30 * i + 30], 30, 10 * (i + 1)) | self.nodes[0], utxos[30 * i:30 * i + 30], 30, 10 * (i + 1)) | ||||
# by now, the tx should be evicted, check confirmation state | # by now, the tx should be evicted, check confirmation state | ||||
assert(txid not in self.nodes[0].getrawmempool()) | assert(txid not in self.nodes[0].getrawmempool()) | ||||
txdata = self.nodes[0].gettransaction(txid) | txdata = self.nodes[0].gettransaction(txid) | ||||
assert(txdata['confirmations'] == 0) # confirmation should still be 0 | assert(txdata['confirmations'] == 0) # confirmation should still be 0 | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
MempoolLimitTest().main() | MempoolLimitTest().main() |