-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: FuzzB0t <[email protected]>
- Loading branch information
Showing
29 changed files
with
352 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Test-e2e | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
cache: npm | ||
node-version: '20.5.1' | ||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
- run: | | ||
npm ci | ||
npm run build | ||
- name: Initialize submodules | ||
run: git submodule update --init --recursive | ||
|
||
- name: E2E Tests | ||
run: cd ./packages/cli && npm run test-e2e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Test-snx-ci | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
cache: npm | ||
node-version: '20.5.1' | ||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
- run: | | ||
npm ci | ||
npm run build | ||
- name: Initialize submodules | ||
run: git submodule update --init --recursive | ||
|
||
- name: Synthetix CI Downstream | ||
run: cd ./packages/cli && npm run test-snx-ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"publishIpfsUrl": "https+ipfs://us-west.repo.usecannon.com", | ||
"providerUrl": "http://localhost:9545", | ||
"privateKey": "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", | ||
"registryPriority": "local", | ||
"registryProviderUrl": "http://localhost:9545", | ||
"etherscanApiUrl": "https://api.etherscan.io/api", | ||
"etherscanApiKey": "A7PNIZCEI2HDRUTDJBWS36XBGIB7Q74YMK" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/usr/bin/env bats | ||
|
||
# This turns on native debug logs on bash | ||
# set -x | ||
|
||
# File pre-run hook | ||
setup_file() { | ||
load helpers/bats-helpers.sh | ||
_setup_file | ||
|
||
# Fork Mainnet to run tests against forked node | ||
anvil --fork-url https://ethereum.publicnode.com --port 9545 --silent & | ||
export ANVIL_PID="$!" | ||
} | ||
|
||
# File post-run hook | ||
teardown_file() { | ||
load helpers/bats-helpers.sh | ||
_teardown_file | ||
|
||
kill -15 "$ANVIL_PID" | ||
} | ||
|
||
# Test pre-hook | ||
setup() { | ||
load helpers/bats-helpers.sh | ||
_setup; | ||
} | ||
|
||
# Test post-hook | ||
teardown() { | ||
load helpers/bats-helpers.sh | ||
_teardown | ||
} | ||
|
||
@test "Alter - Import contract " { | ||
run alter-import-contract.sh | ||
echo $output | ||
assert_output --partial 'ipfs://QmQZu9RscJYaiwqN2qEhkpEVGTFKPj6K54yV7WnX7CPKAt' | ||
assert_success | ||
} | ||
|
||
@test "Alter - Import invoke" { | ||
run alter-import-invoke.sh | ||
echo $output | ||
assert_output --partial 'ipfs://QmQZu9RscJYaiwqN2qEhkpEVGTFKPj6K54yV7WnX7CPKAt' | ||
assert_success | ||
} | ||
|
||
@test "Build - Building foundry greeter example" { | ||
set_custom_config # Uses custom settings.json | ||
run build-foundry.sh | ||
echo $output | ||
assert_success | ||
assert_file_exists "$CANNON_DIRECTORY/tags/greeter-foundry_latest_1-main.txt" | ||
} | ||
|
||
@test "Build - Building hardhat greeter example" { | ||
set_custom_config # Uses custom settings.json | ||
run build-hardhat.sh | ||
echo $output | ||
assert_success | ||
assert_file_exists "$CANNON_DIRECTORY/tags/greeter_latest_13370-main.txt" | ||
} | ||
|
||
@test "Verify - Verify greeter packages" { | ||
set_custom_config # Uses custom settings.json | ||
run verify.sh | ||
echo $output | ||
assert_success | ||
} | ||
|
||
@test "Fetch - Fetch synthetix:latest@main package" { | ||
run fetch.sh | ||
echo $output | ||
assert_output --partial 'Successfully fetched and saved deployment data' | ||
assert_success | ||
assert_file_exists "$CANNON_DIRECTORY/tags/synthetix_3.3.4_13370-main.txt" | ||
} | ||
|
||
@test "Publish - Publishing package" { | ||
set_custom_config # Uses custom settings.json | ||
run publish.sh | ||
echo $output | ||
assert_success | ||
} |
Submodule bats-assert
added at
e2d855
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env bash | ||
|
||
# DEFAULT BATS FUNCTION OVERRIDES | ||
|
||
_setup_file() { | ||
export CANNON_REPO_DIR="$(git rev-parse --show-toplevel)" | ||
export CANNON="node $CANNON_REPO_DIR/packages/cli/bin/cannon.js" | ||
|
||
# Create temporary directory for tests | ||
export WORKDIR="$(mktemp -d)" | ||
export CANNON_DIRECTORY="$WORKDIR/cannondir" | ||
|
||
#Creating cannon directory structure | ||
mkdir $CANNON_DIRECTORY $CANNON_DIRECTORY/tags/ $CANNON_DIRECTORY/ipfs_cache/ $CANNON_DIRECTORY/metadata_cache/ | ||
|
||
# CD into dir so any files created go in the tmp dir | ||
cd $CANNON_DIRECTORY | ||
} | ||
|
||
_setup() { | ||
load 'helpers/bats-support/load' | ||
load 'helpers/bats-assert/load' | ||
load 'helpers/bats-file/load' | ||
|
||
# get the containing directory of this file | ||
# use $BATS_TEST_FILENAME instead of ${BASH_SOURCE[0]} or $0, | ||
# as those will point to the bats executable's location or the preprocessed file respectively | ||
DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")" >/dev/null 2>&1 && pwd)" | ||
|
||
# make executables in scripts/ visible to PATH so tests can run files without relative path | ||
PATH="$DIR/scripts/non-interactive:$DIR/scripts/interactive:$DIR/scripts/:$PATH" | ||
} | ||
|
||
# File post-run hook | ||
_teardown_file() { | ||
if [ -e $WORKDIR]; then | ||
rm -rf $WORKDIR | ||
fi | ||
} | ||
|
||
# Test post-hook | ||
_teardown() { | ||
if [ -e "$CANNON_DIRECTORY/settings.json"]; then | ||
rm "$CANNON_DIRECTORY/settings.json" | ||
fi | ||
} | ||
|
||
|
||
# CUSTOM FUNCTIONS | ||
|
||
# This function is used to log output during test execution | ||
# Bats by default hides output during each test. | ||
log() { | ||
echo "$@" >&3 | ||
} | ||
|
||
# Copy remote network config over to temp dir | ||
set_custom_config() { | ||
touch "$CANNON_DIRECTORY/settings.json" | ||
cp "$DIR/config/settings.json" "$CANNON_DIRECTORY/settings.json" | ||
} | ||
|
Submodule bats-support
added at
9bf10e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$CANNON interact synthetix:latest@main --chain-id 1 |
1 change: 1 addition & 0 deletions
1
packages/cli/test/e2e/scripts/interactive/publish-interactive.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$CANNON publish greeter-foundry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$CANNON run synthetix:latest@main --chain-id 5 |
1 change: 1 addition & 0 deletions
1
packages/cli/test/e2e/scripts/non-interactive/alter-import-contract.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$CANNON alter synthetix:latest@andromeda --chain-id 84531 import contract.AccountModule 0x009deee64034427b0fe2ab6fb223d79a1b97c59f6374cc910e581c3f5fbf933e |
1 change: 1 addition & 0 deletions
1
packages/cli/test/e2e/scripts/non-interactive/alter-import-invoke.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$CANNON alter synthetix:latest@andromeda --chain-id 84531 import invoke.register_const_one_oracle 0xb864b8ee3b3608e31971f92c3c2fd9ee87af32f1ecc91de1fafe8b8c3347657b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$CANNON build $CANNON_REPO_DIR/examples/sample-foundry-project/cannonfile.toml --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --chain-id 1 --port 9545 |
3 changes: 3 additions & 0 deletions
3
packages/cli/test/e2e/scripts/non-interactive/build-hardhat.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cd $CANNON_REPO_DIR/examples/sample-hardhat-project; | ||
npx hardhat cannon:build | ||
cd - |
14 changes: 14 additions & 0 deletions
14
packages/cli/test/e2e/scripts/non-interactive/downstream-ci-synthetix-deployments.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
git clone --depth=1 https://github.com/Synthetixio/synthetix-deployments | ||
cd synthetix-deployments | ||
yarn | ||
yarn link --all $CANNON_DIRECTORY | ||
|
||
yarn cannon build omnibus-base-mainnet-andromeda.toml \ | ||
--port 8545 \ | ||
--dry-run \ | ||
--upgrade-from synthetix-omnibus:latest@andromeda \ | ||
--chain-id 8453 \ | ||
--provider-url https://base.publicnode.com | ||
|
8 changes: 8 additions & 0 deletions
8
packages/cli/test/e2e/scripts/non-interactive/downstream-ci-synthetix-v3.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
git clone --depth=1 https://github.com/Synthetixio/synthetix-v3 | ||
cd synthetix-v3 | ||
yarn | ||
yarn link --all $CANNON_DIRECTORY | ||
|
||
yarn build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$CANNON fetch synthetix:latest@main QmUtELWtepNn1ByaFUF8YAgLMtdvy6GGe2P9ex48EVit4H --chain-id 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$CANNON publish greeter-foundry --chain-id 1 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --skip-confirm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$CANNON verify greeter-foundry --chain-id 1 |
Oops, something went wrong.