mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-08 17:30:36 +02:00
Merge bitcoin/bitcoin#25592: test persistence of non-mempool tx prioritisation
a9790ba95f
[test] persist prioritisation of transactions not in mempool (glozow) Pull request description: We persist tx prioritisation/fee deltas in mempool.dat (see `DumpMempool`). It seems we have test coverage for persistence of modified fees of mempool entries (see `vinfo` loop), but not for the prioritisation of transactions not in mempool (see `mapDeltas`). Relevant: https://github.com/bitcoin/bitcoin/pull/25487#discussion_r917490221 ACKs for top commit: darosior: utACKa9790ba95f
w0xlt: ACKa9790ba95f
Tree-SHA512: 3f2769a917041f12414584f69b2239eef57586f9975869e826f356633fcaf893fde15500619b302e7663de14f3661c6cba22c7524cab5286e715e2c105726521
This commit is contained in:
@ -105,6 +105,11 @@ class MempoolPersistTest(BitcoinTestFramework):
|
|||||||
assert_equal(len(self.nodes[0].p2ps), 0)
|
assert_equal(len(self.nodes[0].p2ps), 0)
|
||||||
self.mini_wallet.send_self_transfer(from_node=self.nodes[0])
|
self.mini_wallet.send_self_transfer(from_node=self.nodes[0])
|
||||||
|
|
||||||
|
# Test persistence of prioritisation for transactions not in the mempool.
|
||||||
|
# Create a tx and prioritise but don't submit until after the restart.
|
||||||
|
tx_prioritised_not_submitted = self.mini_wallet.create_self_transfer()
|
||||||
|
self.nodes[0].prioritisetransaction(txid=tx_prioritised_not_submitted['txid'], fee_delta=9999)
|
||||||
|
|
||||||
self.log.debug("Stop-start the nodes. Verify that node0 has the transactions in its mempool and node1 does not. Verify that node2 calculates its balance correctly after loading wallet transactions.")
|
self.log.debug("Stop-start the nodes. Verify that node0 has the transactions in its mempool and node1 does not. Verify that node2 calculates its balance correctly after loading wallet transactions.")
|
||||||
self.stop_nodes()
|
self.stop_nodes()
|
||||||
# Give this node a head-start, so we can be "extra-sure" that it didn't load anything later
|
# Give this node a head-start, so we can be "extra-sure" that it didn't load anything later
|
||||||
@ -125,6 +130,9 @@ class MempoolPersistTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
self.log.debug('Verify all fields are loaded correctly')
|
self.log.debug('Verify all fields are loaded correctly')
|
||||||
assert_equal(last_entry, self.nodes[0].getmempoolentry(txid=last_txid))
|
assert_equal(last_entry, self.nodes[0].getmempoolentry(txid=last_txid))
|
||||||
|
self.nodes[0].sendrawtransaction(tx_prioritised_not_submitted['hex'])
|
||||||
|
entry_prioritised_before_restart = self.nodes[0].getmempoolentry(txid=tx_prioritised_not_submitted['txid'])
|
||||||
|
assert_equal(entry_prioritised_before_restart['fees']['base'] + Decimal('0.00009999'), entry_prioritised_before_restart['fees']['modified'])
|
||||||
|
|
||||||
# Verify accounting of mempool transactions after restart is correct
|
# Verify accounting of mempool transactions after restart is correct
|
||||||
if self.is_sqlite_compiled():
|
if self.is_sqlite_compiled():
|
||||||
@ -143,7 +151,7 @@ class MempoolPersistTest(BitcoinTestFramework):
|
|||||||
self.stop_nodes()
|
self.stop_nodes()
|
||||||
self.start_node(0)
|
self.start_node(0)
|
||||||
assert self.nodes[0].getmempoolinfo()["loaded"]
|
assert self.nodes[0].getmempoolinfo()["loaded"]
|
||||||
assert_equal(len(self.nodes[0].getrawmempool()), 6)
|
assert_equal(len(self.nodes[0].getrawmempool()), 7)
|
||||||
|
|
||||||
mempooldat0 = os.path.join(self.nodes[0].datadir, self.chain, 'mempool.dat')
|
mempooldat0 = os.path.join(self.nodes[0].datadir, self.chain, 'mempool.dat')
|
||||||
mempooldat1 = os.path.join(self.nodes[1].datadir, self.chain, 'mempool.dat')
|
mempooldat1 = os.path.join(self.nodes[1].datadir, self.chain, 'mempool.dat')
|
||||||
@ -153,12 +161,12 @@ class MempoolPersistTest(BitcoinTestFramework):
|
|||||||
assert os.path.isfile(mempooldat0)
|
assert os.path.isfile(mempooldat0)
|
||||||
assert_equal(result0['filename'], mempooldat0)
|
assert_equal(result0['filename'], mempooldat0)
|
||||||
|
|
||||||
self.log.debug("Stop nodes, make node1 use mempool.dat from node0. Verify it has 6 transactions")
|
self.log.debug("Stop nodes, make node1 use mempool.dat from node0. Verify it has 7 transactions")
|
||||||
os.rename(mempooldat0, mempooldat1)
|
os.rename(mempooldat0, mempooldat1)
|
||||||
self.stop_nodes()
|
self.stop_nodes()
|
||||||
self.start_node(1, extra_args=["-persistmempool"])
|
self.start_node(1, extra_args=["-persistmempool"])
|
||||||
assert self.nodes[1].getmempoolinfo()["loaded"]
|
assert self.nodes[1].getmempoolinfo()["loaded"]
|
||||||
assert_equal(len(self.nodes[1].getrawmempool()), 6)
|
assert_equal(len(self.nodes[1].getrawmempool()), 7)
|
||||||
|
|
||||||
self.log.debug("Prevent bitcoind from writing mempool.dat to disk. Verify that `savemempool` fails")
|
self.log.debug("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
|
||||||
|
Reference in New Issue
Block a user