Skip to content

Commit

Permalink
Merge pull request #387 from eosnetworkfoundation/fix-plugin-http-api…
Browse files Browse the repository at this point in the history
…-test

plugin_http_api_test - fix timing issue
  • Loading branch information
heifner authored Jun 16, 2022
2 parents dd9072c + 1745e67 commit 0724f04
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/Node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1388,10 +1388,12 @@ def getSupportedProtocolFeatureDict(self, excludeDisabled=False, excludeUnactiva
break
return protocolFeatureDigestDict

def waitForHeadToAdvance(self, timeout=6):
def waitForHeadToAdvance(self, blocksToAdvance=1, timeout=None):
currentHead = self.getHeadBlockNum()
if timeout is None:
timeout = 6 + blocksToAdvance / 2
def isHeadAdvancing():
return self.getHeadBlockNum() > currentHead
return self.getHeadBlockNum() >= currentHead + blocksToAdvance
return Utils.waitForBool(isHeadAdvancing, timeout)

def waitForLibToAdvance(self, timeout=30):
Expand Down Expand Up @@ -1422,7 +1424,7 @@ def activatePreactivateFeature(self):
self.scheduleProtocolFeatureActivations([preactivateFeatureDigest])

# Wait for the next block to be produced so the scheduled protocol feature is activated
assert self.waitForHeadToAdvance(), "ERROR: TIMEOUT WAITING FOR PREACTIVATE"
assert self.waitForHeadToAdvance(blocksToAdvance=2), print("ERROR: TIMEOUT WAITING FOR PREACTIVATE")

# Return an array of feature digests to be preactivated in a correct order respecting dependencies
# Require producer_api_plugin
Expand All @@ -1449,7 +1451,7 @@ def preactivateProtocolFeatures(self, featureDigests:list):
if trans is None or not trans[0]:
Utils.Print("ERROR: Failed to preactive digest {}".format(digest))
return None
self.waitForHeadToAdvance()
self.waitForHeadToAdvance(blocksToAdvance=2)

# Require PREACTIVATE_FEATURE to be activated and require eosio.bios with preactivate_feature
def preactivateAllBuiltinProtocolFeature(self):
Expand Down

0 comments on commit 0724f04

Please sign in to comment.