Skip to content

Commit

Permalink
add --local flag to e2e script
Browse files Browse the repository at this point in the history
  • Loading branch information
cam-schultz committed Sep 28, 2023
1 parent afbc280 commit 0898520
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 16 deletions.
19 changes: 3 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,12 @@ Unit tests can be ran locally by running the command in root of the project:

### E2E tests

E2E tests are ran as part of CI, but can also be ran locally. To run the E2E tests locally, you'll need to do the following:
- Install Gingko following the intructions [here](https://onsi.github.io/ginkgo/#installing-ginkgo)
- Clone `subnet-evm` from [Github](https://github.com/ava-labs/subnet-evm) and checkout the correct version as specified in `go.mod` or `scripts/versions.sh`

Next, set up the `avalanchego` build path and `subnet-evm` binary, making sure to install everything in a writeable location (here we use `~/tmp`):

```bash
cd subnet-evm
BASEDIR=~/tmp/e2e-test AVALANCHEGO_BUILD_PATH=~/tmp/e2e-test/avalanchego ./scripts/install_avalanchego_release.sh
./scripts/build.sh ~/tmp/e2e-test/avalanchego/plugins/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy
```

Then, in the root of the `awm-relayer` project, run:
E2E tests are ran as part of CI, but can also be ran locally with the `--local` flag. To run the E2E tests locally, you'll need to install Gingko following the intructions [here](https://onsi.github.io/ginkgo/#installing-ginkgo)

Next, provide the path to the `subnet-evm` repository and the path to a writeable data directory (here we use the `~/subnet-evm` and `~/tmp/e2e-test`) to use for the tests:
```bash
AVALANCHEGO_BUILD_PATH=~/tmp/e2e-test/avalanchego DATA_DIR=~/tmp/e2e-test/data ./scripts/e2e_test.sh
./scripts/e2e_test.sh --local --subnet-evm ~/subnet-evm --data-dir ~/tmp/e2e-test
```

Note that any additional E2E tests that run VMs other than `subnet-evm` will need to install and setup the VM binary in the same way.
### Generate Mocks

We use [gomock](https://pkg.go.dev/go.uber.org/mock/gomock) to generate mocks for testing. To generate mocks, run the following command at the root of the project:
Expand Down
45 changes: 45 additions & 0 deletions scripts/e2e_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,51 @@

set -e

SUBNET_EVM_PATH=
LOCAL=
DATA_DIRECTORY=
HELP=
while [ $# -gt 0 ]; do
case "$1" in
-l | --local) LOCAL=true ;;
-s | --subnet-evm) SUBNET_EVM_PATH=$2 ;;
-d | --data-dir) DATA_DIRECTORY=$2 ;;
-h | --help) HELP=true ;;
esac
shift
done

if [ "$HELP" = true ]; then
echo "Usage: ./scripts/e2e_test.sh [OPTIONS]"
echo "Run E2E tests for AWM Relayer."
echo ""
echo "Options:"
echo " -l, --local Run the test locally. Requires --subnet-evm and --data-dir"
echo " -s, --subnet-evm <path> Path to subnet-evm repo"
echo " -d, --data-dir <path> Path to data directory"
echo " -h, --help Print this help message"
exit 0
fi

if [ "$LOCAL" = true ]; then
if [ -z "$DATA_DIRECTORY" ]; then
echo "Must specify data directory when running local"
exit 1
fi
if [ -z "$SUBNET_EVM_PATH" ]; then
echo "Must specify subnet-evm path when running local"
exit 1
fi
cwd=$PWD
cd $SUBNET_EVM_PATH
BASEDIR=$DATA_DIRECTORY AVALANCHEGO_BUILD_PATH=$DATA_DIRECTORY/avalanchego ./scripts/install_avalanchego_release.sh
./scripts/build.sh $DATA_DIRECTORY/avalanchego/plugins/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy

cd $cwd
export AVALANCHEGO_BUILD_PATH=$DATA_DIRECTORY/avalanchego
export DATA_DIR=$DATA_DIRECTORY/data
fi

RELAYER_PATH=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
cd .. && pwd
Expand Down

0 comments on commit 0898520

Please sign in to comment.