aboutsummaryrefslogtreecommitdiff
path: root/test/functional/mempool_persist.py
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@protonmail.com>2019-10-02 16:55:03 +0200
committerWladimir J. van der Laan <laanwj@protonmail.com>2019-10-02 16:55:36 +0200
commitccaef6c28b1997bd40faad2e1c66e22cdda11edc (patch)
treebec38b34fad46cea3a4102299a38ae6032dd7456 /test/functional/mempool_persist.py
parent19ba43ae2d00d00fde280b43fba4af98d863f547 (diff)
parentfaec689bed7a5b66e2a7675853d10205b933cec8 (diff)
Merge #16908: txmempool: Make entry time type-safe (std::chrono)
faec689bed7a5b66e2a7675853d10205b933cec8 txmempool: Make entry time type-safe (std::chrono) (MarcoFalke) faaa1f01daba94b021ca77515266a16d27f0364e util: Add count_seconds time helper (MarcoFalke) 1111170f2f0141084b5b4ed565b2f07eba48599a test: mempool entry time is persisted (MarcoFalke) Pull request description: This changes the type of the entry time of txs into the mempool from `int64_t` to `std::chrono::seconds`. The benefits: * Documents the type for developers * Type violations result in compile errors * After compilation, the two are equivalent (at no run time cost) ACKs for top commit: ajtowns: utACK faec689bed7a5b66e2a7675853d10205b933cec8 laanwj: ACK faec689bed7a5b66e2a7675853d10205b933cec8 Tree-SHA512: d958e058755d1a1d54cef536a8b30a11cc502b7df0d6ecf84a0ab1d38bc8105a67668a99cd5087a444f6de2421238111c5fca133cdf8e2e2273cb12cb6957845
Diffstat (limited to 'test/functional/mempool_persist.py')
-rwxr-xr-xtest/functional/mempool_persist.py24
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())