fix(test runner): fix how we check balances and stout full buffer
This commit is contained in:
@@ -98,14 +98,22 @@ class TestRunner:
|
|||||||
return TestResult.Failed(
|
return TestResult.Failed(
|
||||||
f"Value mismatch for key '{key}': {value} != {component[key]}"
|
f"Value mismatch for key '{key}': {value} != {component[key]}"
|
||||||
)
|
)
|
||||||
for state in protocol_states["states"]:
|
|
||||||
for token, balance in state["balances"].items():
|
|
||||||
node_balance = get_token_balance(token,comp_id,stop_block)
|
|
||||||
tycho_balance = int(balance,16)
|
|
||||||
if node_balance != tycho_balance:
|
|
||||||
return TestResult.Failed(f"Balance mismatch for {comp_id}:{token} at block {stop_block}: got {node_balance} from rpc call and {tycho_balance} from Substreams")
|
|
||||||
return TestResult.Passed()
|
|
||||||
|
|
||||||
|
for component in protocol_components["protocol_components"]:
|
||||||
|
comp_id = component["id"].lower()
|
||||||
|
for token in component["tokens"]:
|
||||||
|
token_lower = token.lower()
|
||||||
|
state = next((s for s in protocol_states["states"] if s["component_id"].lower() == comp_id), None)
|
||||||
|
if state:
|
||||||
|
balance_hex = state["balances"].get(token_lower, "0x0")
|
||||||
|
else:
|
||||||
|
balance_hex = "0x0"
|
||||||
|
|
||||||
|
node_balance = get_token_balance(token, comp_id, stop_block)
|
||||||
|
tycho_balance = int(balance_hex, 16)
|
||||||
|
if node_balance != tycho_balance:
|
||||||
|
return TestResult.Failed(f"Balance mismatch for {comp_id}:{token} at block {stop_block}: got {node_balance} from rpc call and {tycho_balance} from Substreams")
|
||||||
|
return TestResult.Passed()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return TestResult.Failed(str(e))
|
return TestResult.Failed(str(e))
|
||||||
|
|
||||||
|
|||||||
@@ -41,23 +41,23 @@ class TychoRunner:
|
|||||||
str(start_block),
|
str(start_block),
|
||||||
"--stop-block",
|
"--stop-block",
|
||||||
str(end_block + 2),
|
str(end_block + 2),
|
||||||
], # TODO: +2 is a hack to make up for the cache in the index side.
|
], # +2 is to make up for the cache in the index side.
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
text=True,
|
text=True,
|
||||||
bufsize=1,
|
bufsize=1,
|
||||||
env=env,
|
env=env,
|
||||||
)
|
)
|
||||||
if self.with_binary_logs:
|
|
||||||
with process.stdout:
|
|
||||||
for line in iter(process.stdout.readline, ""):
|
|
||||||
if line:
|
|
||||||
print(line.strip())
|
|
||||||
|
|
||||||
with process.stderr:
|
with process.stdout:
|
||||||
for line in iter(process.stderr.readline, ""):
|
for line in iter(process.stdout.readline, ""):
|
||||||
if line:
|
if line and self.with_binary_logs:
|
||||||
print(line.strip())
|
print(line.strip())
|
||||||
|
|
||||||
|
with process.stderr:
|
||||||
|
for line in iter(process.stderr.readline, ""):
|
||||||
|
if line and self.with_binary_logs:
|
||||||
|
print(line.strip())
|
||||||
|
|
||||||
process.wait()
|
process.wait()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user