docs: improve testing docs (#133)

This commit is contained in:
Louise Poole
2025-01-16 15:49:46 +02:00
committed by GitHub
parent 98c63c685f
commit ffd6da916a
6 changed files with 36 additions and 18 deletions

View File

@@ -11,8 +11,7 @@ Additionally, it will also try to simulate some transactions using the `SwapAdap
## Prerequisites
- Latest version of our indexer, Tycho. Please contact us to obtain the latest version. Once acquired, place it in a directory that is included in your systems PATH.
- Access to PropellerHeads' private PyPI repository. Please contact us to obtain access.
- Latest version of our tycho-indexer binary, placed in a directory that is included in your systems PATH. Ask us for the binary, or follow [these instructions](https://github.com/propeller-heads/tycho-indexer/tree/main/tycho-indexer#build-tycho-indexer-binary) on our tycho-indexer repo.
- Docker installed on your machine.
- [Conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html)
and [AWS cli](https://aws.amazon.com/cli/) installed
@@ -34,7 +33,7 @@ You will also need the VM Runtime file for the adapter contract.
Our testing script should be able to build it using your test config.
The script to generate this file manually is available under `evm/scripts/buildRuntime.sh`.
## Setup testing environment
## Set up testing environment
## Prerequisites
@@ -50,24 +49,29 @@ Before setting up the Python environment, ensure the following tools and librari
- **pip**: Python package installer (https://pip.pypa.io/)
Run the setup env script. It will create a conda virtual env and install all dependencies.
```bash
./setup_env.sh
```
This script must be run from within the `tycho-protocol-sdk/testing` directory.
```
setup_env.sh
Lastly, you need to activate the conda env:
```bash
conda activate tycho-protocol-sdk-testing
```
## Running Tests
### Prerequisites
This section requires a testing environment setup. If you dont have it yet, please refer to the [setup testing
environment section](#setup-testing-environment)
This section requires a testing environment setup. If you dont have it yet, please refer to the [set up testing
environment section](#set-up-testing-environment).
### Step 1: Export Environment Variables
Export the required environment variables for the execution. You can find the available environment variables in the
`.env.default` file.
Please create a `.env` file in the `testing` directory and set the required environment variables.
Please create a `.env` file inside the `testing` directory and set the required environment variables.
#### Environment Variables
@@ -82,15 +86,21 @@ Please create a `.env` file in the `testing` directory and set the required envi
- **Description**: The API token for accessing Substreams services. This token is required for authentication.
- **Example**: `export SUBSTREAMS_API_TOKEN=eyJhbGci...`
### Step 2: Run tests
### Step 2: Set up tests
Run local postgres database using docker compose
If you do not have one already, you will need to build the wasm file of the package you wish to test. This can be done by navigating to the package directory and running:
```bash
cargo build --target wasm32-unknown-unknown --release
```
Then, run a local postgres test database using docker compose. This needs to be done from within the testing directory.
```bash
docker compose up -d db
```
Run tests for your package.
### Step 3: Run tests
Run tests for your package. This must be done from the main project directory.
```bash
python ./testing/src/runner/cli.py --package "your-package-name"
@@ -104,7 +114,9 @@ If you want to run tests for `ethereum-balancer-v2`, use:
conda activate tycho-protocol-sdk-testing
export RPC_URL="https://ethereum-mainnet.core.chainstack.com/123123123123"
export SUBSTREAMS_API_TOKEN=eyJhbGci...
cd testing
docker compose up -d db
cd ..
python ./testing/src/runner/cli.py --package "ethereum-balancer-v2"
```