Skip to content

Commit 1111170

Browse files
author
MarcoFalke
committed
test: mempool entry time is persisted
Also, remove the now unused "Mine a single block to get out of IBD". This was fixed in commit 1111aec.
1 parent 7d4bc60 commit 1111170

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

test/functional/mempool_persist.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,15 @@
3737
"""
3838
from decimal import Decimal
3939
import os
40+
import time
4041

4142
from test_framework.test_framework import BitcoinTestFramework
42-
from test_framework.util import assert_equal, assert_raises_rpc_error, wait_until
43+
from test_framework.util import (
44+
assert_equal,
45+
assert_greater_than_or_equal,
46+
assert_raises_rpc_error,
47+
wait_until,
48+
)
4349

4450

4551
class MempoolPersistTest(BitcoinTestFramework):
@@ -51,18 +57,13 @@ def skip_test_if_missing_module(self):
5157
self.skip_if_no_wallet()
5258

5359
def run_test(self):
54-
chain_height = self.nodes[0].getblockcount()
55-
assert_equal(chain_height, 200)
56-
57-
self.log.debug("Mine a single block to get out of IBD")
58-
self.nodes[0].generate(1)
59-
self.sync_all()
60-
6160
self.log.debug("Send 5 transactions from node2 (to its own address)")
61+
tx_creation_time_lower = int(time.time())
6262
for i in range(5):
6363
last_txid = self.nodes[2].sendtoaddress(self.nodes[2].getnewaddress(), Decimal("10"))
6464
node2_balance = self.nodes[2].getbalance()
6565
self.sync_all()
66+
tx_creation_time_higher = int(time.time())
6667

6768
self.log.debug("Verify that node0 and node1 have 5 transactions in their mempools")
6869
assert_equal(len(self.nodes[0].getrawmempool()), 5)
@@ -75,6 +76,10 @@ def run_test(self):
7576
fees = self.nodes[0].getmempoolentry(txid=last_txid)['fees']
7677
assert_equal(fees['base'] + Decimal('0.00001000'), fees['modified'])
7778

79+
tx_creation_time = self.nodes[0].getmempoolentry(txid=last_txid)['time']
80+
assert_greater_than_or_equal(tx_creation_time, tx_creation_time_lower)
81+
assert_greater_than_or_equal(tx_creation_time_higher, tx_creation_time)
82+
7883
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.")
7984
self.stop_nodes()
8085
# Give this node a head-start, so we can be "extra-sure" that it didn't load anything later
@@ -93,6 +98,9 @@ def run_test(self):
9398
fees = self.nodes[0].getmempoolentry(txid=last_txid)['fees']
9499
assert_equal(fees['base'] + Decimal('0.00001000'), fees['modified'])
95100

101+
self.log.debug('Verify time is loaded correctly')
102+
assert_equal(tx_creation_time, self.nodes[0].getmempoolentry(txid=last_txid)['time'])
103+
96104
# Verify accounting of mempool transactions after restart is correct
97105
self.nodes[2].syncwithvalidationinterfacequeue() # Flush mempool to wallet
98106
assert_equal(node2_balance, self.nodes[2].getbalance())

0 commit comments

Comments
 (0)