Skip to content

Commit 01ae8d9

Browse files
author
MacroFake
committed
Merge bitcoin/bitcoin#25592: test persistence of non-mempool tx prioritisation
a9790ba [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: bitcoin/bitcoin#25487 (comment) ACKs for top commit: darosior: utACK a9790ba w0xlt: ACK bitcoin/bitcoin@a9790ba Tree-SHA512: 3f2769a917041f12414584f69b2239eef57586f9975869e826f356633fcaf893fde15500619b302e7663de14f3661c6cba22c7524cab5286e715e2c105726521
2 parents dd13d7b + a9790ba commit 01ae8d9

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

test/functional/mempool_persist.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ def run_test(self):
105105
assert_equal(len(self.nodes[0].p2ps), 0)
106106
self.mini_wallet.send_self_transfer(from_node=self.nodes[0])
107107

108+
# Test persistence of prioritisation for transactions not in the mempool.
109+
# Create a tx and prioritise but don't submit until after the restart.
110+
tx_prioritised_not_submitted = self.mini_wallet.create_self_transfer()
111+
self.nodes[0].prioritisetransaction(txid=tx_prioritised_not_submitted['txid'], fee_delta=9999)
112+
108113
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.")
109114
self.stop_nodes()
110115
# Give this node a head-start, so we can be "extra-sure" that it didn't load anything later
@@ -125,6 +130,9 @@ def run_test(self):
125130

126131
self.log.debug('Verify all fields are loaded correctly')
127132
assert_equal(last_entry, self.nodes[0].getmempoolentry(txid=last_txid))
133+
self.nodes[0].sendrawtransaction(tx_prioritised_not_submitted['hex'])
134+
entry_prioritised_before_restart = self.nodes[0].getmempoolentry(txid=tx_prioritised_not_submitted['txid'])
135+
assert_equal(entry_prioritised_before_restart['fees']['base'] + Decimal('0.00009999'), entry_prioritised_before_restart['fees']['modified'])
128136

129137
# Verify accounting of mempool transactions after restart is correct
130138
if self.is_sqlite_compiled():
@@ -143,7 +151,7 @@ def run_test(self):
143151
self.stop_nodes()
144152
self.start_node(0)
145153
assert self.nodes[0].getmempoolinfo()["loaded"]
146-
assert_equal(len(self.nodes[0].getrawmempool()), 6)
154+
assert_equal(len(self.nodes[0].getrawmempool()), 7)
147155

148156
mempooldat0 = os.path.join(self.nodes[0].datadir, self.chain, 'mempool.dat')
149157
mempooldat1 = os.path.join(self.nodes[1].datadir, self.chain, 'mempool.dat')
@@ -153,12 +161,12 @@ def run_test(self):
153161
assert os.path.isfile(mempooldat0)
154162
assert_equal(result0['filename'], mempooldat0)
155163

156-
self.log.debug("Stop nodes, make node1 use mempool.dat from node0. Verify it has 6 transactions")
164+
self.log.debug("Stop nodes, make node1 use mempool.dat from node0. Verify it has 7 transactions")
157165
os.rename(mempooldat0, mempooldat1)
158166
self.stop_nodes()
159167
self.start_node(1, extra_args=["-persistmempool"])
160168
assert self.nodes[1].getmempoolinfo()["loaded"]
161-
assert_equal(len(self.nodes[1].getrawmempool()), 6)
169+
assert_equal(len(self.nodes[1].getrawmempool()), 7)
162170

163171
self.log.debug("Prevent bitcoind from writing mempool.dat to disk. Verify that `savemempool` fails")
164172
# to test the exception we are creating a tmp folder called mempool.dat.new

0 commit comments

Comments
 (0)