2022-05-03 20:59:07 +00:00
|
|
|
package forkchoice
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-03-17 18:52:56 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v4/consensus-types/blocks"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
|
|
|
"github.com/prysmaticlabs/prysm/v4/testing/require"
|
|
|
|
"github.com/prysmaticlabs/prysm/v4/testing/util"
|
2022-05-03 20:59:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestBuilderTick(t *testing.T) {
|
|
|
|
st, err := util.NewBeaconState()
|
|
|
|
require.NoError(t, err)
|
2022-08-02 15:30:46 +00:00
|
|
|
blk, err := blocks.NewSignedBeaconBlock(util.NewBeaconBlock())
|
2022-05-03 20:59:07 +00:00
|
|
|
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)
|
2022-08-02 15:30:46 +00:00
|
|
|
blk, err := blocks.NewSignedBeaconBlock(util.NewBeaconBlock())
|
2022-05-03 20:59:07 +00:00
|
|
|
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)
|
2022-08-02 15:30:46 +00:00
|
|
|
blk, err := blocks.NewSignedBeaconBlock(util.NewBeaconBlock())
|
2022-05-03 20:59:07 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
builder := NewBuilder(t, st, blk)
|
2022-06-27 13:34:38 +00:00
|
|
|
builder.PoWBlock(ðpb.PowBlock{BlockHash: []byte{1, 2, 3}})
|
2022-05-03 20:59:07 +00:00
|
|
|
|
|
|
|
require.Equal(t, 1, len(builder.execMock.powBlocks))
|
|
|
|
}
|