Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add e2e test suite with evm contracts deployments #9

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
366042b
feat: add e2e test contract deployments
nadim-az Oct 31, 2024
c321849
remove lib
nadim-az Oct 31, 2024
3a745be
add e2e test ci step
nadim-az Oct 31, 2024
fa18633
save run-latest.json artifact
nadim-az Oct 31, 2024
882f199
lint
nadim-az Oct 31, 2024
d31a1fe
add broadcast to .gitignore
nadim-az Oct 31, 2024
500bec3
remove unlicensed
nadim-az Oct 31, 2024
6abcac2
deploy hpl contracts
nadim-az Dec 11, 2024
6337c5b
Merge branch 'main' into na/add-e2e-test
nadim-az Dec 11, 2024
6bb991a
deploy hyperlane scripts in a different forge step
nadim-az Dec 15, 2024
a70bc45
hyperlane lib
nadim-az Dec 16, 2024
7becacc
use make command in ci workflow
nadim-az Dec 16, 2024
707b5f5
fix ci
nadim-az Dec 16, 2024
160b434
fix ci
nadim-az Dec 16, 2024
14592fa
fix ci
nadim-az Dec 16, 2024
56a3df2
add back gitmodules
nadim-az Dec 16, 2024
19b8357
Update forge-std submodule
nadim-az Dec 16, 2024
18fbe1f
updated hyperlane lib
nadim-az Dec 16, 2024
ad21be6
update ci workflow
nadim-az Dec 16, 2024
9bf9d65
remove gitmodules
nadim-az Dec 16, 2024
57c9a37
rename contract
nadim-az Dec 16, 2024
5735c31
dont forge install in make command
nadim-az Dec 16, 2024
73588c8
remove submodules completely
nadim-az Dec 17, 2024
4447ba7
forge install: forge-std
nadim-az Dec 17, 2024
ee41b9b
add hyperlane
nadim-az Dec 17, 2024
343e3eb
Update hyperlane submodule to use solver-e2etest-changes branch
nadim-az Dec 17, 2024
8eed116
fixes
nadim-az Dec 17, 2024
072cb99
update e2e workflow to use submodules again
nadim-az Dec 17, 2024
c45be88
init hyperlane separately
nadim-az Dec 17, 2024
9de73fd
checkout hyperlane repo custom branch and apply patch changes
nadim-az Dec 17, 2024
2157b71
use subtree instead of git submodule
nadim-az Dec 17, 2024
a6637a3
apply from top level dir
nadim-az Dec 17, 2024
d1d6ad5
remove hyperlane as a submodule
nadim-az Dec 17, 2024
000a5e1
use fixed version of openzeppelin-contracts
nadim-az Dec 18, 2024
e419467
checkout specific version after installing submodule
nadim-az Dec 18, 2024
5fc418a
cleanup
nadim-az Dec 18, 2024
5e9379f
cleanup
nadim-az Dec 18, 2024
34a6383
Merge branch 'main' into na/add-e2e-test
nadim-az Dec 18, 2024
43b03ef
run e2e tests on every PR
nadim-az Dec 18, 2024
7beab47
rename erc20 -> usdc erc20
nadim-az Dec 18, 2024
10b16f8
nit
nadim-az Dec 18, 2024
5726a50
fix broadcast file path
nadim-az Dec 18, 2024
cc6efa1
remove submitorder script
nadim-az Dec 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: e2e
on:
workflow_dispatch:
push:
branches: [main]
pull_request:
env:
FOUNDRY_PROFILE: ci
FOUNDRY_VERSION: nightly

permissions:
contents: read

jobs:
e2e:
strategy:
fail-fast: false
matrix:
test:
- TestWithSolverTestSuite/TestDeploy
name: ${{ matrix.test }}
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: ${{ env.FOUNDRY_VERSION }}

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.22"
check-latest: true

- name: Install dependencies and run E2E Tests
run: |
make tidy
git submodule update --init --recursive
cd tests/e2e/lib/openzeppelin-contracts && git checkout v4.8.0
cd ../openzeppelin-contracts-upgradeable && git checkout v4.8.0
cd ../hyperlane-monorepo/solidity && yarn install --frozen-lockfile
cd ../../../../.. && make e2e-test

