-
Notifications
You must be signed in to change notification settings - Fork 2
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
nadim-az
wants to merge
43
commits into
main
Choose a base branch
from
na/add-e2e-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 c321849
remove lib
nadim-az 3a745be
add e2e test ci step
nadim-az fa18633
save run-latest.json artifact
nadim-az 882f199
lint
nadim-az d31a1fe
add broadcast to .gitignore
nadim-az 500bec3
remove unlicensed
nadim-az 6abcac2
deploy hpl contracts
nadim-az 6337c5b
Merge branch 'main' into na/add-e2e-test
nadim-az 6bb991a
deploy hyperlane scripts in a different forge step
nadim-az a70bc45
hyperlane lib
nadim-az 7becacc
use make command in ci workflow
nadim-az 707b5f5
fix ci
nadim-az 160b434
fix ci
nadim-az 14592fa
fix ci
nadim-az 56a3df2
add back gitmodules
nadim-az 19b8357
Update forge-std submodule
nadim-az 18fbe1f
updated hyperlane lib
nadim-az ad21be6
update ci workflow
nadim-az 9bf9d65
remove gitmodules
nadim-az 57c9a37
rename contract
nadim-az 5735c31
dont forge install in make command
nadim-az 73588c8
remove submodules completely
nadim-az 4447ba7
forge install: forge-std
nadim-az ee41b9b
add hyperlane
nadim-az 343e3eb
Update hyperlane submodule to use solver-e2etest-changes branch
nadim-az 8eed116
fixes
nadim-az 072cb99
update e2e workflow to use submodules again
nadim-az c45be88
init hyperlane separately
nadim-az 9de73fd
checkout hyperlane repo custom branch and apply patch changes
nadim-az 2157b71
use subtree instead of git submodule
nadim-az a6637a3
apply from top level dir
nadim-az d1d6ad5
remove hyperlane as a submodule
nadim-az 000a5e1
use fixed version of openzeppelin-contracts
nadim-az e419467
checkout specific version after installing submodule
nadim-az 5fc418a
cleanup
nadim-az 5e9379f
cleanup
nadim-az 34a6383
Merge branch 'main' into na/add-e2e-test
nadim-az 43b03ef
run e2e tests on every PR
nadim-az 7beab47
rename erc20 -> usdc erc20
nadim-az 10b16f8
nit
nadim-az 5726a50
fix broadcast file path
nadim-az cc6efa1
remove submitorder script
nadim-az File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,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 |
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 |
---|---|---|
|
@@ -6,4 +6,7 @@ solver.db | |
vendor | ||
.idea | ||
config/local/config.yml | ||
config/local/keys.json | ||
config/local/keys.json | ||
out | ||
broadcast | ||
cache |
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,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 |
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 |
---|---|---|
|
@@ -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 ### | ||
|
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,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 | ||
UidGid: "1025:1025", | ||
}, | ||
}, | ||
Bin: "simd", | ||
Bech32Prefix: "cosmos", | ||
Denom: "stake", | ||
GasPrices: "0.00stake", | ||
GasAdjustment: 1.3, | ||
EncodingConfig: CosmosEncodingConfig(), | ||
ModifyGenesis: defaultModifyGenesis(), | ||
TrustingPeriod: "508h", | ||
NoHostMount: false, | ||
}, | ||
}, | ||
} |
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,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 | ||
} |
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,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 | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?