mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-09 03:01:19 +00:00
51581e9b6e
* 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>
42 lines
1.1 KiB
Go
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, ðpb.PowBlock{BlockHash: []byte{1, 2, 3}})
|
|
|
|
require.Equal(t, 1, len(builder.execMock.powBlocks))
|
|
}
|