feat(testing): Test multiple amounts.

This commit is contained in:
kayibal
2024-10-23 12:50:44 +01:00
parent 163296bceb
commit 378c1c2786

View File

@@ -148,7 +148,8 @@ class TestRunner:
comp_id = expected_component.id.lower()
if comp_id not in components_by_id:
return TestResult.Failed(
f"'{comp_id}' not found in protocol components."
f"'{comp_id}' not found in protocol components. "
f"Available components: {set(components_by_id.keys())}"
)
diff = ProtocolComponentExpectation(
@@ -265,8 +266,9 @@ class TestRunner:
if not pool_state.balances:
raise ValueError(f"Missing balances for pool {pool_id}")
for sell_token, buy_token in itertools.permutations(pool_state.tokens, 2):
for prctg in ["0.001", "0.01", "0.1"]:
# Try to sell 0.1% of the protocol balance
sell_amount = Decimal("0.001") * pool_state.balances[sell_token.address]
sell_amount = Decimal(prctg) * pool_state.balances[sell_token.address]
try:
amount_out, gas_used, _ = pool_state.get_amount_out(
sell_token, sell_amount, buy_token
@@ -277,7 +279,7 @@ class TestRunner:
)
except Exception as e:
print(
f"Error simulating get_amount_out for {pool_id}: {sell_token} -> {buy_token}. "
f"Error simulating get_amount_out for {pool_id}: {sell_token} -> {buy_token} at block {block_number}. "
f"Error: {e}"
)
if pool_id not in failed_simulations: