Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests for other scenarios #1477

Merged
merged 3 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/lib/solady
15 changes: 15 additions & 0 deletions mod/consensus-types/pkg/types/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,21 @@ func TestBeaconBlockEmpty(t *testing.T) {
require.IsType(t, &types.BeaconBlockDeneb{}, emptyBlock.RawBeaconBlock)
}

func TestBeaconBlock_IsNil(t *testing.T) {
var block *types.BeaconBlock
require.True(t, block.IsNil())

// Test when RawBeaconBlock is nil
block = &types.BeaconBlock{}
require.True(t, block.IsNil())

// Test when BeaconBlock and RawBeaconBlock are not nil
block = &types.BeaconBlock{
RawBeaconBlock: &types.BeaconBlockDeneb{},
}
require.False(t, block.IsNil())
}

func TestNewWithVersion(t *testing.T) {
slot := math.Slot(10)
proposerIndex := math.ValidatorIndex(5)
Expand Down
33 changes: 25 additions & 8 deletions mod/engine-primitives/pkg/engine-primitives/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,18 @@ func TestBuildForkchoiceUpdateRequest(t *testing.T) {
require.Equal(t, forkVersion, request.ForkVersion)
}

func TestHasValidVersionedAndBlockHashesError(t *testing.T) {
func TestBuildGetPayloadRequest(t *testing.T) {
payloadID := engineprimitives.PayloadID{}
forkVersion := uint32(1)

request := engineprimitives.BuildGetPayloadRequest(payloadID, forkVersion)

require.NotNil(t, request)
require.Equal(t, payloadID, request.PayloadID)
require.Equal(t, forkVersion, request.ForkVersion)
}

func TestHasValidVersionedAndBlockHashesPayloadError(t *testing.T) {
executionPayload := MockExecutionPayload{}
versionedHashes := []common.ExecutionHash{}
parentBeaconBlockRoot := primitives.Root{}
Expand All @@ -163,13 +174,19 @@ func TestHasValidVersionedAndBlockHashesError(t *testing.T) {
require.ErrorIs(t, err, engineprimitives.ErrPayloadBlockHashMismatch)
}

func TestBuildGetPayloadRequest(t *testing.T) {
payloadID := engineprimitives.PayloadID{}
forkVersion := uint32(1)
func TestHasValidVersionedAndBlockHashesMismatchedHashes(t *testing.T) {
executionPayload := MockExecutionPayload{}
versionedHashes := []common.ExecutionHash{common.ExecutionHash{}}
parentBeaconBlockRoot := primitives.Root{}
optimistic := false

request := engineprimitives.BuildGetPayloadRequest(payloadID, forkVersion)
request := engineprimitives.BuildNewPayloadRequest(
executionPayload,
versionedHashes,
&parentBeaconBlockRoot,
optimistic,
)

require.NotNil(t, request)
require.Equal(t, payloadID, request.PayloadID)
require.Equal(t, forkVersion, request.ForkVersion)
err := request.HasValidVersionedAndBlockHashes()
require.ErrorIs(t, err, engineprimitives.ErrMismatchedNumVersionedHashes)
}
Loading