Changeset View
Changeset View
Standalone View
Standalone View
test/functional/mempool_persist.py
Show First 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
assert_equal(len(self.nodes[0].getrawmempool()), 5) | assert_equal(len(self.nodes[0].getrawmempool()), 5) | ||||
assert_equal(len(self.nodes[1].getrawmempool()), 5) | assert_equal(len(self.nodes[1].getrawmempool()), 5) | ||||
self.log.debug("Prioritize a transaction on node0") | self.log.debug("Prioritize a transaction on node0") | ||||
fees = self.nodes[0].getmempoolentry(txid=last_txid)['fees'] | fees = self.nodes[0].getmempoolentry(txid=last_txid)['fees'] | ||||
assert_equal(fees['base'], fees['modified']) | assert_equal(fees['base'], fees['modified']) | ||||
self.nodes[0].prioritisetransaction(txid=last_txid, fee_delta=1000) | self.nodes[0].prioritisetransaction(txid=last_txid, fee_delta=1000) | ||||
fees = self.nodes[0].getmempoolentry(txid=last_txid)['fees'] | fees = self.nodes[0].getmempoolentry(txid=last_txid)['fees'] | ||||
assert_equal(fees['base'] + Decimal('0.00001000'), fees['modified']) | assert_equal(fees['base'] + Decimal('10.0'), fees['modified']) | ||||
tx_creation_time = self.nodes[0].getmempoolentry(txid=last_txid)[ | tx_creation_time = self.nodes[0].getmempoolentry(txid=last_txid)[ | ||||
'time'] | 'time'] | ||||
assert_greater_than_or_equal(tx_creation_time, tx_creation_time_lower) | assert_greater_than_or_equal(tx_creation_time, tx_creation_time_lower) | ||||
assert_greater_than_or_equal(tx_creation_time_higher, tx_creation_time) | assert_greater_than_or_equal(tx_creation_time_higher, tx_creation_time) | ||||
# disconnect nodes & make a txn that remains in the unbroadcast set. | # disconnect nodes & make a txn that remains in the unbroadcast set. | ||||
disconnect_nodes(self.nodes[0], self.nodes[1]) | disconnect_nodes(self.nodes[0], self.nodes[1]) | ||||
assert(len(self.nodes[0].getpeerinfo()) == 0) | assert(len(self.nodes[0].getpeerinfo()) == 0) | ||||
assert(len(self.nodes[0].p2ps) == 0) | assert(len(self.nodes[0].p2ps) == 0) | ||||
self.nodes[0].sendtoaddress( | self.nodes[0].sendtoaddress( | ||||
self.nodes[2].getnewaddress(), Decimal("12")) | self.nodes[2].getnewaddress(), Decimal("12000000")) | ||||
connect_nodes(self.nodes[0], self.nodes[2]) | connect_nodes(self.nodes[0], self.nodes[2]) | ||||
self.log.debug("Stop-start the nodes. Verify that node0 has the " | self.log.debug("Stop-start the nodes. Verify that node0 has the " | ||||
"transactions in its mempool and node1 does not. " | "transactions in its mempool and node1 does not. " | ||||
"Verify that node2 calculates its balance correctly " | "Verify that node2 calculates its balance correctly " | ||||
"after loading wallet transactions.") | "after loading wallet transactions.") | ||||
self.stop_nodes() | self.stop_nodes() | ||||
# Give this one a head-start, so we can be "extra-sure" that it didn't | # Give this one a head-start, so we can be "extra-sure" that it didn't | ||||
# load anything later | # load anything later | ||||
# Also don't store the mempool, to keep the datadir clean | # Also don't store the mempool, to keep the datadir clean | ||||
self.start_node(1, extra_args=["-persistmempool=0"]) | self.start_node(1, extra_args=["-persistmempool=0"]) | ||||
self.start_node(0) | self.start_node(0) | ||||
self.start_node(2) | self.start_node(2) | ||||
# start_node is blocking on the mempool being loaded | # start_node is blocking on the mempool being loaded | ||||
assert self.nodes[0].getmempoolinfo()["loaded"] | assert self.nodes[0].getmempoolinfo()["loaded"] | ||||
assert self.nodes[2].getmempoolinfo()["loaded"] | assert self.nodes[2].getmempoolinfo()["loaded"] | ||||
assert_equal(len(self.nodes[0].getrawmempool()), 6) | assert_equal(len(self.nodes[0].getrawmempool()), 6) | ||||
assert_equal(len(self.nodes[2].getrawmempool()), 5) | assert_equal(len(self.nodes[2].getrawmempool()), 5) | ||||
# The others have loaded their mempool. If node_1 loaded anything, we'd | # The others have loaded their mempool. If node_1 loaded anything, we'd | ||||
# probably notice by now: | # probably notice by now: | ||||
assert_equal(len(self.nodes[1].getrawmempool()), 0) | assert_equal(len(self.nodes[1].getrawmempool()), 0) | ||||
self.log.debug('Verify prioritization is loaded correctly') | self.log.debug('Verify prioritization is loaded correctly') | ||||
fees = self.nodes[0].getmempoolentry(txid=last_txid)['fees'] | fees = self.nodes[0].getmempoolentry(txid=last_txid)['fees'] | ||||
assert_equal(fees['base'] + Decimal('0.00001000'), fees['modified']) | assert_equal(fees['base'] + Decimal('10.00'), fees['modified']) | ||||
self.log.debug('Verify time is loaded correctly') | self.log.debug('Verify time is loaded correctly') | ||||
assert_equal( | assert_equal( | ||||
tx_creation_time, | tx_creation_time, | ||||
self.nodes[0].getmempoolentry( | self.nodes[0].getmempoolentry( | ||||
txid=last_txid)['time']) | txid=last_txid)['time']) | ||||
# Verify accounting of mempool transactions after restart is correct | # Verify accounting of mempool transactions after restart is correct | ||||
▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines |