mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-26 05:17:22 +00:00
b4d2395a38
* Tests for builder service * fix glob * minor changes to mock * add comments to mock * Revert "Auxiliary commit to revert individual files from bc62a140347e3cbd8bd82e99cf5e9deb98b74df0" This reverts commit c4c1016cb597b9340d1c81ab3816e037a6b97f9e. * correct comment * Do not init builder for empty endpoint * revert merging issues * better nil checks * test fix Co-authored-by: terencechain <terence@prysmaticlabs.com> Co-authored-by: Raul Jordan <raul@prysmaticlabs.com> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
40 lines
1.5 KiB
Go
40 lines
1.5 KiB
Go
package builder
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
buildertesting "github.com/prysmaticlabs/prysm/v3/api/client/builder/testing"
|
|
blockchainTesting "github.com/prysmaticlabs/prysm/v3/beacon-chain/blockchain/testing"
|
|
dbtesting "github.com/prysmaticlabs/prysm/v3/beacon-chain/db/testing"
|
|
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
|
eth "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
|
"github.com/prysmaticlabs/prysm/v3/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])
|
|
}
|