- name: Upload run-latest.json // this contains info about transactions that were submitted to chain in e2e test
uses: actions/upload-artifact@v4
with:
name: e2e-test-artifacts
path: |
tests/e2e/broadcast/**/run-latest.json
retention-days: 7
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
uses: actions/setup-go@v3
with:
go-version: "1.22"
- name: Make tests
- name: Run unit tests
run: |
make tidy
make test
make unit-test
lint:
runs-on: ubuntu-latest
steps:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ solver.db
vendor
.idea
config/local/config.yml
config/local/keys.json
config/local/keys.json
out
broadcast
cache
12 changes: 12 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[submodule "tests/e2e/lib/forge-std"]
path = tests/e2e/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "tests/e2e/lib/openzeppelin-contracts-upgradeable"]
path = tests/e2e/lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "tests/e2e/lib/openzeppelin-contracts"]
path = tests/e2e/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "tests/e2e/lib/hyperlane-monorepo"]
path = tests/e2e/lib/hyperlane-monorepo
url = https://github.com/hyperlane-xyz/hyperlane-monorepo
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,22 @@ run-solver:
###############################################################################
### Testing ###
###############################################################################
test:
go clean -testcache
go test --tags=test -v -race $(shell go list ./... | grep -v /scripts/)
.PHONY: unit-test
unit-test:
go test --tags=test -v -race $(shell go list ./... | grep -v /tests)

.PHONY: setup-foundry
setup-foundry:
cd tests/e2e && rm -rf lib && forge install \
foundry-rs/forge-std \
OpenZeppelin/[email protected] \
OpenZeppelin/[email protected] \
hyperlane-xyz/hyperlane-monorepo --no-commit \
&& cd lib/hyperlane-monorepo/solidity && yarn install --frozen-lockfile

.PHONY: e2e-test
e2e-test:
cd tests/e2e && go test -v ./

###############################################################################
### Developer Tools ###
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ docker run skip-go-fast-solver
### How to run tests

```shell
make test # run all tests
make unit-test

make setup-foundry # install end to end test dependencies
make e2e-test
```

### Database access
Expand Down
37 changes: 37 additions & 0 deletions tests/e2e/chainconfig/chain_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package chainconfig

import (
interchaintest "github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/chain/ethereum"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
)

var DefaultChainSpecs = []*interchaintest.ChainSpec{
// -- ETH --
{ChainConfig: ethereum.DefaultEthereumAnvilChainConfig("ethereum")},
// -- IBC-Go --
{
ChainConfig: ibc.ChainConfig{
Type: "cosmos",
Name: "ibc-go-simd",
ChainID: "simd-1",
Images: []ibc.DockerImage{
{
// TODO: Save this image to skip repository and import it from there instead
Repository: "ghcr.io/cosmos/ibc-go-simd", // FOR LOCAL IMAGE USE: Docker Image Name
Version: "poc-solidity-ibc-eureka", // FOR LOCAL IMAGE USE: Docker Image Tag
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it make sense to use a different docker image here?

UidGid: "1025:1025",
},
},
Bin: "simd",
Bech32Prefix: "cosmos",
Denom: "stake",
GasPrices: "0.00stake",
GasAdjustment: 1.3,
EncodingConfig: CosmosEncodingConfig(),
ModifyGenesis: defaultModifyGenesis(),
TrustingPeriod: "508h",
NoHostMount: false,
},
},
}
114 changes: 114 additions & 0 deletions tests/e2e/chainconfig/encoding.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package chainconfig

import (
"github.com/cosmos/gogoproto/proto"

txsigning "cosmossdk.io/x/tx/signing"
upgradetypes "cosmossdk.io/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/address"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdktestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/authz"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
grouptypes "github.com/cosmos/cosmos-sdk/x/group"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
proposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types"
feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
v7migrations "github.com/cosmos/ibc-go/v8/modules/core/02-client/migrations/v7"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
connectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
mock "github.com/cosmos/ibc-go/v8/modules/light-clients/00-mock"
solomachine "github.com/cosmos/ibc-go/v8/modules/light-clients/06-solomachine"
ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
localhost "github.com/cosmos/ibc-go/v8/modules/light-clients/09-localhost"

wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
)

// CosmosEncodingConfig returns the global E2E encoding config for simd.
func CosmosEncodingConfig() *sdktestutil.TestEncodingConfig {
return encodingConfig("cosmos")
}

