Changeset View
Changeset View
Standalone View
Standalone View
test/functional/mempool_persist.py
Show First 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
os.rename(mempooldat0, mempooldat1) | os.rename(mempooldat0, mempooldat1) | ||||
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 setting bad permissions on a tmp file 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' | ||||
with os.fdopen(os.open(mempooldotnew1, os.O_CREAT, 0o000), 'w'): | os.mkdir(mempooldotnew1) | ||||
pass | |||||
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.remove(mempooldotnew1) | os.rmdir(mempooldotnew1) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
MempoolPersistTest().main() | MempoolPersistTest().main() |