prysm-pulse/testing/spectest/shared/common/forkchoice/builder_test.go
Preston Van Loon 51581e9b6e
Spectest: refactor forkchoice helper (#10616)
* Seperate forkchoice builder for lower cognitive score and better reusablity

* gaz

* deepsource resolutions

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
2022-05-03 20:59:07 +00:00

42 lines
1.1 KiB
Go

package forkchoice
import (
"testing"
"github.com/prysmaticlabs/prysm/consensus-types/wrapper"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/testing/require"
"github.com/prysmaticlabs/prysm/testing/util"
)
func TestBuilderTick(t *testing.T) {
st, err := util.NewBeaconState()
require.NoError(t, err)
blk, err := wrapper.WrappedSignedBeaconBlock(util.NewBeaconBlock())
require.NoError(t, err)
builder := NewBuilder(t, st, blk)
builder.Tick(t, 10)
require.Equal(t, int64(10), builder.lastTick)
}
func TestBuilderInvalidBlock(t *testing.T) {
st, err := util.NewBeaconState()
require.NoError(t, err)
blk, err := wrapper.WrappedSignedBeaconBlock(util.NewBeaconBlock())
require.NoError(t, err)
builder := NewBuilder(t, st, blk)
builder.InvalidBlock(t, blk)
}
func TestPoWBlock(t *testing.T) {
st, err := util.NewBeaconState()
require.NoError(t, err)
blk, err := wrapper.WrappedSignedBeaconBlock(util.NewBeaconBlock())
require.NoError(t, err)
builder := NewBuilder(t, st, blk)
builder.PoWBlock(t, &ethpb.PowBlock{BlockHash: []byte{1, 2, 3}})
require.Equal(t, 1, len(builder.execMock.powBlocks))
}