Skip to content

Commit

Permalink
fix: intermittent failures in feature_governance.py
Browse files Browse the repository at this point in the history
  • Loading branch information
UdjinM6 committed Feb 11, 2024
1 parent d9c549e commit 903c617
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions test/functional/feature_governance.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@ def check_superblock(self):

assert_equal(payments_found, 2)

def have_trigger_for_height(self, sb_block_height):
count = 0
for node in self.nodes:
valid_triggers = node.gobject("list", "valid", "triggers")
valid_triggers_list = list(valid_triggers.values())
for i in range(len(valid_triggers)):
if json.loads(valid_triggers_list[i]["DataString"])["event_block_height"] != sb_block_height:
continue
if valid_triggers_list[i]['AbsoluteYesCount'] > 0:
count = count + 1
break
return count == len(self.nodes)

def run_test(self):
map_vote_outcomes = {
0: "none",
Expand Down Expand Up @@ -267,6 +280,11 @@ def sync_gov(node):
self.bump_mocktime(1)
return node.mnsync("status")["IsSynced"]

# make sure isolated node is fully synced at this point
self.wait_until(lambda: sync_gov(isolated))
# let all fulfilled requests expire for re-sync to work correctly
self.bump_mocktime(5 * 60)

for node in self.nodes:
# Force sync
node.mnsync("reset")
Expand Down Expand Up @@ -317,20 +335,33 @@ def sync_gov(node):
n = sb_cycle - block_count % sb_cycle

# Move remaining n blocks until the next Superblock
for _ in range(n):
for _ in range(n - 1):
self.nodes[0].generate(1)
self.bump_mocktime(1)
self.sync_blocks()
# Wait for new trigger and votes
self.wait_until(lambda: self.have_trigger_for_height(260), timeout=5)
# Mine superblock
self.nodes[0].generate(1)
self.bump_mocktime(1)
self.sync_blocks()
assert_equal(self.nodes[0].getblockcount(), 260)
assert_equal(self.nodes[0].getblockchaininfo()["softforks"]["v20"]["bip9"]["status"], "active")

# Mine and check a couple more superblocks
for i in range(2):
for _ in range(20):
for _ in range(sb_cycle - 1):
self.nodes[0].generate(1)
self.bump_mocktime(1)
self.sync_blocks()
assert_equal(self.nodes[0].getblockcount(), 260 + (i + 1) * 20)
# Wait for new trigger and votes
sb_block_height = 260 + (i + 1) * sb_cycle
self.wait_until(lambda: self.have_trigger_for_height(sb_block_height), timeout=5)
# Mine superblock
self.nodes[0].generate(1)
self.bump_mocktime(1)
self.sync_blocks()
assert_equal(self.nodes[0].getblockcount(), sb_block_height)
assert_equal(self.nodes[0].getblockchaininfo()["softforks"]["v20"]["bip9"]["status"], "active")
self.check_superblockbudget(True)
self.check_superblock()
Expand Down

0 comments on commit 903c617

Please sign in to comment.