Commit 79c8fe83 authored by protolambda's avatar protolambda Committed by GitHub

cannon: move example test programs into testdata directory to prevent Go tool noise (#11379)

parent e6dd1ee9
......@@ -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: |
......
......@@ -5,7 +5,7 @@ cache
venv
.idea
*.log
example/bin
testdata/example/bin
contracts/out
state.json
*.json
......
......@@ -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
......
......@@ -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
......
......@@ -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)
......
......@@ -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")
......
......@@ -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")
......
......@@ -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
......
......@@ -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)
......
# 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.
......@@ -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 => ../../../..
......@@ -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 => ../../../..
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment