Skip to content

Commit cbcd3f9

Browse files
MacroFakeknst
authored andcommitted
Merge 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#25487 (comment) ACKs for top commit: darosior: utACK a9790ba w0xlt: ACK bitcoin@a9790ba Tree-SHA512: 3f2769a917041f12414584f69b2239eef57586f9975869e826f356633fcaf893fde15500619b302e7663de14f3661c6cba22c7524cab5286e715e2c105726521
1 parent b52fabb commit cbcd3f9

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
@@ -103,6 +103,11 @@ def run_test(self):
103103
assert_equal(len(self.nodes[0].p2ps), 0)
104104
self.mini_wallet.send_self_transfer(from_node=self.nodes[0])
105105

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

124129
self.log.debug('Verify all fields are loaded correctly')
125130
assert_equal(last_entry, self.nodes[0].getmempoolentry(txid=last_txid))
131+
self.nodes[0].sendrawtransaction(tx_prioritised_not_submitted['hex'])
132+
entry_prioritised_before_restart = self.nodes[0].getmempoolentry(txid=tx_prioritised_not_submitted['txid'])
133+
assert_equal(entry_prioritised_before_restart['fees']['base'] + Decimal('0.00009999'), entry_prioritised_before_restart['fees']['modified'])
126134

127135
# Verify accounting of mempool transactions after restart is correct
128136
if self.is_sqlite_compiled():
@@ -141,7 +149,7 @@ def run_test(self):
141149
self.stop_nodes()
142150
self.start_node(0)
143151
assert self.nodes[0].getmempoolinfo()["loaded"]
144-
assert_equal(len(self.nodes[0].getrawmempool()), 6)
152+
assert_equal(len(self.nodes[0].getrawmempool()), 7)
145153

146154
mempooldat0 = os.path.join(self.nodes[0].datadir, self.chain, 'mempool.dat')
147155
mempooldat1 = os.path.join(self.nodes[1].datadir, self.chain, 'mempool.dat')
@@ -151,12 +159,12 @@ def run_test(self):
151159
assert os.path.isfile(mempooldat0)
152160
assert_equal(result0['filename'], mempooldat0)
153161

154-
self.log.debug("Stop nodes, make node1 use mempool.dat from node0. Verify it has 6 transactions")
162+
self.log.debug("Stop nodes, make node1 use mempool.dat from node0. Verify it has 7 transactions")
155163
os.rename(mempooldat0, mempooldat1)
156164
self.stop_nodes()
157165
self.start_node(1, extra_args=["-persistmempool"])
158166
assert self.nodes[1].getmempoolinfo()["loaded"]
159-
assert_equal(len(self.nodes[1].getrawmempool()), 6)
167+
assert_equal(len(self.nodes[1].getrawmempool()), 7)
160168

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

0 commit comments

Comments
 (0)