Merge pull request #93 from propeller-heads/ah/test-multiple-amounts
feat(testing): Test multiple amounts.
This commit is contained in:
@@ -74,9 +74,12 @@ interface ISwapAdapter is ISwapAdapterTypes {
|
|||||||
/// @param poolId The ID of the trading pool.
|
/// @param poolId The ID of the trading pool.
|
||||||
/// @param sellToken The token being sold.
|
/// @param sellToken The token being sold.
|
||||||
/// @param buyToken The token being bought.
|
/// @param buyToken The token being bought.
|
||||||
/// @return limits An array of size two indicating the limit amount for the sell
|
/// @return limits An array of size two indicating the limit amount for the
|
||||||
/// token (maximum the pool is willing to buy in sell token) as well as the limit
|
/// sell
|
||||||
/// amount of the buy token (maximum the pool is willing to sell in buy token).
|
/// token (maximum the pool is willing to buy in sell token) as well as
|
||||||
|
/// the limit
|
||||||
|
/// amount of the buy token (maximum the pool is willing to sell in buy
|
||||||
|
/// token).
|
||||||
function getLimits(bytes32 poolId, address sellToken, address buyToken)
|
function getLimits(bytes32 poolId, address sellToken, address buyToken)
|
||||||
external
|
external
|
||||||
returns (uint256[] memory limits);
|
returns (uint256[] memory limits);
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ class TestRunner:
|
|||||||
if comp_id not in components_by_id:
|
if comp_id not in components_by_id:
|
||||||
return TestResult.Failed(
|
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(
|
diff = ProtocolComponentExpectation(
|
||||||
@@ -265,8 +266,9 @@ class TestRunner:
|
|||||||
if not pool_state.balances:
|
if not pool_state.balances:
|
||||||
raise ValueError(f"Missing balances for pool {pool_id}")
|
raise ValueError(f"Missing balances for pool {pool_id}")
|
||||||
for sell_token, buy_token in itertools.permutations(pool_state.tokens, 2):
|
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
|
# 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:
|
try:
|
||||||
amount_out, gas_used, _ = pool_state.get_amount_out(
|
amount_out, gas_used, _ = pool_state.get_amount_out(
|
||||||
sell_token, sell_amount, buy_token
|
sell_token, sell_amount, buy_token
|
||||||
@@ -277,7 +279,7 @@ class TestRunner:
|
|||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(
|
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}"
|
f"Error: {e}"
|
||||||
)
|
)
|
||||||
if pool_id not in failed_simulations:
|
if pool_id not in failed_simulations:
|
||||||
|
|||||||
Reference in New Issue
Block a user