diff --git a/test/functional/mempool_persist.py b/test/functional/mempool_persist.py --- a/test/functional/mempool_persist.py +++ b/test/functional/mempool_persist.py @@ -37,12 +37,14 @@ """ from decimal import Decimal import os +import time from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( assert_equal, + assert_greater_than_or_equal, assert_raises_rpc_error, - wait_until + wait_until, ) @@ -55,19 +57,14 @@ self.skip_if_no_wallet() def run_test(self): - chain_height = self.nodes[0].getblockcount() - assert_equal(chain_height, 200) - - self.log.debug("Mine a single block to get out of IBD") - self.nodes[0].generate(1) - self.sync_all() - self.log.debug("Send 5 transactions from node2 (to its own address)") + tx_creation_time_lower = int(time.time()) for i in range(5): last_txid = self.nodes[2].sendtoaddress( self.nodes[2].getnewaddress(), Decimal("10")) node2_balance = self.nodes[2].getbalance() self.sync_all() + tx_creation_time_higher = int(time.time()) self.log.debug( "Verify that node0 and node1 have 5 transactions in their mempools") @@ -81,6 +78,11 @@ fees = self.nodes[0].getmempoolentry(txid=last_txid)['fees'] assert_equal(fees['base'] + Decimal('0.00001000'), fees['modified']) + tx_creation_time = self.nodes[0].getmempoolentry(txid=last_txid)[ + 'time'] + assert_greater_than_or_equal(tx_creation_time, tx_creation_time_lower) + assert_greater_than_or_equal(tx_creation_time_higher, tx_creation_time) + 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 " @@ -104,6 +106,12 @@ fees = self.nodes[0].getmempoolentry(txid=last_txid)['fees'] assert_equal(fees['base'] + Decimal('0.00001000'), fees['modified']) + self.log.debug('Verify time is loaded correctly') + assert_equal( + tx_creation_time, + self.nodes[0].getmempoolentry( + txid=last_txid)['time']) + # Verify accounting of mempool transactions after restart is correct # Flush mempool to wallet self.nodes[2].syncwithvalidationinterfacequeue()