Skip to content

Commit

Permalink
Merge pull request #498 from ava-labs/remove-tesnet-flows
Browse files Browse the repository at this point in the history
Remove tesnet flows
  • Loading branch information
michaelkaplan13 authored Nov 4, 2024
2 parents c84670b + 577d93c commit 1cbfbd4
Show file tree
Hide file tree
Showing 50 changed files with 561 additions and 523 deletions.
2 changes: 0 additions & 2 deletions .env.example

This file was deleted.

22 changes: 0 additions & 22 deletions .env.testnet

This file was deleted.

12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
go-version-file: "go.mod"

- name: Run Go unit tests
run: |
Expand All @@ -61,7 +61,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
go-version-file: "go.mod"

- name: Install Foundry
run: ./scripts/install_foundry.sh
Expand All @@ -71,7 +71,7 @@ jobs:
run: |
export PATH=$PATH:$HOME/.foundry/bin
export PATH="$PATH:$GOPATH/bin"
./scripts/local/e2e_test.sh --components teleporter
./scripts/e2e_test.sh --components teleporter
governance_e2e:
name: governance-e2e-tests
Expand All @@ -95,7 +95,7 @@ jobs:
run: |
export PATH=$PATH:$HOME/.foundry/bin
export PATH="$PATH:$GOPATH/bin"
./scripts/local/e2e_test.sh --components governance
./scripts/e2e_test.sh --components governance
validator_manager_e2e:
name: validator-manager-e2e-tests
Expand All @@ -119,7 +119,7 @@ jobs:
run: |
export PATH=$PATH:$HOME/.foundry/bin
export PATH="$PATH:$GOPATH/bin"
./scripts/local/e2e_test.sh --components validator-manager
./scripts/e2e_test.sh --components validator-manager
ictt_e2e:
name: ictt-e2e-tests
Expand All @@ -143,4 +143,4 @@ jobs:
run: |
export PATH=$PATH:$HOME/.foundry/bin
export PATH="$PATH:$GOPATH/bin"
./scripts/local/e2e_test.sh --components ictt
./scripts/e2e_test.sh --components ictt
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ contracts/pkg
docker-compose-test-local.yml
docker-compose-run-local.yml

# Environment and configuration values
.env

# Ginkgo
main.log
server.log
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ To start developing on Teleporter, you'll need Solidity >= v0.8.25. [Foundry](ht
- Run the end-to-end tests

```sh
./scripts/local/e2e_test.sh
./scripts/e2e_test.sh
```

