Add skip balance check flag for testing module
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -19,4 +19,6 @@ substreams/ethereum-template/Cargo.lock
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
tycho-indexer
|
tycho-indexer
|
||||||
substreams/my_substream
|
substreams/my_substream
|
||||||
|
testing/tycho-client/build/*
|
||||||
|
testing/tycho-client/*.egg-info
|
||||||
@@ -2,6 +2,7 @@ substreams_yaml_path: ./substreams.yaml
|
|||||||
protocol_type_names:
|
protocol_type_names:
|
||||||
- "curve_pool"
|
- "curve_pool"
|
||||||
adapter_contract: "CurveSwapAdapter.evm.runtime"
|
adapter_contract: "CurveSwapAdapter.evm.runtime"
|
||||||
|
skip_balance_check: false
|
||||||
tests:
|
tests:
|
||||||
- name: test_3pool_creation
|
- name: test_3pool_creation
|
||||||
start_block: 10809470
|
start_block: 10809470
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
substreams_yaml_path: ./substreams.yaml
|
substreams_yaml_path: ./substreams.yaml
|
||||||
|
adapter_contract: "SwapAdapter.evm.runtime"
|
||||||
|
skip_balance_check: false
|
||||||
protocol_type_names:
|
protocol_type_names:
|
||||||
- "type_name_1"
|
- "type_name_1"
|
||||||
- "type_name_2"
|
- "type_name_2"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ FROM --platform=linux/amd64 continuumio/miniconda3:24.4.0-0
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Add current directory code to /app in container
|
# Add current directory code to /app in container
|
||||||
ADD ./ /app/testing
|
ADD . /app/testing
|
||||||
|
|
||||||
RUN chmod +x /app/testing/tycho-indexer
|
RUN chmod +x /app/testing/tycho-indexer
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
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.
|
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.
|
Please place this Runtime file under the respective `substream` directory inside the `evm` folder.
|
||||||
|
|
||||||
## Running Tests
|
## Running Tests
|
||||||
|
|||||||
@@ -135,12 +135,13 @@ class TestRunner:
|
|||||||
tycho_balance = int(balance_hex, 16)
|
tycho_balance = int(balance_hex, 16)
|
||||||
token_balances[comp_id][token_lower] = tycho_balance
|
token_balances[comp_id][token_lower] = tycho_balance
|
||||||
|
|
||||||
node_balance = get_token_balance(token, comp_id, stop_block)
|
if self.config["skip_balance_check"] is not True:
|
||||||
if node_balance != tycho_balance:
|
node_balance = get_token_balance(token, comp_id, stop_block)
|
||||||
return TestResult.Failed(
|
if node_balance != tycho_balance:
|
||||||
f"Balance mismatch for {comp_id}:{token} at block {stop_block}: got {node_balance} "
|
return TestResult.Failed(
|
||||||
f"from rpc call and {tycho_balance} from Substreams"
|
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()
|
contract_states = self.tycho_runner.get_contract_state()
|
||||||
simulation_failures = self.simulate_get_amount_out(
|
simulation_failures = self.simulate_get_amount_out(
|
||||||
token_balances,
|
token_balances,
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ pip install -r requirements.txt
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from tycho_client.tycho.decoders import ThirdPartyPoolTychoDecoder
|
from tycho_client.decoders import ThirdPartyPoolTychoDecoder
|
||||||
from tycho_client.tycho.models import Blockchain
|
from tycho_client.models import Blockchain
|
||||||
from tycho_client.tycho.tycho_adapter import TychoPoolStateStreamAdapter
|
from tycho_client.tycho_adapter import TychoPoolStateStreamAdapter
|
||||||
|
|
||||||
decoder = ThirdPartyPoolTychoDecoder(
|
decoder = ThirdPartyPoolTychoDecoder(
|
||||||
"MyProtocolSwapAdapter.evm.runtime", minimum_gas=0, hard_limit=False
|
"MyProtocolSwapAdapter.evm.runtime", minimum_gas=0, hard_limit=False
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class Trade(NamedTuple):
|
|||||||
|
|
||||||
|
|
||||||
class ProtoSimResponse:
|
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.return_value = return_value
|
||||||
self.simulation_result = simulation_result
|
self.simulation_result = simulation_result
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user