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

op-e2e: Organize e2e system tests in subdirs #11939

Merged
merged 5 commits into from
Sep 17, 2024
Merged
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
10 changes: 5 additions & 5 deletions op-e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ test-external-%: pre-test
$(go_test) $(go_test_flags) --externalL2 ./external_$*/

test-ws: pre-test
$(go_test) $(go_test_flags) . ./e2eutils/...
$(go_test) $(go_test_flags) ./system/... ./e2eutils/... ./opgeth/... ./interop/...
.PHONY: test-ws

test-actions: pre-test
$(go_test) $(go_test_flags) ./actions/...
.PHONY: test-actions

test-http: pre-test
OP_E2E_USE_HTTP=true $(go_test) $(go_test_flags) . ./e2eutils/...
OP_E2E_USE_HTTP=true $(go_test) $(go_test_flags) ./system/... ./e2eutils/... ./opgeth/... ./interop/...
.PHONY: test-http

test-cannon: pre-test
Expand Down Expand Up @@ -71,7 +71,7 @@ clean:
.PHONY: clean

fuzz:
go test -run NOTAREALTEST -tags cgo_test -v -fuzztime 10s -fuzz FuzzFjordCostFunction ./
go test -run NOTAREALTEST -tags cgo_test -v -fuzztime 10s -fuzz FuzzFastLzGethSolidity ./
go test -run NOTAREALTEST -tags cgo_test -v -fuzztime 10s -fuzz FuzzFastLzCgo ./
go test -run NOTAREALTEST -tags cgo_test -v -fuzztime 10s -fuzz FuzzFjordCostFunction ./opgeth
go test -run NOTAREALTEST -tags cgo_test -v -fuzztime 10s -fuzz FuzzFastLzGethSolidity ./opgeth
go test -run NOTAREALTEST -tags cgo_test -v -fuzztime 10s -fuzz FuzzFastLzCgo ./opgeth

4 changes: 2 additions & 2 deletions op-e2e/actions/helpers/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import (
"github.com/stretchr/testify/require"

"github.com/ethereum-optimism/optimism/op-chain-ops/crossdomain"
e2e "github.com/ethereum-optimism/optimism/op-e2e"
legacybindings "github.com/ethereum-optimism/optimism/op-e2e/bindings"
"github.com/ethereum-optimism/optimism/op-e2e/config"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
e2ehelpers "github.com/ethereum-optimism/optimism/op-e2e/system/helpers"
"github.com/ethereum-optimism/optimism/op-node/bindings"
bindingspreview "github.com/ethereum-optimism/optimism/op-node/bindings/preview"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
Expand Down Expand Up @@ -449,7 +449,7 @@ func (s *CrossLayerUser) getLatestWithdrawalParams(t Testing) (*withdrawals.Prov

header, err := s.L2.env.EthCl.HeaderByNumber(t.Ctx(), l2OutputBlockNr)
require.NoError(t, err)
params, err := e2e.ProveWithdrawalParameters(t.Ctx(), s.L2.env.Bindings.ProofClient, s.L2.env.EthCl, s.L2.env.EthCl, s.lastL2WithdrawalTxHash, header, &s.L1.env.Bindings.L2OutputOracle.L2OutputOracleCaller, &s.L1.env.Bindings.DisputeGameFactory.DisputeGameFactoryCaller, &s.L1.env.Bindings.OptimismPortal2.OptimismPortal2Caller)
params, err := e2ehelpers.ProveWithdrawalParameters(t.Ctx(), s.L2.env.Bindings.ProofClient, s.L2.env.EthCl, s.L2.env.EthCl, s.lastL2WithdrawalTxHash, header, &s.L1.env.Bindings.L2OutputOracle.L2OutputOracleCaller, &s.L1.env.Bindings.DisputeGameFactory.DisputeGameFactoryCaller, &s.L1.env.Bindings.OptimismPortal2.OptimismPortal2Caller)
require.NoError(t, err)

return &params, nil
Expand Down
8 changes: 4 additions & 4 deletions op-e2e/devnet/devnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"testing"
"time"

e2e "github.com/ethereum-optimism/optimism/op-e2e"
"github.com/ethereum-optimism/optimism/op-service/testlog"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/ethereum-optimism/optimism/op-e2e/system/bridge"
"github.com/ethereum-optimism/optimism/op-service/testlog"
)

func TestDevnet(t *testing.T) {
Expand All @@ -29,7 +29,7 @@ func TestDevnet(t *testing.T) {
})
t.Run("Withdrawal", func(t *testing.T) {
t.Parallel()
e2e.RunWithdrawalsTest(t, sys)
bridge.RunWithdrawalsTest(t, sys)
})
}

