2020-05-15 08:58:36 +00:00
|
|
|
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)
|
2020-05-28 11:33:05 +00:00
|
|
|
toBlock := block + mgr.BlocksPerCycle + 100
|
|
|
|
var prevTick *mgr.Tick
|
2020-05-15 08:58:36 +00:00
|
|
|
|
|
|
|
var sizeFromTicksAccumulator uint64
|
2020-05-28 11:33:05 +00:00
|
|
|
for block <= toBlock {
|
|
|
|
tick := mgr.NewTick(block, stateSize, prevTick)
|
2020-05-15 08:58:36 +00:00
|
|
|
|
|
|
|
sizeFromTicksAccumulator += tick.ToSize - tick.FromSize
|
|
|
|
// props
|
2020-05-28 11:33:05 +00:00
|
|
|
if prevTick != nil && prevTick.Number < tick.Number {
|
2020-05-15 08:58:36 +00:00
|
|
|
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
|
2020-05-28 11:33:05 +00:00
|
|
|
block = tick.ToBlock + 1
|
2020-05-15 08:58:36 +00:00
|
|
|
}
|
|
|
|
}
|