Skip to content

Commit

Permalink
Fix linter and test
Browse files Browse the repository at this point in the history
  • Loading branch information
agnusmor committed Aug 1, 2024
1 parent dde1800 commit e3bd07a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions pool/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

"github.com/0xPolygonHermez/zkevm-node/state"
"github.com/stretchr/testify/assert"
)

func TestIsWithinConstraints(t *testing.T) {
Expand All @@ -21,9 +22,9 @@ func TestIsWithinConstraints(t *testing.T) {
}

testCases := []struct {
desc string
counters state.ZKCounters
expected error
desc string
counters state.ZKCounters
errExpected error
}{
{
desc: "All constraints within limits",
Expand All @@ -38,7 +39,7 @@ func TestIsWithinConstraints(t *testing.T) {
Steps: 2000,
Sha256Hashes_V2: 4000,
},
expected: nil,
errExpected: nil,
},
{
desc: "All constraints exceed limits",
Expand All @@ -53,14 +54,17 @@ func TestIsWithinConstraints(t *testing.T) {
Steps: 5000,
Sha256Hashes_V2: 6000,
},
expected: fmt.Errorf("out of counters at node level (GasUsed, KeccakHashes, PoseidonHashes, PoseidonPaddings, MemAligns, Arithmetics, Binaries, Steps, Sha256Hashes)"),
errExpected: fmt.Errorf("out of counters at node level (GasUsed, KeccakHashes, PoseidonHashes, PoseidonPaddings, MemAligns, Arithmetics, Binaries, Steps, Sha256Hashes)"),
},
}

for _, tC := range testCases {
t.Run(tC.desc, func(t *testing.T) {
if got := cfg.CheckNodeLevelOOC(tC.counters); got != tC.expected {
t.Errorf("Expected %v, got %v", tC.expected, got)
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
err := cfg.CheckNodeLevelOOC(tc.counters)
if tc.errExpected != nil {
assert.EqualError(t, err, tc.errExpected.Error())
} else {
assert.NoError(t, err)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion state/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ type BatchConstraintsCfg struct {
MaxSHA256Hashes uint32 `mapstructure:"MaxSHA256Hashes"`
}

// checkNodeLevelOOC checks if the counters are within the batch constraints
// CheckNodeLevelOOC checks if the counters are within the batch constraints
func (c BatchConstraintsCfg) CheckNodeLevelOOC(counters ZKCounters) error {
oocList := ""

Expand Down

0 comments on commit e3bd07a

Please sign in to comment.