Expand Down
13 changes: 7 additions & 6 deletions op-e2e/devnet/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"os"
"path/filepath"

"github.com/ethereum-optimism/optimism/op-e2e/system/e2esys"

"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
e2e "github.com/ethereum-optimism/optimism/op-e2e"
"github.com/ethereum-optimism/optimism/op-e2e/config"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
op_service "github.com/ethereum-optimism/optimism/op-service"
Expand All @@ -29,7 +30,7 @@ type System struct {
L1 *ethclient.Client
L2 *ethclient.Client
Rollup *sources.RollupClient
Cfg e2e.SystemConfig
Cfg e2esys.SystemConfig
}

func NewSystem(ctx context.Context, lgr log.Logger) (sys *System, err error) {
Expand Down Expand Up @@ -69,7 +70,7 @@ func NewSystem(ctx context.Context, lgr log.Logger) (sys *System, err error) {
}

// Incomplete SystemConfig suffices for withdrawal test (only consumer right now)
sys.Cfg = e2e.SystemConfig{
sys.Cfg = e2esys.SystemConfig{
DeployConfig: deployConfig,
L1Deployments: config.L1Deployments.Copy(),
Secrets: secrets,
Expand All @@ -79,9 +80,9 @@ func NewSystem(ctx context.Context, lgr log.Logger) (sys *System, err error) {

func (s System) NodeClient(role string) *ethclient.Client {
switch role {
case e2e.RoleL1:
case e2esys.RoleL1:
return s.L1
case e2e.RoleSeq, e2e.RoleVerif:
case e2esys.RoleSeq, e2esys.RoleVerif:
// we have only one L2 node
return s.L2
default:
Expand All @@ -94,7 +95,7 @@ func (s System) RollupClient(string) *sources.RollupClient {
return s.Rollup
}

func (s System) Config() e2e.SystemConfig {
func (s System) Config() e2esys.SystemConfig {
return s.Cfg
}

Expand Down
20 changes: 20 additions & 0 deletions op-e2e/helper.go → op-e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,33 @@ package op_e2e

import (
"crypto/md5"
"fmt"
"os"
"runtime"
"strconv"
"strings"
"testing"

"github.com/ethereum-optimism/optimism/op-e2e/config"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
)

func RunMain(m *testing.M) {
if config.ExternalL2Shim != "" {
fmt.Println("Running tests with external L2 process adapter at ", config.ExternalL2Shim)
// As these are integration tests which launch many other processes, the
// default parallelism makes the tests flaky. This change aims to
// reduce the flakiness of these tests.
maxProcs := runtime.NumCPU() / 4
if maxProcs == 0 {
maxProcs = 1
}
runtime.GOMAXPROCS(maxProcs)
}

os.Exit(m.Run())
}

var enableParallelTesting bool = os.Getenv("OP_E2E_DISABLE_PARALLEL") != "true"

func InitParallel(t e2eutils.TestingBase, args ...func(t e2eutils.TestingBase)) {
Expand Down
2 changes: 1 addition & 1 deletion op-e2e/tracer.go → op-e2e/e2eutils/opnode/tracer.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package op_e2e
package opnode

import (
"context"
Expand Down
5 changes: 3 additions & 2 deletions op-e2e/external_geth/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (
"testing"
"time"

"github.com/ethereum-optimism/optimism/op-e2e/system/e2esys"

"github.com/stretchr/testify/require"

e2e "github.com/ethereum-optimism/optimism/op-e2e"
"github.com/ethereum-optimism/optimism/op-e2e/config"
"github.com/ethereum-optimism/optimism/op-service/endpoint"
)
Expand All @@ -37,7 +38,7 @@ func TestShim(t *testing.T) {

config.EthNodeVerbosity = config.LegacyLevelDebug

ec := (&e2e.ExternalRunner{
ec := (&e2esys.ExternalRunner{
Name: "TestShim",
BinPath: shimPath,
}).Run(t)
Expand Down
10 changes: 6 additions & 4 deletions op-e2e/faultproofs/cannon_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import (
"testing"
"time"

op_e2e "github.com/ethereum-optimism/optimism/op-e2e"
"github.com/ethereum-optimism/optimism/op-e2e/system/e2esys"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
Expand All @@ -23,7 +26,6 @@ import (

"github.com/ethereum-optimism/optimism/cannon/mipsevm"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/utils"
op_e2e "github.com/ethereum-optimism/optimism/op-e2e"
"github.com/ethereum-optimism/optimism/op-e2e/bindings"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum-optimism/optimism/op-service/predeploys"
Expand All @@ -35,7 +37,7 @@ func TestBenchmarkCannon_FPP(t *testing.T) {

op_e2e.InitParallel(t, op_e2e.UsesCannon)
ctx := context.Background()
cfg := op_e2e.DefaultSystemConfig(t)
cfg := e2esys.DefaultSystemConfig(t)
// We don't need a verifier - just the sequencer is enough
delete(cfg.Nodes, "verifier")
// Use a small sequencer window size to avoid test timeout while waiting for empty blocks
Expand Down Expand Up @@ -102,7 +104,7 @@ func TestBenchmarkCannon_FPP(t *testing.T) {
// TODO(client-pod#906): Use maximum witness size for assertions against pages allocated by the VM
}

func createBigContracts(ctx context.Context, t *testing.T, cfg op_e2e.SystemConfig, client *ethclient.Client, key *ecdsa.PrivateKey, numContracts int) []common.Address {
func createBigContracts(ctx context.Context, t *testing.T, cfg e2esys.SystemConfig, client *ethclient.Client, key *ecdsa.PrivateKey, numContracts int) []common.Address {
/*
contract Big {
bytes constant foo = hex"<24.4 KB of random data>";
Expand Down Expand Up @@ -162,7 +164,7 @@ func createBigContracts(ctx context.Context, t *testing.T, cfg op_e2e.SystemConf
return addrs
}

func callBigContracts(ctx context.Context, t *testing.T, cfg op_e2e.SystemConfig, client *ethclient.Client, key *ecdsa.PrivateKey, addrs []common.Address) *types.Receipt {
func callBigContracts(ctx context.Context, t *testing.T, cfg e2esys.SystemConfig, client *ethclient.Client, key *ecdsa.PrivateKey, addrs []common.Address) *types.Receipt {
multicall3, err := bindings.NewMultiCall3(predeploys.MultiCall3Addr, client)
require.NoError(t, err)

Expand Down
1 change: 1 addition & 0 deletions op-e2e/faultproofs/challenge_preimage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

op_e2e "github.com/ethereum-optimism/optimism/op-e2e"

"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/disputegame"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/disputegame/preimage"
Expand Down
1 change: 1 addition & 0 deletions op-e2e/faultproofs/multi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

op_e2e "github.com/ethereum-optimism/optimism/op-e2e"

"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/disputegame"
"github.com/ethereum/go-ethereum/common"
Expand Down
3 changes: 2 additions & 1 deletion op-e2e/faultproofs/output_alphabet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"testing"
"time"

"github.com/ethereum-optimism/optimism/op-challenger/game/types"
op_e2e "github.com/ethereum-optimism/optimism/op-e2e"

"github.com/ethereum-optimism/optimism/op-challenger/game/types"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/disputegame"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
Expand Down
3 changes: 2 additions & 1 deletion op-e2e/faultproofs/output_cannon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"fmt"
"testing"

op_e2e "github.com/ethereum-optimism/optimism/op-e2e"

"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/utils"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/types"
gameTypes "github.com/ethereum-optimism/optimism/op-challenger/game/types"
op_e2e "github.com/ethereum-optimism/optimism/op-e2e"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/disputegame"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/disputegame/preimage"
Expand Down
15 changes: 9 additions & 6 deletions op-e2e/faultproofs/precompile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (
"path/filepath"
"testing"

op_e2e "github.com/ethereum-optimism/optimism/op-e2e"
"github.com/ethereum-optimism/optimism/op-e2e/system/e2esys"
"github.com/ethereum-optimism/optimism/op-e2e/system/helpers"

"github.com/ethereum-optimism/optimism/cannon/mipsevm/versions"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
Expand All @@ -19,7 +23,6 @@ import (
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/utils"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/vm"
"github.com/ethereum-optimism/optimism/op-challenger/metrics"
op_e2e "github.com/ethereum-optimism/optimism/op-e2e"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/disputegame"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
Expand Down Expand Up @@ -75,7 +78,7 @@ func TestPrecompiles(t *testing.T) {
op_e2e.InitParallel(t, op_e2e.UsesCannon)
ctx := context.Background()
genesisTime := hexutil.Uint64(0)
cfg := op_e2e.EcotoneSystemConfig(t, &genesisTime)
cfg := e2esys.EcotoneSystemConfig(t, &genesisTime)
// We don't need a verifier - just the sequencer is enough
delete(cfg.Nodes, "verifier")
// Use a small sequencer window size to avoid test timeout while waiting for empty blocks
Expand All @@ -101,7 +104,7 @@ func TestPrecompiles(t *testing.T) {
l2Head := agreedL2Output.BlockRef.Hash
l2OutputRoot := agreedL2Output.OutputRoot

receipt := op_e2e.SendL2Tx(t, cfg, l2Seq, aliceKey, func(opts *op_e2e.TxOpts) {
receipt := helpers.SendL2Tx(t, cfg, l2Seq, aliceKey, func(opts *helpers.TxOpts) {
opts.Gas = 1_000_000
opts.ToAddr = &test.address
opts.Nonce = 0
Expand Down Expand Up @@ -140,7 +143,7 @@ func TestPrecompiles(t *testing.T) {

l2Seq := sys.NodeClient("sequencer")
aliceKey := sys.Cfg.Secrets.Alice
receipt := op_e2e.SendL2Tx(t, sys.Cfg, l2Seq, aliceKey, func(opts *op_e2e.TxOpts) {
receipt := helpers.SendL2Tx(t, sys.Cfg, l2Seq, aliceKey, func(opts *helpers.TxOpts) {
opts.Gas = 1_000_000
opts.ToAddr = &test.address
opts.Nonce = 0
Expand Down Expand Up @@ -174,7 +177,7 @@ func TestGranitePrecompiles(t *testing.T) {
op_e2e.InitParallel(t, op_e2e.UsesCannon)
ctx := context.Background()
genesisTime := hexutil.Uint64(0)
cfg := op_e2e.GraniteSystemConfig(t, &genesisTime)
cfg := e2esys.GraniteSystemConfig(t, &genesisTime)
// We don't need a verifier - just the sequencer is enough
delete(cfg.Nodes, "verifier")
// Use a small sequencer window size to avoid test timeout while waiting for empty blocks
Expand Down Expand Up @@ -242,7 +245,7 @@ func TestGranitePrecompiles(t *testing.T) {
runCannon(t, ctx, sys, inputs)
}

func runCannon(t *testing.T, ctx context.Context, sys *op_e2e.System, inputs utils.LocalGameInputs, extraVmArgs ...string) {
func runCannon(t *testing.T, ctx context.Context, sys *e2esys.System, inputs utils.LocalGameInputs, extraVmArgs ...string) {
l1Endpoint := sys.NodeEndpoint("l1").RPC()
l1Beacon := sys.L1BeaconEndpoint().RestHTTP()
rollupEndpoint := sys.RollupEndpoint("sequencer").RPC()
Expand Down
1 change: 1 addition & 0 deletions op-e2e/faultproofs/preimages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"

op_e2e "github.com/ethereum-optimism/optimism/op-e2e"

"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/disputegame"
preimage "github.com/ethereum-optimism/optimism/op-preimage"
"github.com/ethereum-optimism/optimism/op-program/client"
Expand Down
Loading
Loading