- Run the Solidity and Golang linters
Expand Down
22 changes: 5 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ To get started with using Teleporter, see [How to Deploy Teleporter Enabled Subn
- [Structure](#structure)
- [E2E tests](#e2e-tests)
- [Run specific E2E tests](#run-specific-e2e-tests)
- [Run the E2E tests on another network](#run-the-e2e-tests-on-another-network)
- [Upgradability](#upgradability)
- [Deploy Teleporter to a Subnet](#deploy-teleporter-to-a-subnet)
- [Deploy TeleporterRegistry to a Subnet](#deploy-teleporterregistry-to-a-subnet)
Expand Down Expand Up @@ -67,7 +66,7 @@ Release versions follow the [semver](https://semver.org/) convention of incompat
- `scripts/` includes bash scripts for interacting with Teleporter in various environments, as well as utility scripts.
- `abi_bindings.sh` generates ABI bindings for the contracts in `contracts/` and outputs them to `abi-bindings/`.
- `lint.sh` performs Solidity and Golang linting.
- `scripts/local/` includes scripts for running Teleporter in Docker.
- `scripts/` includes scripts for running Teleporter in Docker.
- `docker/` includes configurations for a local, containerized setup of Teleporter.

## E2E tests
Expand All @@ -79,21 +78,21 @@ To run the E2E tests locally, you'll need to install Gingko following the instru
Then run the following command from the root of the repository:

```bash
./scripts/local/e2e_test.sh
./scripts/e2e_test.sh
```

### Run specific E2E tests

To run a specific E2E test, specify the environment variable `GINKGO_FOCUS`, which will then look for test descriptions that match the provided input. For example, to run the `Calculate Teleporter message IDs` test:

```bash
GINKGO_FOCUS="Calculate Teleporter message IDs" ./scripts/local/e2e_test.sh
GINKGO_FOCUS="Calculate Teleporter message IDs" ./scripts/e2e_test.sh
```

A substring of the full test description can be used as well:

```bash
GINKGO_FOCUS="Calculate Teleporter" ./scripts/local/e2e_test.sh
GINKGO_FOCUS="Calculate Teleporter" ./scripts/e2e_test.sh
```

The E2E tests also supports `GINKGO_LABEL_FILTER`, making it easy to group test cases and run them together. For example, to run all E2E tests for the example cross chain applications:
Expand All @@ -107,20 +106,9 @@ The E2E tests also supports `GINKGO_LABEL_FILTER`, making it easy to group test
```
```bash
GINKGO_LABEL_FILTER="cross chain apps" ./scripts/local/e2e_test.sh
GINKGO_LABEL_FILTER="cross chain apps" ./scripts/e2e_test.sh
```
### Run the E2E tests on another network
The same E2E test flows can be executed against external network by setting the proper environment variables in `.env.testnet` and `.env`, and running the following commands:
```bash
cp .env.example .env # Set proper values after copying.
./scripts/testnet/run_testnet_e2e_flows.sh
```
The user wallet set in `.env` must have native tokens for each of the Subnets used in order for the test flows to be able to send transactions on those networks. The [Avalanche Testnet Faucet](https://core.app/tools/testnet-faucet) can be used to obtain native tokens for certain public testnet Subnets.
## Upgradability
The Teleporter contract is non-upgradeable and can not be changed once it is deployed. This provides immutability to the contracts, and ensures that the contract's behavior at each address is unchanging. However, to allow for new features and potential bug fixes, new versions of the Teleporter contract can be deployed to different addresses. The [TeleporterRegistry](./contracts/teleporter/TeleporterRegistry.sol) is used to keep track of the deployed versions of Teleporter, and to provide a standard interface for dApps to interact with the different Teleporter versions.
Expand Down
10 changes: 5 additions & 5 deletions scripts/local/e2e_test.sh → scripts/e2e_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ set -e

TELEPORTER_PATH=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
cd ../.. && pwd
cd ../ && pwd
)

function printHelp() {
echo "Usage: ./scripts/local/e2e_test.sh [--component component]"
echo "Usage: ./scripts/e2e_test.sh [--component component]"
echo ""
printUsage
}
Expand All @@ -26,7 +26,7 @@ Options:
EOF
}

valid_components=$(ls -d $TELEPORTER_PATH/tests/local/*/ | xargs -n 1 basename)
valid_components=$(ls -d $TELEPORTER_PATH/tests/suites/*/ | xargs -n 1 basename)
components=

while [ $# -gt 0 ]; do
Expand Down Expand Up @@ -89,11 +89,11 @@ go install -v github.com/onsi/ginkgo/v2/ginkgo@${GINKGO_VERSION}

for component in $(echo $components | tr ',' ' '); do
echo "Building e2e tests for $component"
ginkgo build ./tests/local/$component
ginkgo build ./tests/suites/$component

echo "Running e2e tests for $component"

RUN_E2E=true ./tests/local/$component/$component.test \
RUN_E2E=true ./tests/suites/$component/$component.test \
--ginkgo.vv \
--ginkgo.label-filter=${GINKGO_LABEL_FILTER:-""} \
--ginkgo.focus=${GINKGO_FOCUS:-""} \
Expand Down
18 changes: 0 additions & 18 deletions scripts/testnet/run_testnet_e2e_flows.sh

This file was deleted.

18 changes: 7 additions & 11 deletions tests/flows/governance/validator_set_sig.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"github.com/ava-labs/subnet-evm/accounts/abi/bind"
validatorsetsig "github.com/ava-labs/teleporter/abi-bindings/go/governance/ValidatorSetSig"
exampleerc20 "github.com/ava-labs/teleporter/abi-bindings/go/mocks/ExampleERC20"
"github.com/ava-labs/teleporter/tests/interfaces"
localnetwork "github.com/ava-labs/teleporter/tests/network"
"github.com/ava-labs/teleporter/tests/utils"
. "github.com/onsi/gomega"
)

func ValidatorSetSig(network interfaces.LocalNetwork) {
func ValidatorSetSig(network *localnetwork.LocalNetwork) {
// ************************************************************************************************
// Setup
// ************************************************************************************************
Expand All @@ -36,7 +36,7 @@ func ValidatorSetSig(network interfaces.LocalNetwork) {
// ************************************************************************************************
// Setup
// ************************************************************************************************
subnetA, subnetB := utils.GetTwoSubnets(network)
subnetA, subnetB := network.GetTwoSubnets()
_, fundedKey := network.GetFundedAccountInfo()

ctx := context.Background()
Expand Down Expand Up @@ -150,9 +150,8 @@ func ValidatorSetSig(network interfaces.LocalNetwork) {
// ************************************************************************************************

// Execute the ValidatorSetSig executeCall and wait for acceptance
receipt := utils.ExecuteValidatorSetSigCallAndVerify(
receipt := network.ExecuteValidatorSetSigCallAndVerify(
ctx,
network,
subnetB,
subnetA,
validatorSetSigContractAddress,
Expand All @@ -173,9 +172,8 @@ func ValidatorSetSig(network interfaces.LocalNetwork) {

// Resend the same message again and it should fail due to nonce being consumed

_ = utils.ExecuteValidatorSetSigCallAndVerify(
_ = network.ExecuteValidatorSetSigCallAndVerify(
ctx,
network,
subnetB,
subnetA,
validatorSetSigContractAddress,
Expand All @@ -190,9 +188,8 @@ func ValidatorSetSig(network interfaces.LocalNetwork) {
Expect(endingBalance).Should(Equal(big.NewInt(100)))

// Send another valid transaction with the incremented nonce
receipt2 := utils.ExecuteValidatorSetSigCallAndVerify(
receipt2 := network.ExecuteValidatorSetSigCallAndVerify(
ctx,
network,
subnetB,
subnetA,
validatorSetSigContractAddress,
Expand Down Expand Up @@ -222,9 +219,8 @@ func ValidatorSetSig(network interfaces.LocalNetwork) {

// Send the third transaction where the validatorSetSig contract expects validator signatures
// from the same chain that it is deployed on.
receipt3 := utils.ExecuteValidatorSetSigCallAndVerify(
receipt3 := network.ExecuteValidatorSetSigCallAndVerify(
ctx,
network,
subnetB,
subnetB,
validatorSetSigContractAddress2,
Expand Down
8 changes: 4 additions & 4 deletions tests/flows/ictt/erc20_home_erc20_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/ava-labs/subnet-evm/accounts/abi/bind"
erc20tokenhome "github.com/ava-labs/teleporter/abi-bindings/go/ictt/TokenHome/ERC20TokenHome"
erc20tokenremote "github.com/ava-labs/teleporter/abi-bindings/go/ictt/TokenRemote/ERC20TokenRemote"
"github.com/ava-labs/teleporter/tests/interfaces"
localnetwork "github.com/ava-labs/teleporter/tests/network"
"github.com/ava-labs/teleporter/tests/utils"
teleporterUtils "github.com/ava-labs/teleporter/tests/utils"
"github.com/ethereum/go-ethereum/crypto"
Expand All @@ -20,9 +20,9 @@ import (
* Transfers C-Chain example ERC20 tokens to Subnet A
* Transfer tokens from Subnet A to C-Chain
*/
func ERC20TokenHomeERC20TokenRemote(network interfaces.Network, teleporter utils.TeleporterTestInfo) {
func ERC20TokenHomeERC20TokenRemote(network *localnetwork.LocalNetwork, teleporter utils.TeleporterTestInfo) {
cChainInfo := network.GetPrimaryNetworkInfo()
subnetAInfo, _ := teleporterUtils.GetTwoSubnets(network)
subnetAInfo, _ := network.GetTwoSubnets()
fundedAddress, fundedKey := network.GetFundedAccountInfo()

ctx := context.Background()
Expand Down Expand Up @@ -74,12 +74,12 @@ func ERC20TokenHomeERC20TokenRemote(network interfaces.Network, teleporter utils

utils.RegisterERC20TokenRemoteOnHome(
ctx,
network,
teleporter,
cChainInfo,
erc20TokenHomeAddress,
subnetAInfo,
erc20TokenRemoteAddress,
fundedKey,
)

// Generate new recipient to receive transferred tokens
Expand Down
12 changes: 5 additions & 7 deletions tests/flows/ictt/erc20_home_erc20_remote_multihop.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/ava-labs/subnet-evm/accounts/abi/bind"
erc20tokenhome "github.com/ava-labs/teleporter/abi-bindings/go/ictt/TokenHome/ERC20TokenHome"
"github.com/ava-labs/teleporter/tests/interfaces"
localnetwork "github.com/ava-labs/teleporter/tests/network"
"github.com/ava-labs/teleporter/tests/utils"
"github.com/ethereum/go-ethereum/crypto"
. "github.com/onsi/gomega"
Expand All @@ -19,9 +19,9 @@ import (
* Transfer tokens from Subnet A to Subnet B through multi-hop
* Transfer back tokens from Subnet B to Subnet A through multi-hop
*/
func ERC20TokenHomeERC20TokenRemoteMultiHop(network interfaces.Network, teleporter utils.TeleporterTestInfo) {
func ERC20TokenHomeERC20TokenRemoteMultiHop(network *localnetwork.LocalNetwork, teleporter utils.TeleporterTestInfo) {
cChainInfo := network.GetPrimaryNetworkInfo()
subnetAInfo, subnetBInfo := utils.GetTwoSubnets(network)
subnetAInfo, subnetBInfo := network.GetTwoSubnets()
fundedAddress, fundedKey := network.GetFundedAccountInfo()

ctx := context.Background()
Expand Down Expand Up @@ -89,21 +89,21 @@ func ERC20TokenHomeERC20TokenRemoteMultiHop(network interfaces.Network, teleport
// Register both ERC20TokenRemote instances on the ERC20TokenHome
utils.RegisterERC20TokenRemoteOnHome(
ctx,
network,
teleporter,
cChainInfo,
erc20TokenHomeAddress,
subnetAInfo,
erc20TokenRemoteAddressA,
fundedKey,
)
utils.RegisterERC20TokenRemoteOnHome(
ctx,
network,
teleporter,
cChainInfo,
erc20TokenHomeAddress,
subnetBInfo,
erc20TokenRemoteAddressB,
fundedKey,
)

// Generate new recipient to receive transferred tokens
Expand Down Expand Up @@ -162,7 +162,6 @@ func ERC20TokenHomeERC20TokenRemoteMultiHop(network interfaces.Network, teleport
secondaryFeeAmount := big.NewInt(0).Div(transferredAmount, big.NewInt(4))
utils.SendERC20TokenMultiHopAndVerify(
ctx,
network,
teleporter,
fundedKey,
recipientKey,
Expand All @@ -183,7 +182,6 @@ func ERC20TokenHomeERC20TokenRemoteMultiHop(network interfaces.Network, teleport
secondaryFeeAmount = big.NewInt(0).Div(transferredAmount, big.NewInt(4))
utils.SendERC20TokenMultiHopAndVerify(
ctx,
network,
teleporter,
fundedKey,
recipientKey,
Expand Down
Loading

0 comments on commit 1cbfbd4

Please sign in to comment.