diff --git a/.circleci/config.yml b/.circleci/config.yml index 6931718f4879..81de1bab202c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -137,7 +137,7 @@ jobs: - run: name: build Cannon example binaries command: make elf # only compile ELF binaries with Go, we do not have MIPS GCC for creating the debug-dumps. - working_directory: cannon/example + working_directory: cannon/testdata/example - run: name: Cannon Go lint command: | diff --git a/cannon/.gitignore b/cannon/.gitignore index fc1a1f3b9949..c3e45199f0ed 100644 --- a/cannon/.gitignore +++ b/cannon/.gitignore @@ -5,7 +5,7 @@ cache venv .idea *.log -example/bin +testdata/example/bin contracts/out state.json *.json diff --git a/cannon/Makefile b/cannon/Makefile index f815b9f37474..0240b7df095f 100644 --- a/cannon/Makefile +++ b/cannon/Makefile @@ -20,7 +20,7 @@ clean: rm -rf bin elf: - make -C ./example elf + make -C ./testdata/example elf contract: cd ../packages/contracts-bedrock && forge build diff --git a/cannon/README.md b/cannon/README.md index 5ff497162f33..e9e751ce2ffe 100644 --- a/cannon/README.md +++ b/cannon/README.md @@ -83,7 +83,7 @@ The smart-contracts are integrated into the Optimism monorepo contracts: Example programs that can be run and proven with Cannon. Optional dependency, but required for `mipsevm` Go tests. -See [`example/Makefile`](./example/Makefile) for building the example MIPS binaries. +See [`testdata/example/Makefile`](./testdata/example/Makefile) for building the example MIPS binaries. ## License diff --git a/cannon/mipsevm/multithreaded/instrumented_test.go b/cannon/mipsevm/multithreaded/instrumented_test.go index 50382ae18536..c20126d3ca22 100644 --- a/cannon/mipsevm/multithreaded/instrumented_test.go +++ b/cannon/mipsevm/multithreaded/instrumented_test.go @@ -32,7 +32,7 @@ func TestInstrumentedState_Claim(t *testing.T) { } func TestInstrumentedState_MultithreadedProgram(t *testing.T) { - state := testutil.LoadELFProgram(t, "../../example/bin/multithreaded.elf", CreateInitialState, false) + state := testutil.LoadELFProgram(t, "../../testdata/example/bin/multithreaded.elf", CreateInitialState, false) oracle := testutil.StaticOracle(t, []byte{}) var stdOutBuf, stdErrBuf bytes.Buffer @@ -56,7 +56,7 @@ func TestInstrumentedState_MultithreadedProgram(t *testing.T) { func TestInstrumentedState_Alloc(t *testing.T) { t.Skip("TODO(client-pod#906): Currently failing - need to debug.") - state := testutil.LoadELFProgram(t, "../../example/bin/alloc.elf", CreateInitialState, false) + state := testutil.LoadELFProgram(t, "../../testdata/example/bin/alloc.elf", CreateInitialState, false) const numAllocs = 100 // where each alloc is a 32 MiB chunk oracle := testutil.AllocOracle(t, numAllocs) diff --git a/cannon/mipsevm/multithreaded/state_test.go b/cannon/mipsevm/multithreaded/state_test.go index e6805423b165..e9dbef2db346 100644 --- a/cannon/mipsevm/multithreaded/state_test.go +++ b/cannon/mipsevm/multithreaded/state_test.go @@ -86,7 +86,7 @@ func TestState_EncodeWitness(t *testing.T) { } func TestState_JSONCodec(t *testing.T) { - elfProgram, err := elf.Open("../../example/bin/hello.elf") + elfProgram, err := elf.Open("../../testdata/example/bin/hello.elf") require.NoError(t, err, "open ELF file") state, err := program.LoadELF(elfProgram, CreateInitialState) require.NoError(t, err, "load ELF into state") diff --git a/cannon/mipsevm/singlethreaded/state_test.go b/cannon/mipsevm/singlethreaded/state_test.go index 2ab4a5009b0e..27588f8b67ed 100644 --- a/cannon/mipsevm/singlethreaded/state_test.go +++ b/cannon/mipsevm/singlethreaded/state_test.go @@ -58,7 +58,7 @@ func TestStateHash(t *testing.T) { } func TestStateJSONCodec(t *testing.T) { - elfProgram, err := elf.Open("../../example/bin/hello.elf") + elfProgram, err := elf.Open("../../testdata/example/bin/hello.elf") require.NoError(t, err, "open ELF file") state, err := program.LoadELF(elfProgram, CreateInitialState) require.NoError(t, err, "load ELF into state") diff --git a/cannon/mipsevm/tests/evm_test.go b/cannon/mipsevm/tests/evm_test.go index 361a924eb34d..f7ca26589c80 100644 --- a/cannon/mipsevm/tests/evm_test.go +++ b/cannon/mipsevm/tests/evm_test.go @@ -427,7 +427,7 @@ func TestHelloEVM(t *testing.T) { evm.SetTracer(tracer) testutil.LogStepFailureAtCleanup(t, evm) - state := testutil.LoadELFProgram(t, "../../example/bin/hello.elf", singlethreaded.CreateInitialState, true) + state := testutil.LoadELFProgram(t, "../../testdata/example/bin/hello.elf", singlethreaded.CreateInitialState, true) var stdOutBuf, stdErrBuf bytes.Buffer goState := singlethreaded.NewInstrumentedState(state, nil, io.MultiWriter(&stdOutBuf, os.Stdout), io.MultiWriter(&stdErrBuf, os.Stderr), nil) @@ -469,7 +469,7 @@ func TestClaimEVM(t *testing.T) { evm.SetTracer(tracer) testutil.LogStepFailureAtCleanup(t, evm) - state := testutil.LoadELFProgram(t, "../../example/bin/claim.elf", singlethreaded.CreateInitialState, true) + state := testutil.LoadELFProgram(t, "../../testdata/example/bin/claim.elf", singlethreaded.CreateInitialState, true) oracle, expectedStdOut, expectedStdErr := testutil.ClaimTestOracle(t) var stdOutBuf, stdErrBuf bytes.Buffer diff --git a/cannon/mipsevm/testutil/vmtests.go b/cannon/mipsevm/testutil/vmtests.go index 71bb9937f224..c016b91e076a 100644 --- a/cannon/mipsevm/testutil/vmtests.go +++ b/cannon/mipsevm/testutil/vmtests.go @@ -78,7 +78,7 @@ func RunVMTests_OpenMips[T mipsevm.FPVMState](t *testing.T, stateFactory StateFa } func RunVMTest_Hello[T mipsevm.FPVMState](t *testing.T, initState program.CreateInitialFPVMState[T], vmFactory VMFactory[T], doPatchGo bool) { - state := LoadELFProgram(t, "../../example/bin/hello.elf", initState, doPatchGo) + state := LoadELFProgram(t, "../../testdata/example/bin/hello.elf", initState, doPatchGo) var stdOutBuf, stdErrBuf bytes.Buffer us := vmFactory(state, nil, io.MultiWriter(&stdOutBuf, os.Stdout), io.MultiWriter(&stdErrBuf, os.Stderr), CreateLogger()) @@ -99,7 +99,7 @@ func RunVMTest_Hello[T mipsevm.FPVMState](t *testing.T, initState program.Create } func RunVMTest_Claim[T mipsevm.FPVMState](t *testing.T, initState program.CreateInitialFPVMState[T], vmFactory VMFactory[T], doPatchGo bool) { - state := LoadELFProgram(t, "../../example/bin/claim.elf", initState, doPatchGo) + state := LoadELFProgram(t, "../../testdata/example/bin/claim.elf", initState, doPatchGo) oracle, expectedStdOut, expectedStdErr := ClaimTestOracle(t) diff --git a/cannon/testdata/README.md b/cannon/testdata/README.md new file mode 100644 index 000000000000..4730cac00b0d --- /dev/null +++ b/cannon/testdata/README.md @@ -0,0 +1,11 @@ +# Cannon testdata + +These example Go programs are used in tests, +and encapsulated as their own Go modules. + +## Testdata + +The `testdata` directory name (special Go exception) prevents tools like `go mod tidy` +that run from the monorepo root from picking up on the test data, +preventing noisy dependabot PRs. + diff --git a/cannon/example/Makefile b/cannon/testdata/example/Makefile similarity index 100% rename from cannon/example/Makefile rename to cannon/testdata/example/Makefile diff --git a/cannon/example/alloc/go.mod b/cannon/testdata/example/alloc/go.mod similarity index 98% rename from cannon/example/alloc/go.mod rename to cannon/testdata/example/alloc/go.mod index d2e4bd2239f3..5ead2ebe8af6 100644 --- a/cannon/example/alloc/go.mod +++ b/cannon/testdata/example/alloc/go.mod @@ -11,4 +11,4 @@ require ( golang.org/x/sys v0.22.0 // indirect ) -replace github.com/ethereum-optimism/optimism v0.0.0 => ../../.. +replace github.com/ethereum-optimism/optimism v0.0.0 => ../../../.. diff --git a/cannon/example/alloc/go.sum b/cannon/testdata/example/alloc/go.sum similarity index 100% rename from cannon/example/alloc/go.sum rename to cannon/testdata/example/alloc/go.sum diff --git a/cannon/example/alloc/main.go b/cannon/testdata/example/alloc/main.go similarity index 100% rename from cannon/example/alloc/main.go rename to cannon/testdata/example/alloc/main.go diff --git a/cannon/example/claim/go.mod b/cannon/testdata/example/claim/go.mod similarity index 98% rename from cannon/example/claim/go.mod rename to cannon/testdata/example/claim/go.mod index b7417d15317b..dfbd45f6f57c 100644 --- a/cannon/example/claim/go.mod +++ b/cannon/testdata/example/claim/go.mod @@ -11,4 +11,4 @@ require ( golang.org/x/sys v0.22.0 // indirect ) -replace github.com/ethereum-optimism/optimism v0.0.0 => ../../.. +replace github.com/ethereum-optimism/optimism v0.0.0 => ../../../.. diff --git a/cannon/example/claim/go.sum b/cannon/testdata/example/claim/go.sum similarity index 100% rename from cannon/example/claim/go.sum rename to cannon/testdata/example/claim/go.sum diff --git a/cannon/example/claim/main.go b/cannon/testdata/example/claim/main.go similarity index 100% rename from cannon/example/claim/main.go rename to cannon/testdata/example/claim/main.go diff --git a/cannon/example/hello/go.mod b/cannon/testdata/example/hello/go.mod similarity index 100% rename from cannon/example/hello/go.mod rename to cannon/testdata/example/hello/go.mod diff --git a/cannon/example/hello/main.go b/cannon/testdata/example/hello/main.go similarity index 100% rename from cannon/example/hello/main.go rename to cannon/testdata/example/hello/main.go diff --git a/cannon/example/multithreaded/go.mod b/cannon/testdata/example/multithreaded/go.mod similarity index 100% rename from cannon/example/multithreaded/go.mod rename to cannon/testdata/example/multithreaded/go.mod diff --git a/cannon/example/multithreaded/main.go b/cannon/testdata/example/multithreaded/main.go similarity index 100% rename from cannon/example/multithreaded/main.go rename to cannon/testdata/example/multithreaded/main.go