aboutsummaryrefslogtreecommitdiff
path: root/test/functional/rpc_blockchain.py
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2021-07-21 17:05:01 +0200
committerJon Atack <jon@atack.com>2021-07-21 17:38:19 +0200
commit0a9129c588ab016eb0453b40a0cae918ca4aa6a2 (patch)
treedf87c026800a28bf29e152c55bf178387ef714fb /test/functional/rpc_blockchain.py
parenta3791da0e80ab35e862989373f033e5be4dff26b (diff)
downloadbitcoin-0a9129c588ab016eb0453b40a0cae918ca4aa6a2.tar.xz
test: assert on the value of getblockchaininfo#time
Diffstat (limited to 'test/functional/rpc_blockchain.py')
-rwxr-xr-xtest/functional/rpc_blockchain.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py
index f7290ff229..01f5ce7eb0 100755
--- a/test/functional/rpc_blockchain.py
+++ b/test/functional/rpc_blockchain.py
@@ -49,6 +49,10 @@ from test_framework.util import (
from test_framework.wallet import MiniWallet
+TIME_RANGE_STEP = 600 # ten-minute steps
+TIME_RANGE_END = TIME_GENESIS_BLOCK + 200 * TIME_RANGE_STEP
+
+
class BlockchainTest(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
@@ -71,9 +75,8 @@ class BlockchainTest(BitcoinTestFramework):
assert self.nodes[0].verifychain(4, 0)
def mine_chain(self):
- self.log.info('Create some old blocks')
- for t in range(TIME_GENESIS_BLOCK, TIME_GENESIS_BLOCK + 200 * 600, 600):
- # ten-minute steps from genesis block time
+ self.log.info("Generate 200 blocks after the genesis block in ten-minute steps")
+ for t in range(TIME_GENESIS_BLOCK, TIME_RANGE_END, TIME_RANGE_STEP):
self.nodes[0].setmocktime(t)
self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_P2WSH_OP_TRUE)
assert_equal(self.nodes[0].getblockchaininfo()['blocks'], 200)
@@ -99,7 +102,7 @@ class BlockchainTest(BitcoinTestFramework):
]
res = self.nodes[0].getblockchaininfo()
- assert isinstance(res['time'], int)
+ assert_equal(res['time'], TIME_RANGE_END - TIME_RANGE_STEP)
# result should have these additional pruning keys if manual pruning is enabled
assert_equal(sorted(res.keys()), sorted(['pruneheight', 'automatic_pruning'] + keys))