Skip to content

Commit 368eebb

Browse files
Merge #6921: test: wait for new trigger for up to 1s while mining in maturity window
6a13041 test: generate block by batches when it's not important to go one-by-one (Konstantin Akimov) f56ce76 test: wait for new trigger for up to 1s while mining in maturity window (UdjinM6) Pull request description: ## Issue being fixed or feature implemented Mining too fast can result in creation of multiple triggers none of which is going to win - too many "no" votes from competing mns for `AbsoluteYesCount` to go above 0. ## What was done? Wait for new trigger for up to 1s while mining in maturity window. If no winning trigger was found in 1s we move to the next block. When there is a winning trigger `wait_until` is basically instant. ## How Has This Been Tested? Run multiple `feature_governance.py` jobs in parallel. develop: some jobs fail on `wait_until(lambda: have_trigger_for_height(...))` this PR: should be no to little difference in test duration times comparing to develop with no failures on `wait_until(lambda: have_trigger_for_height(...))` ## Breaking Changes ## Checklist: - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: knst: re-ACK 6a13041 Tree-SHA512: 22317d5097a2836febfddcffa45eb2ebe284ec34dc3b9541e796fb2f99afac4990c2381b28a59c71c90a5fbd386a70f23d4a0cd9d34b55717a4a30538daf6895
2 parents 2d84c2b + 6a13041 commit 368eebb

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

test/functional/feature_governance.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,18 @@ def sync_gov(node):
349349
assert_equal(self.nodes[0].gobject("list", "valid", "triggers")[isolated_trigger_hash]['NoCount'], self.mn_count - 1)
350350

351351
block_count = self.nodes[0].getblockcount()
352-
n = sb_cycle - block_count % sb_cycle
352+
n = sb_immaturity_window - block_count % sb_cycle
353+
assert n > 0
353354

354-
self.log.info("Move remaining n blocks until the next Superblock")
355-
for _ in range(n - 1):
355+
self.log.info("Move remaining n blocks until the next maturity window")
356+
self.bump_mocktime(n)
357+
self.generate(self.nodes[0], n, sync_fun=self.sync_blocks())
358+
359+
self.log.info("Move inside maturity window until the next Superblock")
360+
for _ in range(sb_maturity_window - 1):
356361
self.bump_mocktime(1)
357362
self.generate(self.nodes[0], 1, sync_fun=self.sync_blocks())
363+
self.wait_until(lambda: have_trigger_for_height(self.nodes, 180), timeout=1, do_assert=False)
358364
self.log.info("Wait for new trigger and votes")
359365
self.wait_until(lambda: have_trigger_for_height(self.nodes, 180))
360366
self.log.info("Mine superblock")
@@ -365,11 +371,14 @@ def sync_gov(node):
365371

366372
self.log.info("Mine and check a couple more superblocks")
367373
for i in range(2):
368-
for _ in range(sb_cycle - 1):
374+
sb_block_height = 180 + (i + 1) * sb_cycle
375+
self.bump_mocktime(sb_immaturity_window)
376+
self.generate(self.nodes[0], sb_immaturity_window, sync_fun=self.sync_blocks())
377+
for _ in range(sb_maturity_window - 1):
369378
self.bump_mocktime(1)
370379
self.generate(self.nodes[0], 1, sync_fun=self.sync_blocks())
380+
self.wait_until(lambda: have_trigger_for_height(self.nodes, sb_block_height), timeout=1, do_assert=False)
371381
# Wait for new trigger and votes
372-
sb_block_height = 180 + (i + 1) * sb_cycle
373382
self.wait_until(lambda: have_trigger_for_height(self.nodes, sb_block_height))
374383
# Mine superblock
375384
self.bump_mocktime(1)

0 commit comments

Comments
 (0)