diff options
Diffstat (limited to 'test/functional')
-rwxr-xr-x | test/functional/mempool_persist.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/test/functional/mempool_persist.py b/test/functional/mempool_persist.py index bb0169ee52..398fdeb326 100755 --- a/test/functional/mempool_persist.py +++ b/test/functional/mempool_persist.py @@ -37,9 +37,15 @@ Test is as follows: """ from decimal import Decimal import os +import time from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, assert_raises_rpc_error, wait_until +from test_framework.util import ( + assert_equal, + assert_greater_than_or_equal, + assert_raises_rpc_error, + wait_until, +) class MempoolPersistTest(BitcoinTestFramework): @@ -51,18 +57,13 @@ class MempoolPersistTest(BitcoinTestFramework): 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") assert_equal(len(self.nodes[0].getrawmempool()), 5) @@ -75,6 +76,10 @@ class MempoolPersistTest(BitcoinTestFramework): 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 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 @@ -93,6 +98,9 @@ class MempoolPersistTest(BitcoinTestFramework): 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 self.nodes[2].syncwithvalidationinterfacequeue() # Flush mempool to wallet assert_equal(node2_balance, self.nodes[2].getbalance()) |