Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdee committed Sep 24, 2023
1 parent 81e75b7 commit d741855
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 65 deletions.
37 changes: 37 additions & 0 deletions mock/builderbidprovider.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright © 2023 Attestant Limited.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package mock

import (
"context"

"github.com/attestantio/go-block-relay/services/blockauctioneer"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/services/beaconblockproposer"
)

type BuilderBidProvider struct{}

// BuilderBid returns a builder bid.
func (b BuilderBidProvider) BuilderBid(_ context.Context,
_ phase0.Slot,
_ phase0.Hash32,
_ phase0.BLSPubKey,
_ *beaconblockproposer.ProposerConfig,
) (
*blockauctioneer.Results,
error,
) {
return &blockauctioneer.Results{}, nil
}
11 changes: 3 additions & 8 deletions services/blockrelay/standard/proposerconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ func TestProposerConfig(t *testing.T) {
genesisTimeProvider := mock.NewGenesisTimeProvider(genesisTime)
slotDurationProvider := mock.NewSlotDurationProvider(slotDuration)
slotsPerEpochProvider := mock.NewSlotsPerEpochProvider(slotsPerEpoch)
specProvider := mock.NewSpecProvider()
domainProvider := mock.NewDomainProvider()

mockValidatingAccountsProvider := mockaccountmanager.NewValidatingAccountsProvider()
mockAccountsProvider := mockaccountmanager.NewAccountsProvider()
Expand Down Expand Up @@ -128,9 +126,8 @@ func TestProposerConfig(t *testing.T) {
standard.WithValidatingAccountsProvider(mockValidatingAccountsProvider),
standard.WithAccountsProvider(mockAccountsProvider),
standard.WithValidatorRegistrationSigner(mockSigner),
standard.WithSpecProvider(specProvider),
standard.WithDomainProvider(domainProvider),
standard.WithReleaseVersion("test"),
standard.WithBuilderBidProvider(mock.BuilderBidProvider{}),
},
proposerConfig: `{"fee_recipient":"0x0100000000000000000000000000000000000000","relays":[]}`,
},
Expand All @@ -149,9 +146,8 @@ func TestProposerConfig(t *testing.T) {
standard.WithValidatingAccountsProvider(mockValidatingAccountsProvider),
standard.WithAccountsProvider(mockAccountsProvider),
standard.WithValidatorRegistrationSigner(mockSigner),
standard.WithSpecProvider(specProvider),
standard.WithDomainProvider(domainProvider),
standard.WithReleaseVersion("test"),
standard.WithBuilderBidProvider(mock.BuilderBidProvider{}),
},
proposerConfig: `{"fee_recipient":"0x0200000000000000000000000000000000000000","relays":[]}`,
logEntries: []map[string]interface{}{
Expand All @@ -175,9 +171,8 @@ func TestProposerConfig(t *testing.T) {
standard.WithValidatingAccountsProvider(mockValidatingAccountsProvider),
standard.WithAccountsProvider(mockAccountsProvider),
standard.WithValidatorRegistrationSigner(mockSigner),
standard.WithSpecProvider(specProvider),
standard.WithDomainProvider(domainProvider),
standard.WithReleaseVersion("test"),
standard.WithBuilderBidProvider(mock.BuilderBidProvider{}),
},
proposerConfig: `{"fee_recipient":"0x0100000000000000000000000000000000000000","relays":[]}`,
logEntries: []map[string]interface{}{
Expand Down
77 changes: 20 additions & 57 deletions services/blockrelay/standard/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ func TestService(t *testing.T) {
genesisTimeProvider := mock.NewGenesisTimeProvider(genesisTime)
slotDurationProvider := mock.NewSlotDurationProvider(slotDuration)
slotsPerEpochProvider := mock.NewSlotsPerEpochProvider(slotsPerEpoch)
specProvider := mock.NewSpecProvider()
domainProvider := mock.NewDomainProvider()

mockValidatingAccountsProvider := mockaccountmanager.NewValidatingAccountsProvider()
mockAccountsProvider := mockaccountmanager.NewAccountsProvider()
Expand Down Expand Up @@ -78,6 +76,8 @@ func TestService(t *testing.T) {
fallbackGasLimit := uint64(10000000)
mockSigner := mocksigner.New()

builderBidProvider := mock.BuilderBidProvider{}

tests := []struct {
name string
params []standard.Parameter
Expand All @@ -100,9 +100,8 @@ func TestService(t *testing.T) {
standard.WithAccountsProvider(mockAccountsProvider),
standard.WithValidatingAccountsProvider(mockValidatingAccountsProvider),
standard.WithValidatorRegistrationSigner(mockSigner),
standard.WithSpecProvider(specProvider),
standard.WithDomainProvider(domainProvider),
standard.WithReleaseVersion("test"),
standard.WithBuilderBidProvider(builderBidProvider),
},
err: "problem with parameters: no monitor specified",
},
Expand All @@ -122,9 +121,8 @@ func TestService(t *testing.T) {
standard.WithAccountsProvider(mockAccountsProvider),
standard.WithValidatingAccountsProvider(mockValidatingAccountsProvider),
standard.WithValidatorRegistrationSigner(mockSigner),
standard.WithSpecProvider(specProvider),
standard.WithDomainProvider(domainProvider),
standard.WithReleaseVersion("test"),
standard.WithBuilderBidProvider(builderBidProvider),
},
err: "problem with parameters: no timeout specified",
},
Expand All @@ -144,9 +142,8 @@ func TestService(t *testing.T) {
standard.WithAccountsProvider(mockAccountsProvider),
standard.WithValidatingAccountsProvider(mockValidatingAccountsProvider),
standard.WithValidatorRegistrationSigner(mockSigner),
standard.WithSpecProvider(specProvider),
standard.WithDomainProvider(domainProvider),
standard.WithReleaseVersion("test"),
standard.WithBuilderBidProvider(builderBidProvider),
},
err: "problem with parameters: no majordomo specified",
},
Expand All @@ -166,9 +163,8 @@ func TestService(t *testing.T) {
standard.WithAccountsProvider(mockAccountsProvider),
standard.WithValidatingAccountsProvider(mockValidatingAccountsProvider),
standard.WithValidatorRegistrationSigner(mockSigner),
standard.WithSpecProvider(specProvider),
standard.WithDomainProvider(domainProvider),
standard.WithReleaseVersion("test"),
standard.WithBuilderBidProvider(builderBidProvider),
},
err: "problem with parameters: no scheduler specified",
},
Expand All @@ -188,9 +184,8 @@ func TestService(t *testing.T) {
standard.WithAccountsProvider(mockAccountsProvider),
standard.WithValidatingAccountsProvider(mockValidatingAccountsProvider),
standard.WithValidatorRegistrationSigner(mockSigner),
standard.WithSpecProvider(specProvider),
standard.WithDomainProvider(domainProvider),
standard.WithReleaseVersion("test"),
standard.WithBuilderBidProvider(builderBidProvider),
},
err: "problem with parameters: no listen address specified",
},
Expand All @@ -210,9 +205,8 @@ func TestService(t *testing.T) {
standard.WithAccountsProvider(mockAccountsProvider),
standard.WithValidatingAccountsProvider(mockValidatingAccountsProvider),
standard.WithValidatorRegistrationSigner(mockSigner),
standard.WithSpecProvider(specProvider),
standard.WithDomainProvider(domainProvider),
standard.WithReleaseVersion("test"),
standard.WithBuilderBidProvider(builderBidProvider),
},
err: "problem with parameters: listen address malformed",
},
Expand All @@ -232,9 +226,8 @@ func TestService(t *testing.T) {
standard.WithAccountsProvider(mockAccountsProvider),
standard.WithValidatingAccountsProvider(mockValidatingAccountsProvider),
standard.WithValidatorRegistrationSigner(mockSigner),
standard.WithSpecProvider(specProvider),
standard.WithDomainProvider(domainProvider),
standard.WithReleaseVersion("test"),
standard.WithBuilderBidProvider(builderBidProvider),
},
err: "problem with parameters: no chaintime specified",
},
Expand All @@ -254,9 +247,8 @@ func TestService(t *testing.T) {
standard.WithAccountsProvider(mockAccountsProvider),
standard.WithValidatingAccountsProvider(mockValidatingAccountsProvider),
standard.WithValidatorRegistrationSigner(mockSigner),
standard.WithSpecProvider(specProvider),
standard.WithDomainProvider(domainProvider),
standard.WithReleaseVersion("test"),
standard.WithBuilderBidProvider(builderBidProvider),
},
err: "problem with parameters: no fallback fee recipient specified",
},
Expand All @@ -276,9 +268,8 @@ func TestService(t *testing.T) {
standard.WithAccountsProvider(mockAccountsProvider),
standard.WithValidatingAccountsProvider(mockValidatingAccountsProvider),
standard.WithValidatorRegistrationSigner(mockSigner),
standard.WithSpecProvider(specProvider),
standard.WithDomainProvider(domainProvider),
standard.WithReleaseVersion("test"),
standard.WithBuilderBidProvider(builderBidProvider),
},
err: "problem with parameters: no fallback gas limit specified",
},
Expand All @@ -297,9 +288,8 @@ func TestService(t *testing.T) {
standard.WithFallbackGasLimit(fallbackGasLimit),
standard.WithValidatingAccountsProvider(mockValidatingAccountsProvider),
standard.WithValidatorRegistrationSigner(mockSigner),
standard.WithSpecProvider(specProvider),
standard.WithDomainProvider(domainProvider),
standard.WithReleaseVersion("test"),
standard.WithBuilderBidProvider(builderBidProvider),
},
err: "problem with parameters: no accounts provider specified",
},
Expand All @@ -319,9 +309,8 @@ func TestService(t *testing.T) {
standard.WithAccountsProvider(mockAccountsProvider),
standard.WithValidatingAccountsProvider(nil),
standard.WithValidatorRegistrationSigner(mockSigner),
standard.WithSpecProvider(specProvider),
standard.WithDomainProvider(domainProvider),
standard.WithReleaseVersion("test"),
standard.WithBuilderBidProvider(builderBidProvider),
},
err: "problem with parameters: no validating accounts provider specified",
},
Expand All @@ -341,14 +330,13 @@ func TestService(t *testing.T) {
standard.WithAccountsProvider(mockAccountsProvider),
standard.WithValidatingAccountsProvider(mockValidatingAccountsProvider),
standard.WithValidatorRegistrationSigner(nil),
standard.WithSpecProvider(specProvider),
standard.WithDomainProvider(domainProvider),
standard.WithReleaseVersion("test"),
standard.WithBuilderBidProvider(builderBidProvider),
},
err: "problem with parameters: no validator registration signer specified",
},
{
name: "SpecProviderMissing",
name: "ReleaseVersionMissing",
params: []standard.Parameter{
standard.WithLogLevel(zerolog.Disabled),
standard.WithMonitor(prometheusMetrics),
Expand All @@ -364,13 +352,12 @@ func TestService(t *testing.T) {
standard.WithValidatingAccountsProvider(mockValidatingAccountsProvider),
standard.WithValidatorRegistrationSigner(mockSigner),
standard.WithLogResults(true),
standard.WithDomainProvider(domainProvider),
standard.WithReleaseVersion("test"),
standard.WithBuilderBidProvider(builderBidProvider),
},
err: "problem with parameters: no spec provider specified",
err: "problem with parameters: no release version specified",
},
{
name: "DomainProviderMissing",
name: "BuilderBidProviderMissing",
params: []standard.Parameter{
standard.WithLogLevel(zerolog.Disabled),
standard.WithMonitor(prometheusMetrics),
Expand All @@ -386,32 +373,9 @@ func TestService(t *testing.T) {
standard.WithValidatingAccountsProvider(mockValidatingAccountsProvider),
standard.WithValidatorRegistrationSigner(mockSigner),
standard.WithLogResults(true),
standard.WithSpecProvider(specProvider),
standard.WithReleaseVersion("test"),
},
err: "problem with parameters: no domain provider specified",
},
{
name: "ReleaseVersionMissing",
params: []standard.Parameter{
standard.WithLogLevel(zerolog.Disabled),
standard.WithMonitor(prometheusMetrics),
standard.WithTimeout(time.Second),
standard.WithMajordomo(majordomoSvc),
standard.WithScheduler(mockScheduler),
standard.WithListenAddress(listenAddress),
standard.WithChainTime(chainTime),
standard.WithConfigURL(configURL),
standard.WithFallbackFeeRecipient(fallbackFeeRecipient),
standard.WithFallbackGasLimit(fallbackGasLimit),
standard.WithAccountsProvider(mockAccountsProvider),
standard.WithValidatingAccountsProvider(mockValidatingAccountsProvider),
standard.WithValidatorRegistrationSigner(mockSigner),
standard.WithLogResults(true),
standard.WithSpecProvider(specProvider),
standard.WithDomainProvider(domainProvider),
},
err: "problem with parameters: no release version specified",
err: "problem with parameters: no builder bid provider specified",
},
{
name: "Good",
Expand All @@ -430,9 +394,8 @@ func TestService(t *testing.T) {
standard.WithValidatingAccountsProvider(mockValidatingAccountsProvider),
standard.WithValidatorRegistrationSigner(mockSigner),
standard.WithLogResults(true),
standard.WithSpecProvider(specProvider),
standard.WithDomainProvider(domainProvider),
standard.WithReleaseVersion("test"),
standard.WithBuilderBidProvider(builderBidProvider),
},
},
}
Expand Down

0 comments on commit d741855

Please sign in to comment.