Skip to content

Commit

Permalink
Merge bitcoin#14931: test: mempool_persist: Verify prioritization is …
Browse files Browse the repository at this point in the history
…dumped correctly

fa30a0e test: mempool_persist: Verify prioritization is dumped correctly (MarcoFalke)

Pull request description:

Tree-SHA512: ef39c470cd418443741b55e9765ee84e0a87a44e7756f88dea86df9b4d37a121a4fbcb97976fbe4693692691650fb1196093b7dadd3922359eb4720845d28f05
  • Loading branch information
MarcoFalke authored and UdjinM6 committed Jul 5, 2021
1 parent 84e5945 commit 0520716
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion test/functional/mempool_persist.py
Expand Up @@ -41,6 +41,7 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *


class MempoolPersistTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 3
Expand All @@ -56,14 +57,21 @@ def run_test(self):

self.log.debug("Send 5 transactions from node2 (to its own address)")
for i in range(5):
self.nodes[2].sendtoaddress(self.nodes[2].getnewaddress(), Decimal("10"))
last_txid = self.nodes[2].sendtoaddress(self.nodes[2].getnewaddress(), Decimal("10"))
node2_balance = self.nodes[2].getbalance()
self.sync_all()

self.log.debug("Verify that node0 and node1 have 5 transactions in their mempools")
assert_equal(len(self.nodes[0].getrawmempool()), 5)
assert_equal(len(self.nodes[1].getrawmempool()), 5)

self.log.debug("Prioritize a transaction on node0")
fees = self.nodes[0].getmempoolentry(txid=last_txid)['fees']
assert_equal(fees['base'], fees['modified'])
self.nodes[0].prioritisetransaction(txid=last_txid, fee_delta=1000)
fees = self.nodes[0].getmempoolentry(txid=last_txid)['fees']
assert_equal(fees['base'] + Decimal('0.00001000'), fees['modified'])

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()
# Give this node a head-start, so we can be "extra-sure" that it didn't load anything later
Expand All @@ -77,6 +85,10 @@ def run_test(self):
# 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)

self.log.debug('Verify prioritization is loaded correctly')
fees = self.nodes[0].getmempoolentry(txid=last_txid)['fees']
assert_equal(fees['base'] + Decimal('0.00001000'), fees['modified'])

# Verify accounting of mempool transactions after restart is correct
self.nodes[2].syncwithvalidationinterfacequeue() # Flush mempool to wallet
assert_equal(node2_balance, self.nodes[2].getbalance())
Expand Down

0 comments on commit 0520716

Please sign in to comment.