mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 18:51:19 +00:00
d17996f8b0
* Update V3 from V4 * Fix build v3 -> v4 * Update ssz * Update beacon_chain.pb.go * Fix formatter import * Update update-mockgen.sh comment to v4 * Fix conflicts. Pass build and tests * Fix test
40 lines
1.5 KiB
Go
40 lines
1.5 KiB
Go
package builder
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
buildertesting "github.com/prysmaticlabs/prysm/v4/api/client/builder/testing"
|
|
blockchainTesting "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain/testing"
|
|
dbtesting "github.com/prysmaticlabs/prysm/v4/beacon-chain/db/testing"
|
|
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
|
|
eth "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/v4/testing/assert"
|
|
"github.com/prysmaticlabs/prysm/v4/testing/require"
|
|
)
|
|
|
|
func Test_NewServiceWithBuilder(t *testing.T) {
|
|
s, err := NewService(context.Background(), WithBuilderClient(&buildertesting.MockClient{}))
|
|
require.NoError(t, err)
|
|
assert.Equal(t, true, s.Configured())
|
|
}
|
|
|
|
func Test_NewServiceWithoutBuilder(t *testing.T) {
|
|
s, err := NewService(context.Background())
|
|
require.NoError(t, err)
|
|
assert.Equal(t, false, s.Configured())
|
|
}
|
|
|
|
func Test_RegisterValidator(t *testing.T) {
|
|
ctx := context.Background()
|
|
db := dbtesting.SetupDB(t)
|
|
headFetcher := &blockchainTesting.ChainService{}
|
|
builder := buildertesting.NewClient()
|
|
s, err := NewService(ctx, WithDatabase(db), WithHeadFetcher(headFetcher), WithBuilderClient(&builder))
|
|
require.NoError(t, err)
|
|
pubkey := bytesutil.ToBytes48([]byte("pubkey"))
|
|
var feeRecipient [20]byte
|
|
require.NoError(t, s.RegisterValidator(ctx, []*eth.SignedValidatorRegistrationV1{{Message: ð.ValidatorRegistrationV1{Pubkey: pubkey[:], FeeRecipient: feeRecipient[:]}}}))
|
|
assert.Equal(t, true, builder.RegisteredVals[pubkey])
|
|
}
|