Skip to content

Commit

Permalink
Merge pull request #908 from AntelopeIO/gh_848
Browse files Browse the repository at this point in the history
[1.0.3] Test failure: distributed-transactions-if-test
  • Loading branch information
greg7mdp authored Oct 8, 2024
2 parents bc2bee9 + ee12561 commit d52e8cf
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions tests/TestHarness/Node.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,37 +708,39 @@ def countInLog(self, searchStr) -> int:
count += contents.count(searchStr)
return count

# verify only one or two 'Starting block' per block number unless block is restarted
# Verify that we have only one "Starting block" in the log for any block number unless:
# - the block was restarted because it was exhausted,
# - or the second "Starting block" is for a different block time than the first.
# -------------------------------------------------------------------------------------
def verifyStartingBlockMessages(self):
dataDir=Utils.getNodeDataDir(self.nodeId)
files=Node.findStderrFiles(dataDir)
restarting_exhausted_regexp = re.compile(r"Restarting exhausted speculative block #(\d+)")
starting_block_regexp = re.compile(r"Starting block #(\d+) .*(\d\d:\d\d\.\d\d\d) producer")

for f in files:
blockNumbers = set()
duplicateBlockNumbers = set()
threeStartsFound = False
lastRestartBlockNum = 0
blockNumber = 0
notRestartedBlockNumbersAndTimes = {}
duplicateStartFound = False

with open(f, 'r') as file:
for line in file:
match = re.match(r".*Restarting exhausted speculative block #(\d+)", line)
match = restarting_exhausted_regexp.match(line)
if match:
lastRestartBlockNum = match.group(1)
continue
if re.match(r".*unlinkable_block_exception", line):
lastRestartBlockNum = blockNumber
# remove restarted block
notRestartedBlockNumbersAndTimes.pop(match.group(1), None)
continue
match = re.match(r".*Starting block #(\d+)", line)
match = starting_block_regexp.match(line)
if match:
blockNumber = match.group(1)
if blockNumber != lastRestartBlockNum and blockNumber in duplicateBlockNumbers:
print(f"Duplicate Staring block found: {blockNumber} in {f}")
threeStartsFound = True
if blockNumber != lastRestartBlockNum and blockNumber in blockNumbers:
duplicateBlockNumbers.add(blockNumber)
blockNumbers.add(blockNumber)

return not threeStartsFound
blockNumber, time = match.group(1), match.group(2)
if blockNumber in notRestartedBlockNumbersAndTimes and notRestartedBlockNumbersAndTimes[blockNumber] == time:
print(f"Duplicate Starting block found: {blockNumber} in {f}")
duplicateStartFound = True
break
notRestartedBlockNumbersAndTimes[blockNumber] = time
if duplicateStartFound:
break

return not duplicateStartFound

def analyzeProduction(self, specificBlockNum=None, thresholdMs=500):
dataDir=Utils.getNodeDataDir(self.nodeId)
Expand Down

0 comments on commit d52e8cf

Please sign in to comment.