forked from erigontech/erigon
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
75 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package vm | ||
|
||
import ( | ||
"testing" | ||
|
||
zk_consts "github.com/ledgerwatch/erigon-lib/chain" | ||
Check failure on line 6 in core/vm/zk_counters_limits_test.go GitHub Actions / tests (ubuntu-20.04)
|
||
) | ||
|
||
func TestGetTotalSteps(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
forkID uint16 | ||
expected int | ||
}{ | ||
{ | ||
name: "Pre ForkID10", | ||
forkID: uint16(zk_consts.ForkID9Elderberry2), | ||
expected: preForkId10TotalSteps, // 1 << 23 | ||
}, | ||
{ | ||
name: "ForkID10", | ||
forkID: uint16(zk_consts.ForkID10), | ||
expected: forkId10TotalSteps - stepDeduction, | ||
}, | ||
{ | ||
name: "ForkID11", | ||
forkID: uint16(zk_consts.ForkID11), | ||
expected: forkId11TotalSteps - stepDeduction, | ||
}, | ||
{ | ||
name: "ForkID12", | ||
forkID: uint16(zk_consts.ForkID12Banana), | ||
expected: forkId11TotalSteps - stepDeduction, | ||
}, | ||
{ | ||
name: "ForkID13", | ||
forkID: uint16(zk_consts.ForkId13Durian), | ||
expected: forkId11TotalSteps - stepDeduction, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got := getTotalSteps(tt.forkID) | ||
if got != tt.expected { | ||
t.Errorf("getTotalSteps(%d) = %d, want %d", tt.forkID, got, tt.expected) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestCounterLimitsProgression(t *testing.T) { | ||
// Test that forkid progression is correct from for 9 to 100 | ||
startForkID := uint16(zk_consts.ForkID9Elderberry2) | ||
endForkID := uint16(100) | ||
|
||
var prevLimit int | ||
for forkID := startForkID; forkID <= endForkID; forkID++ { | ||
currentLimit := getTotalSteps(forkID) | ||
|
||
if prevLimit > currentLimit { | ||
t.Errorf("ForkID %d has fewer steps (%d) than previous forkID %d (%d)!", forkID, currentLimit, forkID-1, prevLimit) | ||
} | ||
|
||
prevLimit = currentLimit | ||
} | ||
} |