diff --git a/.gitignore b/.gitignore index 3b908fb..6a71539 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,6 @@ substreams/ethereum-template/Cargo.lock .DS_Store tycho-indexer -substreams/my_substream \ No newline at end of file +substreams/my_substream +testing/tycho-client/build/* +testing/tycho-client/*.egg-info \ No newline at end of file diff --git a/substreams/ethereum-curve/test_assets.yaml b/substreams/ethereum-curve/test_assets.yaml index dff8257..6552c25 100644 --- a/substreams/ethereum-curve/test_assets.yaml +++ b/substreams/ethereum-curve/test_assets.yaml @@ -2,6 +2,7 @@ substreams_yaml_path: ./substreams.yaml protocol_type_names: - "curve_pool" adapter_contract: "CurveSwapAdapter.evm.runtime" +skip_balance_check: false tests: - name: test_3pool_creation start_block: 10809470 diff --git a/substreams/ethereum-template/test_assets.yaml b/substreams/ethereum-template/test_assets.yaml index 31edb21..0896e57 100644 --- a/substreams/ethereum-template/test_assets.yaml +++ b/substreams/ethereum-template/test_assets.yaml @@ -1,4 +1,6 @@ substreams_yaml_path: ./substreams.yaml +adapter_contract: "SwapAdapter.evm.runtime" +skip_balance_check: false protocol_type_names: - "type_name_1" - "type_name_2" diff --git a/testing/Dockerfile b/testing/Dockerfile index 42272a4..700cb0a 100644 --- a/testing/Dockerfile +++ b/testing/Dockerfile @@ -5,7 +5,7 @@ FROM --platform=linux/amd64 continuumio/miniconda3:24.4.0-0 WORKDIR /app # Add current directory code to /app in container -ADD ./ /app/testing +ADD . /app/testing RUN chmod +x /app/testing/tycho-indexer diff --git a/testing/README.md b/testing/README.md index 7810b34..eb011e3 100644 --- a/testing/README.md +++ b/testing/README.md @@ -22,7 +22,7 @@ Tests are defined in a `yaml` file. A template can be found at `substreams/ether Each test will index all blocks between `start-block` and `stop-block` and verify that the indexed state matches the expected state. You will also need the EVM Runtime file for the adapter contract. -The script to generate this file is available under `/evm/scripts/buildRuntime.sh`. +The script to generate this file is available under `evm/scripts/buildRuntime.sh`. Please place this Runtime file under the respective `substream` directory inside the `evm` folder. ## Running Tests diff --git a/testing/runner.py b/testing/runner.py index f85dc22..8689f29 100644 --- a/testing/runner.py +++ b/testing/runner.py @@ -135,12 +135,13 @@ class TestRunner: tycho_balance = int(balance_hex, 16) token_balances[comp_id][token_lower] = tycho_balance - node_balance = get_token_balance(token, comp_id, stop_block) - if node_balance != tycho_balance: - return TestResult.Failed( - f"Balance mismatch for {comp_id}:{token} at block {stop_block}: got {node_balance} " - f"from rpc call and {tycho_balance} from Substreams" - ) + if self.config["skip_balance_check"] is not True: + node_balance = get_token_balance(token, comp_id, stop_block) + if node_balance != tycho_balance: + return TestResult.Failed( + f"Balance mismatch for {comp_id}:{token} at block {stop_block}: got {node_balance} " + f"from rpc call and {tycho_balance} from Substreams" + ) contract_states = self.tycho_runner.get_contract_state() simulation_failures = self.simulate_get_amount_out( token_balances, diff --git a/testing/tycho-client/README.md b/testing/tycho-client/README.md index 1871992..2000d45 100644 --- a/testing/tycho-client/README.md +++ b/testing/tycho-client/README.md @@ -22,9 +22,9 @@ pip install -r requirements.txt ## Usage ```python -from tycho_client.tycho.decoders import ThirdPartyPoolTychoDecoder -from tycho_client.tycho.models import Blockchain -from tycho_client.tycho.tycho_adapter import TychoPoolStateStreamAdapter +from tycho_client.decoders import ThirdPartyPoolTychoDecoder +from tycho_client.models import Blockchain +from tycho_client.tycho_adapter import TychoPoolStateStreamAdapter decoder = ThirdPartyPoolTychoDecoder( "MyProtocolSwapAdapter.evm.runtime", minimum_gas=0, hard_limit=False diff --git a/testing/tycho-client/tycho_client/adapter_contract.py b/testing/tycho-client/tycho_client/adapter_contract.py index 9015cb8..a4e90ae 100644 --- a/testing/tycho-client/tycho_client/adapter_contract.py +++ b/testing/tycho-client/tycho_client/adapter_contract.py @@ -40,7 +40,7 @@ class Trade(NamedTuple): class ProtoSimResponse: - def __init__(self, return_value: Any, simulation_result: "SimulationResult"): + def __init__(self, return_value: Any, simulation_result: SimulationResult): self.return_value = return_value self.simulation_result = simulation_result