Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xenowits committed Nov 3, 2023
1 parent 5501f07 commit 733732d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
10 changes: 5 additions & 5 deletions app/eth2wrap/success.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
package eth2wrap

import (
"github.com/attestantio/go-eth2-client/api"
apiv1 "github.com/attestantio/go-eth2-client/api/v1"
"github.com/attestantio/go-eth2-client/spec/phase0"
eth2api "github.com/attestantio/go-eth2-client/api"
eth2v1 "github.com/attestantio/go-eth2-client/api/v1"
eth2p0 "github.com/attestantio/go-eth2-client/spec/phase0"
)

// isSyncStateOk returns true if the sync state is not syncing.
func isSyncStateOk(resp *api.Response[*apiv1.SyncState]) bool {
func isSyncStateOk(resp *eth2api.Response[*eth2v1.SyncState]) bool {
return !resp.Data.IsSyncing
}

// isAggregateAttestationOk returns true if the aggregate attestation is not nil (which can happen if the subscription wasn't successful).
func isAggregateAttestationOk(resp *api.Response[*phase0.Attestation]) bool {
func isAggregateAttestationOk(resp *eth2api.Response[*eth2p0.Attestation]) bool {
return resp.Data != nil
}
28 changes: 14 additions & 14 deletions app/eth2wrap/synthproposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
eth2v1 "github.com/attestantio/go-eth2-client/api/v1"
eth2bellatrix "github.com/attestantio/go-eth2-client/api/v1/bellatrix"
eth2capella "github.com/attestantio/go-eth2-client/api/v1/capella"
"github.com/attestantio/go-eth2-client/spec"
eth2spec "github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/bellatrix"
"github.com/attestantio/go-eth2-client/spec/capella"
eth2p0 "github.com/attestantio/go-eth2-client/spec/phase0"
Expand Down Expand Up @@ -139,7 +139,7 @@ func (h *synthWrapper) BlindedProposal(ctx context.Context, opts *eth2api.Blinde

// syntheticProposal returns a synthetic unsigned beacon block to propose.
func (h *synthWrapper) syntheticProposal(ctx context.Context, slot eth2p0.Slot, vIdx eth2p0.ValidatorIndex) (*eth2api.VersionedProposal, error) {
var signedBlock *spec.VersionedSignedBeaconBlock
var signedBlock *eth2spec.VersionedSignedBeaconBlock

// Work our way back from previous slot to find a proposal to base the synthetic proposal on.
for prev := slot - 1; prev > 0; prev-- {
Expand Down Expand Up @@ -168,24 +168,24 @@ func (h *synthWrapper) syntheticProposal(ctx context.Context, slot eth2p0.Slot,

proposal := &eth2api.VersionedProposal{Version: signedBlock.Version}
switch signedBlock.Version {
case spec.DataVersionPhase0:
case eth2spec.DataVersionPhase0:
proposal.Phase0 = signedBlock.Phase0.Message
proposal.Phase0.Body.Graffiti = GetSyntheticGraffiti()
proposal.Phase0.Slot = slot
proposal.Phase0.ProposerIndex = vIdx
case spec.DataVersionAltair:
case eth2spec.DataVersionAltair:
proposal.Altair = signedBlock.Altair.Message
proposal.Altair.Body.Graffiti = GetSyntheticGraffiti()
proposal.Altair.Slot = slot
proposal.Altair.ProposerIndex = vIdx
case spec.DataVersionBellatrix:
case eth2spec.DataVersionBellatrix:
proposal.Bellatrix = signedBlock.Bellatrix.Message
proposal.Bellatrix.Body.Graffiti = GetSyntheticGraffiti()
proposal.Bellatrix.Slot = slot
proposal.Bellatrix.ProposerIndex = vIdx
proposal.Bellatrix.Body.ExecutionPayload.FeeRecipient = feeRecipient
proposal.Bellatrix.Body.ExecutionPayload.Transactions = fraction(proposal.Bellatrix.Body.ExecutionPayload.Transactions)
case spec.DataVersionCapella:
case eth2spec.DataVersionCapella:
proposal.Capella = signedBlock.Capella.Message
proposal.Capella.Body.Graffiti = GetSyntheticGraffiti()
proposal.Capella.Slot = slot
Expand Down Expand Up @@ -237,9 +237,9 @@ func GetSyntheticGraffiti() [32]byte {
func IsSyntheticBlindedBlock(block *eth2api.VersionedSignedBlindedProposal) bool {
var graffiti [32]byte
switch block.Version {
case spec.DataVersionBellatrix:
case eth2spec.DataVersionBellatrix:
graffiti = block.Bellatrix.Message.Body.Graffiti
case spec.DataVersionCapella:
case eth2spec.DataVersionCapella:
graffiti = block.Capella.Message.Body.Graffiti
default:
return false
Expand All @@ -252,13 +252,13 @@ func IsSyntheticBlindedBlock(block *eth2api.VersionedSignedBlindedProposal) bool
func IsSyntheticProposal(block *eth2api.VersionedSignedProposal) bool {
var graffiti [32]byte
switch block.Version {
case spec.DataVersionPhase0:
case eth2spec.DataVersionPhase0:
graffiti = block.Phase0.Message.Body.Graffiti
case spec.DataVersionAltair:
case eth2spec.DataVersionAltair:
graffiti = block.Altair.Message.Body.Graffiti
case spec.DataVersionBellatrix:
case eth2spec.DataVersionBellatrix:
graffiti = block.Bellatrix.Message.Body.Graffiti
case spec.DataVersionCapella:
case eth2spec.DataVersionCapella:
graffiti = block.Capella.Message.Body.Graffiti
default:
return false
Expand Down Expand Up @@ -436,7 +436,7 @@ func blindedProposal(proposal *eth2api.VersionedProposal) (*eth2api.VersionedBli
var resp *eth2api.VersionedBlindedProposal
// Blinded blocks are only available from bellatrix.
switch proposal.Version {
case spec.DataVersionBellatrix:
case eth2spec.DataVersionBellatrix:
resp = &eth2api.VersionedBlindedProposal{
Version: proposal.Version,
Bellatrix: &eth2bellatrix.BlindedBeaconBlock{
Expand Down Expand Up @@ -473,7 +473,7 @@ func blindedProposal(proposal *eth2api.VersionedProposal) (*eth2api.VersionedBli
},
},
}
case spec.DataVersionCapella:
case eth2spec.DataVersionCapella:
resp = &eth2api.VersionedBlindedProposal{
Version: proposal.Version,
Capella: &eth2capella.BlindedBeaconBlock{
Expand Down
10 changes: 5 additions & 5 deletions app/eth2wrap/synthproposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
eth2api "github.com/attestantio/go-eth2-client/api"
eth2v1 "github.com/attestantio/go-eth2-client/api/v1"
eth2capella "github.com/attestantio/go-eth2-client/api/v1/capella"
"github.com/attestantio/go-eth2-client/spec"
eth2spec "github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/bellatrix"
eth2p0 "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -59,7 +59,7 @@ func TestSynthProposer(t *testing.T) {
return cached(ctx)
}
signedBeaconBlock := bmock.SignedBeaconBlock
bmock.SignedBeaconBlockFunc = func(ctx context.Context, blockID string) (*spec.VersionedSignedBeaconBlock, error) {
bmock.SignedBeaconBlockFunc = func(ctx context.Context, blockID string) (*eth2spec.VersionedSignedBeaconBlock, error) {
opts := &eth2api.SignedBeaconBlockOpts{Block: blockID}
resp, err := signedBeaconBlock(ctx, opts)
if err != nil {
Expand Down Expand Up @@ -120,7 +120,7 @@ func TestSynthProposer(t *testing.T) {

continue
}
require.Equal(t, spec.DataVersionCapella, block.Version)
require.Equal(t, eth2spec.DataVersionCapella, block.Version)

signed := testutil.RandomVersionedSignedProposal()
signed.Capella.Message = block.Capella
Expand All @@ -146,10 +146,10 @@ func TestSynthProposer(t *testing.T) {
} else {
require.Equal(t, feeRecipient, block.Capella.Body.ExecutionPayloadHeader.FeeRecipient)
}
require.Equal(t, spec.DataVersionCapella, block.Version)
require.Equal(t, eth2spec.DataVersionCapella, block.Version)

signed := &eth2api.VersionedSignedBlindedProposal{
Version: spec.DataVersionCapella,
Version: eth2spec.DataVersionCapella,
Capella: &eth2capella.SignedBlindedBeaconBlock{
Message: block.Capella,
Signature: testutil.RandomEth2Signature(),
Expand Down

0 comments on commit 733732d

Please sign in to comment.