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: ...@@ -137,7 +137,7 @@ jobs:
- run: - run:
name: build Cannon example binaries 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. 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: - run:
name: Cannon Go lint name: Cannon Go lint
command: | command: |
......
...@@ -5,7 +5,7 @@ cache ...@@ -5,7 +5,7 @@ cache
venv venv
.idea .idea
*.log *.log
example/bin testdata/example/bin
contracts/out contracts/out
state.json state.json
*.json *.json
......
...@@ -20,7 +20,7 @@ clean: ...@@ -20,7 +20,7 @@ clean:
rm -rf bin rm -rf bin
elf: elf:
make -C ./example elf make -C ./testdata/example elf
contract: contract:
cd ../packages/contracts-bedrock && forge build cd ../packages/contracts-bedrock && forge build
......
...@@ -83,7 +83,7 @@ The smart-contracts are integrated into the Optimism monorepo contracts: ...@@ -83,7 +83,7 @@ The smart-contracts are integrated into the Optimism monorepo contracts:
Example programs that can be run and proven with Cannon. Example programs that can be run and proven with Cannon.
Optional dependency, but required for `mipsevm` Go tests. 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 ## License
......
...@@ -32,7 +32,7 @@ func TestInstrumentedState_Claim(t *testing.T) { ...@@ -32,7 +32,7 @@ func TestInstrumentedState_Claim(t *testing.T) {
} }
func TestInstrumentedState_MultithreadedProgram(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{}) oracle := testutil.StaticOracle(t, []byte{})
var stdOutBuf, stdErrBuf bytes.Buffer var stdOutBuf, stdErrBuf bytes.Buffer
...@@ -56,7 +56,7 @@ func TestInstrumentedState_MultithreadedProgram(t *testing.T) { ...@@ -56,7 +56,7 @@ func TestInstrumentedState_MultithreadedProgram(t *testing.T) {
func TestInstrumentedState_Alloc(t *testing.T) { func TestInstrumentedState_Alloc(t *testing.T) {
t.Skip("TODO(client-pod#906): Currently failing - need to debug.") 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 const numAllocs = 100 // where each alloc is a 32 MiB chunk
oracle := testutil.AllocOracle(t, numAllocs) oracle := testutil.AllocOracle(t, numAllocs)
......
...@@ -86,7 +86,7 @@ func TestState_EncodeWitness(t *testing.T) { ...@@ -86,7 +86,7 @@ func TestState_EncodeWitness(t *testing.T) {
} }
func TestState_JSONCodec(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") require.NoError(t, err, "open ELF file")
state, err := program.LoadELF(elfProgram, CreateInitialState) state, err := program.LoadELF(elfProgram, CreateInitialState)
require.NoError(t, err, "load ELF into state") require.NoError(t, err, "load ELF into state")
......
...@@ -58,7 +58,7 @@ func TestStateHash(t *testing.T) { ...@@ -58,7 +58,7 @@ func TestStateHash(t *testing.T) {
} }
func TestStateJSONCodec(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") require.NoError(t, err, "open ELF file")
state, err := program.LoadELF(elfProgram, CreateInitialState) state, err := program.LoadELF(elfProgram, CreateInitialState)
require.NoError(t, err, "load ELF into state") require.NoError(t, err, "load ELF into state")
......
...@@ -427,7 +427,7 @@ func TestHelloEVM(t *testing.T) { ...@@ -427,7 +427,7 @@ func TestHelloEVM(t *testing.T) {
evm.SetTracer(tracer) evm.SetTracer(tracer)
testutil.LogStepFailureAtCleanup(t, evm) 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 var stdOutBuf, stdErrBuf bytes.Buffer
goState := singlethreaded.NewInstrumentedState(state, nil, io.MultiWriter(&stdOutBuf, os.Stdout), io.MultiWriter(&stdErrBuf, os.Stderr), nil) 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) { ...@@ -469,7 +469,7 @@ func TestClaimEVM(t *testing.T) {
evm.SetTracer(tracer) evm.SetTracer(tracer)
testutil.LogStepFailureAtCleanup(t, evm) 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) oracle, expectedStdOut, expectedStdErr := testutil.ClaimTestOracle(t)
var stdOutBuf, stdErrBuf bytes.Buffer var stdOutBuf, stdErrBuf bytes.Buffer
......
...@@ -78,7 +78,7 @@ func RunVMTests_OpenMips[T mipsevm.FPVMState](t *testing.T, stateFactory StateFa ...@@ -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) { 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 var stdOutBuf, stdErrBuf bytes.Buffer
us := vmFactory(state, nil, io.MultiWriter(&stdOutBuf, os.Stdout), io.MultiWriter(&stdErrBuf, os.Stderr), CreateLogger()) 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 ...@@ -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) { 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) 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 ( ...@@ -11,4 +11,4 @@ require (
golang.org/x/sys v0.22.0 // indirect 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 ( ...@@ -11,4 +11,4 @@ require (
golang.org/x/sys v0.22.0 // indirect 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