The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
woop/core/core_test.go

69 lines
1.3 KiB

package core
import (
"math/big"
"testing"
8 months ago
blockfactory "github.com/woop-chain/woop/block/factory"
"github.com/woop-chain/woop/core/types"
shardingconfig "github.com/woop-chain/woop/internal/configs/sharding"
"github.com/woop-chain/woop/shard"
)
func TestIsEpochBlock(t *testing.T) {
blockNumbered := func(n int64) *types.Block {
return types.NewBlock(
blockfactory.NewTestHeader().With().Number(big.NewInt(n)).Header(),
nil, nil, nil, nil, nil,
)
}
tests := []struct {
schedule shardingconfig.Schedule
block *types.Block
expected bool
}{
{
shardingconfig.MainnetSchedule,
blockNumbered(10),
false,
},
{
shardingconfig.MainnetSchedule,
blockNumbered(0),
true,
},
{
shardingconfig.MainnetSchedule,
blockNumbered(344064),
true,
},
{
shardingconfig.TestnetSchedule,
blockNumbered(37),
false,
},
{
shardingconfig.TestnetSchedule,
blockNumbered(38),
true,
},
{
shardingconfig.TestnetSchedule,
blockNumbered(75),
false,
},
{
shardingconfig.TestnetSchedule,
blockNumbered(76),
true,
},
}
for i, test := range tests {
shard.Schedule = test.schedule
r := IsEpochBlock(test.block)
if r != test.expected {
t.Errorf("index: %v, expected: %v, got: %v\n", i, test.expected, r)
}
}
}