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 containing contract deployments #9

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
68 changes: 68 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: e2e
on:
workflow_dispatch:
push:
branches: [main]
pull_request:
paths:
- "**.rs"
- "**.go"
- "**.toml"
- "**.lock"
- "**.mod"
- "**.sum"
- "**.sol"
- ".github/workflows/e2e.yml"
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
with:
submodules: recursive

- 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
run: |
forge install
go mod download
sudo apt-get update
sudo apt-get install -y build-essential

- name: Run E2E Tests
run: |
make tidy
make e2e-test

- name: Upload run-latest.json // this contains info about all the transactions that were submitted to chain in e2e test
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-test-artifacts
path: |
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.21"
- name: Make tests
- name: Run unit tests
run: |
make tidy
make test
make unit-test
lint:
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ conf/debug.yml
keys.json.plaintext
solver.db
vendor
.idea
.idea
lib
broadcast
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "lib/openzeppelin-contracts-upgradeable"]
path = lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,22 @@ deps:
go mod download

run-solver:
quickstart=true ${SERVER_BIN}

quickstart=true ${SERVER_BIN}

###############################################################################
### 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 && forge install foundry-rs/forge-std OpenZeppelin/openzeppelin-contracts OpenZeppelin/openzeppelin-contracts-upgradeable --no-commit

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

###############################################################################
### Developer Tools ###
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ make run-solver --config <configFilePath> --keys <keysFilePath> --key-store-type
### How to run tests

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

### Database access
Expand Down
33 changes: 33 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Full reference https://github.com/foundry-rs/foundry/tree/master/crates/config

[profile.default]
auto_detect_solc = false
block_timestamp = 1_680_220_800 # March 31, 2023 at 00:00 GMT
bytecode_hash = "none"
evm_version = "shanghai"
fuzz = { runs = 1_000_00 }
gas_reports = ["*"]
optimizer = true
optimizer_runs = 10_000
out = "out"
script = "script"
solc = "0.8.28"
src = "src"
test = "test"
fs_permissions = [{ access = "read-write", path = "./" },]
libs = ['lib']
remappings = [
'@openzeppelin/=lib/openzeppelin-contracts/',
'@openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/',
'forge-std/=lib/forge-std/src/',
]

[fmt]
bracket_spacing = true
int_types = "long"
line_length = 120
multiline_func_header = "all"
number_underscore = "thousands"
quote_style = "double"
tab_width = 4
wrap_comments = true
6 changes: 6 additions & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@openzeppelin/=lib/openzeppelin-contracts/
@openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/
forge-std/=lib/forge-std/src/
ds-test/=lib/openzeppelin-contracts-upgradeable/lib/forge-std/lib/ds-test/src/
erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/
halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/
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
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
}
Loading
Loading