Commit 2ab1eb7e authored by protolambda's avatar protolambda

mipsevm,cli: step fn fixes, fix lint

parent 9ce6c04a
...@@ -214,9 +214,9 @@ func Run(ctx *cli.Context) error { ...@@ -214,9 +214,9 @@ func Run(ctx *cli.Context) error {
proofFmt := ctx.String(RunProofFmtFlag.Name) proofFmt := ctx.String(RunProofFmtFlag.Name)
snapshotFmt := ctx.String(RunSnapshotFmtFlag.Name) snapshotFmt := ctx.String(RunSnapshotFmtFlag.Name)
step := us.Step stepFn := us.Step
if po.cmd != nil { if po.cmd != nil {
step = Guard(po.cmd.ProcessState, step) stepFn = Guard(po.cmd.ProcessState, stepFn)
} }
for !state.Exited { for !state.Exited {
...@@ -241,7 +241,7 @@ func Run(ctx *cli.Context) error { ...@@ -241,7 +241,7 @@ func Run(ctx *cli.Context) error {
if proofAt(state) { if proofAt(state) {
preStateHash := crypto.Keccak256Hash(state.EncodeWitness()) preStateHash := crypto.Keccak256Hash(state.EncodeWitness())
witness, err := us.Step(true) witness, err := stepFn(true)
if err != nil { if err != nil {
return fmt.Errorf("failed at proof-gen step %d (PC: %08x): %w", step, state.PC, err) return fmt.Errorf("failed at proof-gen step %d (PC: %08x): %w", step, state.PC, err)
} }
......
...@@ -74,7 +74,8 @@ func TestState(t *testing.T) { ...@@ -74,7 +74,8 @@ func TestState(t *testing.T) {
if us.state.PC == endAddr { if us.state.PC == endAddr {
break break
} }
us.Step(false) _, err := us.Step(false)
require.NoError(t, err)
} }
require.Equal(t, uint32(endAddr), us.state.PC, "must reach end") require.Equal(t, uint32(endAddr), us.state.PC, "must reach end")
// inspect test result // inspect test result
...@@ -109,7 +110,8 @@ func TestHello(t *testing.T) { ...@@ -109,7 +110,8 @@ func TestHello(t *testing.T) {
if us.state.Exited { if us.state.Exited {
break break
} }
us.Step(false) _, err := us.Step(false)
require.NoError(t, err)
} }
require.True(t, state.Exited, "must complete program") require.True(t, state.Exited, "must complete program")
...@@ -215,7 +217,8 @@ func TestClaim(t *testing.T) { ...@@ -215,7 +217,8 @@ func TestClaim(t *testing.T) {
if us.state.Exited { if us.state.Exited {
break break
} }
us.Step(false) _, err := us.Step(false)
require.NoError(t, err)
} }
require.True(t, state.Exited, "must complete program") require.True(t, state.Exited, "must complete program")
......
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