Skip to content

Commit 6991337

Browse files
UdjinM6knst
andauthored
fix: intermittent failures in feature_governance.py (dashpay#5868)
## Issue being fixed or feature implemented Should fix failures like https://gitlab.com/dashpay/dash/-/jobs/6107697452 ## What was done? See inline comments ## How Has This Been Tested? Run lots of `feature_governance.py` in parallel multiple times ## Breaking Changes n/a ## Checklist: - [x] I have performed a self-review of my own code - [x] 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 - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ --------- Co-authored-by: Konstantin Akimov <[email protected]>
1 parent 2f65282 commit 6991337

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

test/functional/feature_governance.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ def check_superblock(self):
7777

7878
assert_equal(payments_found, 2)
7979

80+
def have_trigger_for_height(self, sb_block_height):
81+
count = 0
82+
for node in self.nodes:
83+
valid_triggers = node.gobject("list", "valid", "triggers")
84+
for trigger in list(valid_triggers.values()):
85+
if json.loads(trigger["DataString"])["event_block_height"] != sb_block_height:
86+
continue
87+
if trigger['AbsoluteYesCount'] > 0:
88+
count = count + 1
89+
break
90+
return count == len(self.nodes)
91+
8092
def run_test(self):
8193
map_vote_outcomes = {
8294
0: "none",
@@ -267,6 +279,11 @@ def sync_gov(node):
267279
self.bump_mocktime(1)
268280
return node.mnsync("status")["IsSynced"]
269281

282+
# make sure isolated node is fully synced at this point
283+
self.wait_until(lambda: sync_gov(isolated))
284+
# let all fulfilled requests expire for re-sync to work correctly
285+
self.bump_mocktime(5 * 60)
286+
270287
for node in self.nodes:
271288
# Force sync
272289
node.mnsync("reset")
@@ -317,20 +334,33 @@ def sync_gov(node):
317334
n = sb_cycle - block_count % sb_cycle
318335

319336
# Move remaining n blocks until the next Superblock
320-
for _ in range(n):
337+
for _ in range(n - 1):
321338
self.nodes[0].generate(1)
322339
self.bump_mocktime(1)
323340
self.sync_blocks()
341+
# Wait for new trigger and votes
342+
self.wait_until(lambda: self.have_trigger_for_height(260), timeout=5)
343+
# Mine superblock
344+
self.nodes[0].generate(1)
345+
self.bump_mocktime(1)
346+
self.sync_blocks()
324347
assert_equal(self.nodes[0].getblockcount(), 260)
325348
assert_equal(self.nodes[0].getblockchaininfo()["softforks"]["v20"]["bip9"]["status"], "active")
326349

327350
# Mine and check a couple more superblocks
328351
for i in range(2):
329-
for _ in range(20):
352+
for _ in range(sb_cycle - 1):
330353
self.nodes[0].generate(1)
331354
self.bump_mocktime(1)
332355
self.sync_blocks()
333-
assert_equal(self.nodes[0].getblockcount(), 260 + (i + 1) * 20)
356+
# Wait for new trigger and votes
357+
sb_block_height = 260 + (i + 1) * sb_cycle
358+
self.wait_until(lambda: self.have_trigger_for_height(sb_block_height), timeout=5)
359+
# Mine superblock
360+
self.nodes[0].generate(1)
361+
self.bump_mocktime(1)
362+
self.sync_blocks()
363+
assert_equal(self.nodes[0].getblockcount(), sb_block_height)
334364
assert_equal(self.nodes[0].getblockchaininfo()["softforks"]["v20"]["bip9"]["status"], "active")
335365
self.check_superblockbudget(True)
336366
self.check_superblock()

0 commit comments

Comments
 (0)