Skip to content

Commit 0a9129c

Browse files
committed
test: assert on the value of getblockchaininfo#time
1 parent a3791da commit 0a9129c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

test/functional/rpc_blockchain.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
from test_framework.wallet import MiniWallet
5050

5151

52+
TIME_RANGE_STEP = 600 # ten-minute steps
53+
TIME_RANGE_END = TIME_GENESIS_BLOCK + 200 * TIME_RANGE_STEP
54+
55+
5256
class BlockchainTest(BitcoinTestFramework):
5357
def set_test_params(self):
5458
self.setup_clean_chain = True
@@ -71,9 +75,8 @@ def run_test(self):
7175
assert self.nodes[0].verifychain(4, 0)
7276

7377
def mine_chain(self):
74-
self.log.info('Create some old blocks')
75-
for t in range(TIME_GENESIS_BLOCK, TIME_GENESIS_BLOCK + 200 * 600, 600):
76-
# ten-minute steps from genesis block time
78+
self.log.info("Generate 200 blocks after the genesis block in ten-minute steps")
79+
for t in range(TIME_GENESIS_BLOCK, TIME_RANGE_END, TIME_RANGE_STEP):
7780
self.nodes[0].setmocktime(t)
7881
self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_P2WSH_OP_TRUE)
7982
assert_equal(self.nodes[0].getblockchaininfo()['blocks'], 200)
@@ -99,7 +102,7 @@ def _test_getblockchaininfo(self):
99102
]
100103
res = self.nodes[0].getblockchaininfo()
101104

102-
assert isinstance(res['time'], int)
105+
assert_equal(res['time'], TIME_RANGE_END - TIME_RANGE_STEP)
103106

104107
# result should have these additional pruning keys if manual pruning is enabled
105108
assert_equal(sorted(res.keys()), sorted(['pruneheight', 'automatic_pruning'] + keys))

0 commit comments

Comments
 (0)