Skip to content

Commit

Permalink
test: add -maxtipage test for the maximum allowable value
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesob committed Nov 14, 2022
1 parent a451e83 commit e4be0e9
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions test/functional/feature_maxtipage.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,24 @@ def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 2

def test_maxtipage(self, maxtipage, set_parameter=True):
def test_maxtipage(self, maxtipage, set_parameter=True, test_deltas=True):
node_miner = self.nodes[0]
node_ibd = self.nodes[1]

self.restart_node(1, [f'-maxtipage={maxtipage}'] if set_parameter else None)
self.connect_nodes(0, 1)

# tips older than maximum age -> stay in IBD
cur_time = int(time.time())
node_ibd.setmocktime(cur_time)
for delta in [5, 4, 3, 2, 1]:
node_miner.setmocktime(cur_time - maxtipage - delta)
self.generate(node_miner, 1)
assert_equal(node_ibd.getblockchaininfo()['initialblockdownload'], True)

if test_deltas:
# tips older than maximum age -> stay in IBD
node_ibd.setmocktime(cur_time)
for delta in [5, 4, 3, 2, 1]:
node_miner.setmocktime(cur_time - maxtipage - delta)
self.generate(node_miner, 1)
assert_equal(node_ibd.getblockchaininfo()['initialblockdownload'], True)

# tip within maximum age -> leave IBD
node_miner.setmocktime(cur_time - maxtipage)
node_miner.setmocktime(max(cur_time - maxtipage, 0))
self.generate(node_miner, 1)
assert_equal(node_ibd.getblockchaininfo()['initialblockdownload'], False)

Expand All @@ -51,6 +52,10 @@ def run_test(self):
self.log.info(f"Test IBD with maximum tip age of {hours} hours (-maxtipage={maxtipage}).")
self.test_maxtipage(maxtipage)

max_long_val = 9223372036854775807
self.log.info(f"Test IBD with highest allowable maximum tip age ({max_long_val}).")
self.test_maxtipage(max_long_val, test_deltas=False)


if __name__ == '__main__':
MaxTipAgeTest().main()

0 comments on commit e4be0e9

Please sign in to comment.