Add skip balance check flag for testing module

This commit is contained in:
Thales Lima
2024-07-19 22:29:31 +02:00
committed by tvinagre
parent e0c1ba3b50
commit 3ccf0a8a1f
8 changed files with 19 additions and 13 deletions

4
.gitignore vendored
View File

@@ -19,4 +19,6 @@ substreams/ethereum-template/Cargo.lock
.DS_Store
tycho-indexer
substreams/my_substream
substreams/my_substream
testing/tycho-client/build/*
testing/tycho-client/*.egg-info

View File

@@ -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

View File

@@ -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"

View File

@@ -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

View File

@@ -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

View File

@@ -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,

View File

@@ -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

View File

@@ -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