refactor(testing): miscellaneous improvements and bugfixes
Includes bugfix on `tycho-indexer-client` and `protosim_py`, a script to simplify setting up testing python env and cli improvements. Also add support for building runtime for SwapAdapters with many args that was bugged before.
This commit is contained in:
@@ -31,8 +31,15 @@ echo "CONSTRUCTOR_ARGUMENTS: $CONSTRUCTOR_ARGUMENTS"
|
||||
|
||||
# Perform operations if CONSTRUCTOR_SIGNATURE and CONSTRUCTOR_ARGUMENTS are set
|
||||
if [[ ! -z "$CONSTRUCTOR_SIGNATURE" && ! -z "$CONSTRUCTOR_ARGUMENTS" ]]; then
|
||||
# Do some operations here
|
||||
export __PROPELLER_DEPLOY_ARGS=$(cast abi-encode $CONSTRUCTOR_SIGNATURE $CONSTRUCTOR_ARGUMENTS)
|
||||
# Split the CONSTRUCTOR_ARGUMENTS by commas into an array
|
||||
IFS=',' read -r -a ARG_ARRAY <<< "$CONSTRUCTOR_ARGUMENTS"
|
||||
|
||||
# Create the cast abi-encode command with the arguments
|
||||
ENCODED_ARGS=$(cast abi-encode "$CONSTRUCTOR_SIGNATURE" "${ARG_ARRAY[@]}")
|
||||
|
||||
# Export the encoded arguments
|
||||
export __PROPELLER_DEPLOY_ARGS=$ENCODED_ARGS
|
||||
echo "$ENCODED_ARGS"
|
||||
fi
|
||||
|
||||
export __PROPELLER_CONTRACT="$CONTRACT_NAME.sol:$CONTRACT_NAME"
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
export SUBSTREAMS_PACKAGE=ethereum-curve
|
||||
export RPC_URL=https://mainnet.infura.io/v3/your-infura-key
|
||||
export DATABASE_URL: "postgres://postgres:mypassword@db:5432/tycho_indexer_0"
|
||||
export SUBSTREAMS_API_TOKEN="changeme"
|
||||
export DOMAIN_OWNER="AWSAccountId"
|
||||
@@ -2,5 +2,5 @@ psycopg2==2.9.9
|
||||
PyYAML==6.0.1
|
||||
Requests==2.32.2
|
||||
web3==5.31.3
|
||||
tycho-indexer-client>=0.7.0
|
||||
protosim_py>=0.5.0
|
||||
tycho-indexer-client>=0.7.2
|
||||
protosim_py>=0.6.3
|
||||
|
||||
35
testing/setup_env.sh
Executable file
35
testing/setup_env.sh
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Variables
|
||||
ENV_NAME="propeller-protocol-lib-testing"
|
||||
PYTHON_VERSION="3.9"
|
||||
REQUIREMENTS_FILE="requirements.txt"
|
||||
PRE_BUILD_SCRIPT="pre_build.sh"
|
||||
|
||||
# Allow to run either from root or from inside testing folder.
|
||||
if [ -f "./$REQUIREMENTS_FILE" ]; then
|
||||
# If the requirements file is found in the current directory, do nothing
|
||||
SCRIPT_DIR="."
|
||||
elif [ -f "testing/$REQUIREMENTS_FILE" ]; then
|
||||
# If the requirements file is found in testing/, adjust the paths
|
||||
SCRIPT_DIR="testing"
|
||||
else
|
||||
echo "Error: Script must be run from the propeller-protocol-lib or propeller-protocol-lib/testing directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create conda environment
|
||||
echo "Creating conda environment ${ENV_NAME} with Python ${PYTHON_VERSION}..."
|
||||
conda create --name $ENV_NAME python=$PYTHON_VERSION -y
|
||||
|
||||
# Activate the environment
|
||||
echo "Activating the environment..."
|
||||
source activate $ENV_NAME
|
||||
|
||||
# Install the requirements
|
||||
echo "Installing the requirements from ${SCRIPT_DIR}/${REQUIREMENTS_FILE}..."
|
||||
./${SCRIPT_DIR}/${PRE_BUILD_SCRIPT}
|
||||
pip install -r ${SCRIPT_DIR}/${REQUIREMENTS_FILE}
|
||||
conda activate $ENV_NAME
|
||||
|
||||
echo "Setup complete."
|
||||
@@ -8,10 +8,13 @@ def main() -> None:
|
||||
)
|
||||
parser.add_argument("--package", type=str, help="Name of the package to test.")
|
||||
parser.add_argument(
|
||||
"--tycho-logs", action="store_true", help="Flag to activate logs from Tycho."
|
||||
"--tycho-logs", action="store_true", help="Enable Tycho logs."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--db-url", type=str, help="Postgres database URL for the Tycho indexer."
|
||||
"--db-url",
|
||||
default="postgres://postgres:mypassword@localhost:5431/tycho_indexer_0",
|
||||
type=str,
|
||||
help="Postgres database URL for the Tycho indexer. Default: postgres://postgres:mypassword@localhost:5431/tycho_indexer_0",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--vm-traces", action="store_true", help="Enable tracing during vm simulations."
|
||||
|
||||
@@ -4,8 +4,6 @@ from hexbytes import HexBytes
|
||||
from pydantic import BaseModel, Field, validator
|
||||
from typing import List, Dict, Optional
|
||||
|
||||
from tycho_client.dto import ProtocolComponent
|
||||
|
||||
|
||||
class ProtocolComponentExpectation(BaseModel):
|
||||
"""Represents a ProtocolComponent with its main attributes."""
|
||||
|
||||
@@ -14,7 +14,7 @@ from protosim_py.evm.decoders import ThirdPartyPoolTychoDecoder
|
||||
from protosim_py.evm.storage import TychoDBSingleton
|
||||
from protosim_py.models import EVMBlock
|
||||
from pydantic import BaseModel
|
||||
from tycho_client.dto import (
|
||||
from tycho_indexer_client.dto import (
|
||||
Chain,
|
||||
ProtocolComponentsParams,
|
||||
ProtocolStateParams,
|
||||
@@ -26,7 +26,7 @@ from tycho_client.dto import (
|
||||
Snapshot,
|
||||
ContractId,
|
||||
)
|
||||
from tycho_client.rpc_client import TychoRPCClient
|
||||
from tycho_indexer_client.rpc_client import TychoRPCClient
|
||||
|
||||
from models import (
|
||||
IntegrationTestsConfig,
|
||||
|
||||
@@ -27,12 +27,15 @@ def find_binary_file(file_name):
|
||||
|
||||
# Check each location
|
||||
for location in locations:
|
||||
potential_path = location + "/" + file_name
|
||||
potential_path = os.path.join(location, file_name)
|
||||
if os.path.exists(potential_path):
|
||||
return potential_path
|
||||
|
||||
# If binary is not found in the usual locations, return None
|
||||
raise RuntimeError("Unable to locate tycho-indexer binary")
|
||||
searched_paths = "\n".join(locations)
|
||||
raise RuntimeError(
|
||||
f"Unable to locate {file_name} binary. Searched paths:\n{searched_paths}"
|
||||
)
|
||||
|
||||
|
||||
binary_path = find_binary_file("tycho-indexer")
|
||||
|
||||
@@ -3,7 +3,7 @@ from typing import Union
|
||||
|
||||
from eth_utils import to_checksum_address
|
||||
from protosim_py.models import EthereumToken
|
||||
from tycho_client.dto import (
|
||||
from tycho_indexer_client.dto import (
|
||||
ResponseProtocolState,
|
||||
ProtocolComponent,
|
||||
ResponseAccount,
|
||||
@@ -13,7 +13,7 @@ from tycho_client.dto import (
|
||||
TokensParams,
|
||||
PaginationParams,
|
||||
)
|
||||
from tycho_client.rpc_client import TychoRPCClient
|
||||
from tycho_indexer_client.rpc_client import TychoRPCClient
|
||||
|
||||
log = getLogger(__name__)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user