Skip to content

Instantly share code, notes, and snippets.

@theStack
Created May 29, 2023 00:47
Show Gist options
  • Save theStack/cb5a08583b0a7376c2155b21a10dbbb7 to your computer and use it in GitHub Desktop.
Save theStack/cb5a08583b0a7376c2155b21a10dbbb7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import re
import requests
ci_log = requests.get('https://api.cirrus-ci.com/v1/task/4776911524593664/logs/ci.log').content.decode()
generated_block_hashes = []
for match in re.compile('node0.*BlockChecked.*block hash=([a-z0-9]+) ').finditer(ci_log):
generated_block_hashes.append(match.group(1))
generated_block_hashes.pop(0) # first block (height 200) is generated by test framework, so ignore it
received_block_hashes = []
for match in re.compile('node2.*received block ([a-z0-9]+) |node2.*reconstructed block ([a-z0-9]+) ').finditer(ci_log):
received_hash = match.group(1)
reconstructed_hash = match.group(2)
received_block_hashes.append((received_hash, "received") if received_hash is not None else (reconstructed_hash, "reconstructed"))
assert len(generated_block_hashes) == len(received_block_hashes)
for i in range(len(received_block_hashes)):
expected_height = i + 201
received_block_hash, recv_or_reconstr = received_block_hashes[i]
if generated_block_hashes[i] == received_block_hash:
print(f"node2 {recv_or_reconstr} block {expected_height}, OK.")
else:
received_height = generated_block_hashes.index(received_block_hash) + 201
print(f"!!! expected to receive/reconstruct block {expected_height}, but {recv_or_reconstr} block {received_height} !!!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment