mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-05 18:42:19 +00:00
02dd405e93
* MGR Make Schedule v0
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package mgr_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/eth/mgr"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestScheduleProperties(t *testing.T) {
|
|
require := require.New(t)
|
|
stateSize := uint64(123456)
|
|
block := uint64(11)
|
|
|
|
var prevTick mgr.Tick
|
|
var prevSlice mgr.StateSizeSlice
|
|
|
|
var sizeFromSlicesAccumulator uint64
|
|
var sizeFromTicksAccumulator uint64
|
|
schedule := mgr.NewStateSchedule(stateSize, block, block+mgr.BlocksPerCycle+100)
|
|
for i := range schedule.Ticks {
|
|
tick := schedule.Ticks[i]
|
|
for j := range tick.StateSizeSlices {
|
|
ss := tick.StateSizeSlices[j]
|
|
sizeFromSlicesAccumulator += ss.ToSize - ss.FromSize
|
|
|
|
// props
|
|
if prevTick.Number < tick.Number { // because cycles are... cycled
|
|
require.Less(ss.FromSize, ss.ToSize)
|
|
require.LessOrEqual(prevSlice.ToSize, ss.FromSize)
|
|
}
|
|
|
|
prevSlice = ss
|
|
}
|
|
sizeFromTicksAccumulator += tick.ToSize - tick.FromSize
|
|
|
|
// props
|
|
if prevTick.Number < tick.Number {
|
|
require.LessOrEqual(block, tick.FromBlock)
|
|
require.Less(tick.FromBlock, tick.ToBlock)
|
|
require.Less(prevTick.ToBlock, tick.FromBlock)
|
|
|
|
require.LessOrEqual(tick.ToSize, stateSize)
|
|
require.Less(tick.FromSize, tick.ToSize)
|
|
require.Less(prevTick.ToSize, tick.FromSize)
|
|
}
|
|
|
|
prevTick = tick
|
|
}
|
|
|
|
}
|