forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug_test.go
40 lines (33 loc) · 1.01 KB
/
debug_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package mipsevm
import (
"math"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
"github.com/ethereum-optimism/optimism/op-service/ioutil"
"github.com/ethereum-optimism/optimism/op-service/jsonutil"
)
func TestDebugInfo_Serialization(t *testing.T) {
debugInfo := &DebugInfo{
Pages: 1,
MemoryUsed: 2,
NumPreimageRequests: 3,
TotalPreimageSize: 4,
TotalSteps: 123456,
RmwSuccessCount: 5,
RmwFailCount: 6,
MaxStepsBetweenLLAndSC: 7,
ReservationInvalidationCount: 8,
ForcedPreemptionCount: 9,
IdleStepCountThread0: math.MaxUint64,
}
// Serialize to file
dir := t.TempDir()
path := filepath.Join(dir, "debug-info-test.txt")
err := jsonutil.WriteJSON(debugInfo, ioutil.ToAtomicFile(path, 0o644))
require.NoError(t, err)
// Deserialize
fromJson, err := jsonutil.LoadJSON[DebugInfo](path)
require.NoError(t, err)
require.Equal(t, debugInfo, fromJson)
}