Skip to content

Commit

Permalink
test: assert on the value of getblockchaininfo#time
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatack committed Jul 21, 2021
1 parent a3791da commit 0a9129c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions test/functional/rpc_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
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
Expand All @@ -71,9 +75,8 @@ def run_test(self):
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)
Expand All @@ -99,7 +102,7 @@ def _test_getblockchaininfo(self):
]
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))
Expand Down

0 comments on commit 0a9129c

Please sign in to comment.