@@ -13,6 +13,7 @@ import (
1313
1414 "github.com/ethereum/go-ethereum/log"
1515 "github.com/stretchr/testify/require"
16+ "golang.org/x/crypto/sha3"
1617
1718 "github.com/ethereum-optimism/optimism/cannon/mipsevm"
1819 "github.com/ethereum-optimism/optimism/cannon/mipsevm/memory"
@@ -69,8 +70,36 @@ func TestInstrumentedState_Claim(t *testing.T) {
6970 })
7071}
7172
73+ func TestInstrumentedState_Keccak (t * testing.T ) {
74+ runTestAcrossVms (t , "Keccak" , func (t * testing.T , vmFactory VMFactory [* State ], goTarget testutil.GoTarget ) {
75+ state , meta := testutil .LoadELFProgram (t , testutil .ProgramPath ("keccak" , goTarget ), CreateInitialState )
76+
77+ var stdOutBuf , stdErrBuf bytes.Buffer
78+ us := vmFactory (state , nil , io .MultiWriter (& stdOutBuf , os .Stdout ), io .MultiWriter (& stdErrBuf , os .Stderr ), testutil .CreateLogger (), meta )
79+
80+ for i := 0 ; i < 2000_000 ; i ++ {
81+ if us .GetState ().GetExited () {
82+ break
83+ }
84+ _ , err := us .Step (false )
85+ require .NoError (t , err )
86+ }
87+
88+ require .True (t , state .GetExited (), "must complete program" )
89+ require .Equal (t , uint8 (0 ), state .GetExitCode (), "exit with 0" )
90+
91+ var result []byte
92+ keccakState := sha3 .NewLegacyKeccak256 ()
93+ keccakState .Write ([]byte {1 , 2 , 3 })
94+ result = keccakState .Sum (result )
95+ expectedStdOut := fmt .Sprintf ("keccak program. result=%x\n " , result )
96+ require .Equal (t , expectedStdOut , stdOutBuf .String (), "stdout" )
97+ require .Equal (t , "" , stdErrBuf .String (), "stderr" )
98+ })
99+ }
100+
72101func TestInstrumentedState_Random (t * testing.T ) {
73- state , meta := testutil .LoadELFProgram (t , testutil .ProgramPath ("random" , testutil .Go1_24 ), CreateInitialState )
102+ state , meta := testutil .LoadELFProgram (t , testutil .ProgramPath ("random" , testutil .Go1_25 ), CreateInitialState )
74103
75104 var stdOutBuf , stdErrBuf bytes.Buffer
76105 us := latestVm (state , nil , io .MultiWriter (& stdOutBuf , os .Stdout ), io .MultiWriter (& stdErrBuf , os .Stderr ), testutil .CreateLogger (), meta )
@@ -420,6 +449,7 @@ func runTestsAcrossVms[T any](t *testing.T, testNamer TestNamer[T], testCases []
420449 variations := []VMVariations {
421450 {name : "Go 1.23 VM" , goTarget : testutil .Go1_23 , features : mipsevm.FeatureToggles {}},
422451 {name : "Go 1.24 VM" , goTarget : testutil .Go1_24 , features : allFeaturesEnabled ()},
452+ {name : "Go 1.25 VM" , goTarget : testutil .Go1_25 , features : allFeaturesEnabled ()},
423453 }
424454
425455 for _ , testCase := range testCases {
0 commit comments