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("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 load anything later | # Give this one a head-start, so we can be "extra-sure" that it didn't | ||||
# load anything later | |||||
self.start_node(1) | self.start_node(1) | ||||
self.start_node(0) | self.start_node(0) | ||||
self.start_node(2) | self.start_node(2) | ||||
wait_until(lambda: self.nodes[0].getmempoolinfo()["loaded"], timeout=1) | wait_until(lambda: self.nodes[0].getmempoolinfo()["loaded"], timeout=1) | ||||
wait_until(lambda: self.nodes[2].getmempoolinfo()["loaded"], timeout=1) | wait_until(lambda: self.nodes[2].getmempoolinfo()["loaded"], timeout=1) | ||||
assert_equal(len(self.nodes[0].getrawmempool()), 5) | assert_equal(len(self.nodes[0].getrawmempool()), 5) | ||||
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 probably notice by now: | # The others have loaded their mempool. If node_1 loaded anything, we'd | ||||
# probably notice by now: | |||||
assert_equal(len(self.nodes[1].getrawmempool()), 0) | assert_equal(len(self.nodes[1].getrawmempool()), 0) | ||||
# Verify accounting of mempool transactions after restart is correct | # Verify accounting of mempool transactions after restart is correct | ||||
# Flush mempool to wallet | # Flush mempool to wallet | ||||
self.nodes[2].syncwithvalidationinterfacequeue() | self.nodes[2].syncwithvalidationinterfacequeue() | ||||
assert_equal(node2_balance, self.nodes[2].getbalance()) | assert_equal(node2_balance, self.nodes[2].getbalance()) | ||||
self.log.debug( | self.log.debug( | ||||
Show All 26 Lines | def run_test(self): | ||||
self.stop_nodes() | self.stop_nodes() | ||||
self.start_node(1, extra_args=[]) | self.start_node(1, extra_args=[]) | ||||
wait_until(lambda: self.nodes[1].getmempoolinfo()["loaded"]) | wait_until(lambda: self.nodes[1].getmempoolinfo()["loaded"]) | ||||
assert_equal(len(self.nodes[1].getrawmempool()), 5) | assert_equal(len(self.nodes[1].getrawmempool()), 5) | ||||
self.log.debug( | self.log.debug( | ||||
"Prevent bitcoind from writing mempool.dat to disk. Verify that `savemempool` fails") | "Prevent bitcoind from writing mempool.dat to disk. Verify that `savemempool` fails") | ||||
# to test the exception we are creating a tmp folder called mempool.dat.new | # to test the exception we are creating a tmp folder called mempool.dat.new | ||||
# which is an implementation detail that could change and break this test | # which is an implementation detail that could change and break this | ||||
# test | |||||
mempooldotnew1 = mempooldat1 + '.new' | mempooldotnew1 = mempooldat1 + '.new' | ||||
os.mkdir(mempooldotnew1) | os.mkdir(mempooldotnew1) | ||||
assert_raises_rpc_error(-1, "Unable to dump mempool to disk", | assert_raises_rpc_error(-1, "Unable to dump mempool to disk", | ||||
self.nodes[1].savemempool) | self.nodes[1].savemempool) | ||||
os.rmdir(mempooldotnew1) | os.rmdir(mempooldotnew1) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
MempoolPersistTest().main() | MempoolPersistTest().main() |