Fix hexbytes comparison, fix attribute access

This commit is contained in:
Thales Lima
2024-08-07 05:13:14 +02:00
committed by tvinagre
parent cb6e997375
commit 5238141771
2 changed files with 15 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
import argparse
from runner import TestRunner
from .runner import TestRunner
def main() -> None:

View File

@@ -140,7 +140,17 @@ class TestRunner:
return TestResult.Failed(
f"Missing '{key}' in component '{comp_id}'."
)
if isinstance(value, list):
if key == "tokens":
if set(map(HexBytes, value)) != set(component[key]):
return TestResult.Failed(
f"Token mismatch for key '{key}': {value} != {component[key]}"
)
elif key == "creation_tx":
if HexBytes(value) != component[key]:
return TestResult.Failed(
f"Creation tx mismatch for key '{key}': {value} != {component[key]}"
)
elif isinstance(value, list):
if set(map(str.lower, value)) != set(
map(str.lower, component[key])
):
@@ -165,10 +175,10 @@ class TestRunner:
None,
)
if state:
balance_hex = state["balances"].get(token, "0x0")
balance_hex = state.balances.get(token, "0x0")
else:
balance_hex = "0x0"
tycho_balance = int(balance_hex, 16)
tycho_balance = int(balance_hex)
token_balances[comp_id][token] = tycho_balance
if self.config["skip_balance_check"] is not True:
@@ -227,7 +237,7 @@ class TestRunner:
)
failed_simulations: dict[str, list[SimulationFailure]] = dict()
for protocol in protocol_type_names:
for _ in protocol_type_names:
adapter_contract = os.path.join(
self.adapters_src,
"out",