// EncodingConfig returns the global E2E encoding config.
// It includes CosmosSDK, IBC, and Wasm messages
func encodingConfig(bech32Prefix string) *sdktestutil.TestEncodingConfig {
amino := codec.NewLegacyAmino()
interfaceRegistry, err := codectypes.NewInterfaceRegistryWithOptions(codectypes.InterfaceRegistryOptions{
ProtoFiles: proto.HybridResolver,
SigningOptions: txsigning.Options{
AddressCodec: address.Bech32Codec{
Bech32Prefix: bech32Prefix,
},
ValidatorAddressCodec: address.Bech32Codec{
Bech32Prefix: bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator,
},
},
})
if err != nil {
panic(err)
}

// ibc types
icacontrollertypes.RegisterInterfaces(interfaceRegistry)
icahosttypes.RegisterInterfaces(interfaceRegistry)
feetypes.RegisterInterfaces(interfaceRegistry)
transfertypes.RegisterInterfaces(interfaceRegistry)
v7migrations.RegisterInterfaces(interfaceRegistry)
clienttypes.RegisterInterfaces(interfaceRegistry)
connectiontypes.RegisterInterfaces(interfaceRegistry)
channeltypes.RegisterInterfaces(interfaceRegistry)
solomachine.RegisterInterfaces(interfaceRegistry)
ibctmtypes.RegisterInterfaces(interfaceRegistry)
localhost.RegisterInterfaces(interfaceRegistry)
mock.RegisterInterfaces(interfaceRegistry)

// sdk types
upgradetypes.RegisterInterfaces(interfaceRegistry)
banktypes.RegisterInterfaces(interfaceRegistry)
govv1beta1.RegisterInterfaces(interfaceRegistry)
govv1.RegisterInterfaces(interfaceRegistry)
authtypes.RegisterInterfaces(interfaceRegistry)
cryptocodec.RegisterInterfaces(interfaceRegistry)
grouptypes.RegisterInterfaces(interfaceRegistry)
proposaltypes.RegisterInterfaces(interfaceRegistry)
authz.RegisterInterfaces(interfaceRegistry)
txtypes.RegisterInterfaces(interfaceRegistry)
stakingtypes.RegisterInterfaces(interfaceRegistry)
minttypes.RegisterInterfaces(interfaceRegistry)
distrtypes.RegisterInterfaces(interfaceRegistry)
slashingtypes.RegisterInterfaces(interfaceRegistry)
consensustypes.RegisterInterfaces(interfaceRegistry)

// custom module types
wasmtypes.RegisterInterfaces(interfaceRegistry)

cdc := codec.NewProtoCodec(interfaceRegistry)

cfg := &sdktestutil.TestEncodingConfig{
InterfaceRegistry: interfaceRegistry,
Codec: cdc,
TxConfig: authtx.NewTxConfig(cdc, authtx.DefaultSignModes),
Amino: amino,
}

return cfg
}
79 changes: 79 additions & 0 deletions tests/e2e/chainconfig/genesis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package chainconfig

import (
"bytes"
"encoding/json"
"fmt"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"

"github.com/strangelove-ventures/interchaintest/v8/ibc"
)

func defaultModifyGenesis() func(ibc.ChainConfig, []byte) ([]byte, error) {
return func(chainConfig ibc.ChainConfig, genBz []byte) ([]byte, error) {
appGenesis, err := genutiltypes.AppGenesisFromReader(bytes.NewReader(genBz))
if err != nil {
return nil, fmt.Errorf("failed to unmarshal genesis bytes: %w", err)
}

var appState genutiltypes.AppMap
if err := json.Unmarshal(appGenesis.AppState, &appState); err != nil {
return nil, fmt.Errorf("failed to unmarshal app state: %w", err)
}

// modify the gov v1 app state
govGenBz, err := modifyGovV1AppState(chainConfig, appState[govtypes.ModuleName])
if err != nil {
return nil, fmt.Errorf("failed to modify gov v1 app state: %w", err)
}

appState[govtypes.ModuleName] = govGenBz

// marshal the app state
appGenesis.AppState, err = json.Marshal(appState)
if err != nil {
return nil, fmt.Errorf("failed to marshal app state: %w", err)
}

res, err := json.MarshalIndent(appGenesis, "", " ")
if err != nil {
return nil, fmt.Errorf("failed to marshal app genesis: %w", err)
}

return res, nil
}
}

// modifyGovV1AppState takes the existing gov app state and marshals it to a govv1 GenesisState.
func modifyGovV1AppState(chainConfig ibc.ChainConfig, govAppState []byte) ([]byte, error) {
cdc := CosmosEncodingConfig().Codec

govGenesisState := &govv1.GenesisState{}
if err := cdc.UnmarshalJSON(govAppState, govGenesisState); err != nil {
return nil, fmt.Errorf("failed to unmarshal genesis bytes into gov genesis state: %w", err)
}

if govGenesisState.Params == nil {
govGenesisState.Params = &govv1.Params{}
}
var (
MaxDepositPeriod = time.Second * 10
VotingPeriod = time.Second * 30
)

govGenesisState.Params.MinDeposit = sdk.NewCoins(sdk.NewCoin(chainConfig.Denom, govv1.DefaultMinDepositTokens))
govGenesisState.Params.MaxDepositPeriod = &MaxDepositPeriod
govGenesisState.Params.VotingPeriod = &VotingPeriod

govGenBz, err := cdc.MarshalJSON(govGenesisState)
if err != nil {
return nil, fmt.Errorf("failed to marshal gov genesis state: %w", err)
}

return govGenBz, nil
}
Loading
Loading