mirror of https://github.com/certusone/vouch.git
Update mocks.
Create mocks for services that do not have them. Update eth2client mock with more mocks.
This commit is contained in:
parent
cc09d86dd6
commit
a17f71a90d
|
@ -60,6 +60,19 @@ func (m *SlotDurationProvider) SlotDuration(ctx context.Context) (time.Duration,
|
|||
return m.slotDuration, nil
|
||||
}
|
||||
|
||||
// ErroringSlotDurationProvider is a mock for eth2client.SlotDurationProvider.
|
||||
type ErroringSlotDurationProvider struct{}
|
||||
|
||||
// NewErroringSlotDurationProvider returns a mock slot duration provider that errors.
|
||||
func NewErroringSlotDurationProvider() eth2client.SlotDurationProvider {
|
||||
return &ErroringSlotDurationProvider{}
|
||||
}
|
||||
|
||||
// SlotDuration is a mock.
|
||||
func (m *ErroringSlotDurationProvider) SlotDuration(ctx context.Context) (time.Duration, error) {
|
||||
return 0, errors.New("mock")
|
||||
}
|
||||
|
||||
// FarFutureEpochProvider is a mock for eth2client.FarFutureEpochProvider.
|
||||
type FarFutureEpochProvider struct {
|
||||
farFutureEpoch spec.Epoch
|
||||
|
@ -107,6 +120,45 @@ func (m *ErroringSlotsPerEpochProvider) SlotsPerEpoch(ctx context.Context) (uint
|
|||
return 0, errors.New("error")
|
||||
}
|
||||
|
||||
// ProposerDutiesProvider is a mock for eth2client.ProposerDutiesProvider.
|
||||
type ProposerDutiesProvider struct{}
|
||||
|
||||
// NewProposerDutiesProvider returns a mock proposer duties provider.
|
||||
func NewProposerDutiesProvider() eth2client.ProposerDutiesProvider {
|
||||
return &ProposerDutiesProvider{}
|
||||
}
|
||||
|
||||
// ProposerDuties is a mock.
|
||||
func (m *ProposerDutiesProvider) ProposerDuties(ctx context.Context, epoch spec.Epoch, validatorIndices []spec.ValidatorIndex) ([]*api.ProposerDuty, error) {
|
||||
return make([]*api.ProposerDuty, 0), nil
|
||||
}
|
||||
|
||||
// AttesterDutiesProvider is a mock for eth2client.AttesterDutiesProvider.
|
||||
type AttesterDutiesProvider struct{}
|
||||
|
||||
// NewAttesterDutiesProvider returns a mock attester duties provider.
|
||||
func NewAttesterDutiesProvider() eth2client.AttesterDutiesProvider {
|
||||
return &AttesterDutiesProvider{}
|
||||
}
|
||||
|
||||
// AttesterDuties is a mock.
|
||||
func (m *AttesterDutiesProvider) AttesterDuties(ctx context.Context, epoch spec.Epoch, validatorIndices []spec.ValidatorIndex) ([]*api.AttesterDuty, error) {
|
||||
return make([]*api.AttesterDuty, 0), nil
|
||||
}
|
||||
|
||||
// EventsProvider is a mock for eth2client.EventsProvider.
|
||||
type EventsProvider struct{}
|
||||
|
||||
// NewEventsProvider returns a mock events provider.
|
||||
func NewEventsProvider() eth2client.EventsProvider {
|
||||
return &EventsProvider{}
|
||||
}
|
||||
|
||||
// Events is a mock
|
||||
func (m *EventsProvider) Events(ctx context.Context, topics []string, handler eth2client.EventHandlerFunc) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AttestationsSubmitter is a mock for eth2client.AttestationsSubmitter.
|
||||
type AttestationsSubmitter struct{}
|
||||
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
// Copyright © 2020 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"
|
||||
|
||||
spec "github.com/attestantio/go-eth2-client/spec/phase0"
|
||||
"github.com/attestantio/vouch/services/accountmanager"
|
||||
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
|
||||
)
|
||||
|
||||
type validatingAccountsProvider struct{}
|
||||
|
||||
// NewValidatingAccountsProvider is a mock.
|
||||
func NewValidatingAccountsProvider() accountmanager.ValidatingAccountsProvider {
|
||||
return &validatingAccountsProvider{}
|
||||
}
|
||||
|
||||
// ValidatingAccountsForEpoch is a mock.
|
||||
func (v *validatingAccountsProvider) ValidatingAccountsForEpoch(ctx context.Context, epoch spec.Epoch) (map[spec.ValidatorIndex]e2wtypes.Account, error) {
|
||||
return make(map[spec.ValidatorIndex]e2wtypes.Account), nil
|
||||
}
|
||||
|
||||
// ValidatingAccountsForEpochByIndex obtains the specified validating accounts for a given epoch.
|
||||
func (v *validatingAccountsProvider) ValidatingAccountsForEpochByIndex(ctx context.Context,
|
||||
epoch spec.Epoch,
|
||||
indices []spec.ValidatorIndex,
|
||||
) (
|
||||
map[spec.ValidatorIndex]e2wtypes.Account,
|
||||
error,
|
||||
) {
|
||||
return make(map[spec.ValidatorIndex]e2wtypes.Account), nil
|
||||
}
|
||||
|
||||
type refresher struct{}
|
||||
|
||||
// NewRefresher is a mock.
|
||||
func NewRefresher() accountmanager.Refresher {
|
||||
return &refresher{}
|
||||
}
|
||||
|
||||
// Refresh is a mock.
|
||||
func (r *refresher) Refresh(ctx context.Context) {}
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright © 2020 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/vouch/services/attestationaggregator"
|
||||
)
|
||||
|
||||
// service is a mock.
|
||||
type service struct{}
|
||||
|
||||
// New creates a mock attestation aggregator.
|
||||
func New() attestationaggregator.Service {
|
||||
return &service{}
|
||||
}
|
||||
|
||||
// Aggregate is a mock.
|
||||
func (s *service) Aggregate(ctx context.Context, data interface{}) {}
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright © 2020 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"
|
||||
|
||||
spec "github.com/attestantio/go-eth2-client/spec/phase0"
|
||||
)
|
||||
|
||||
// Service is a mock attester.
|
||||
type Service struct{}
|
||||
|
||||
// New creates a new mock attester.
|
||||
func New() *Service {
|
||||
return &Service{}
|
||||
}
|
||||
|
||||
// Attest carries out attestations for a slot.
|
||||
func (s *Service) Attest(ctx context.Context, data interface{}) ([]*spec.Attestation, error) {
|
||||
return make([]*spec.Attestation, 0), nil
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright © 2020 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/vouch/services/beaconblockproposer"
|
||||
)
|
||||
|
||||
type service struct{}
|
||||
|
||||
// New is a mock.
|
||||
func New() beaconblockproposer.Service {
|
||||
return &service{}
|
||||
}
|
||||
|
||||
// Prepare is a mock.
|
||||
func (s *service) Prepare(ctx context.Context, details interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Propose is a mock.
|
||||
func (s *service) Propose(ctx context.Context, details interface{}) {}
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright © 2020 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"
|
||||
|
||||
spec "github.com/attestantio/go-eth2-client/spec/phase0"
|
||||
"github.com/attestantio/vouch/services/beaconcommitteesubscriber"
|
||||
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
|
||||
)
|
||||
|
||||
type service struct{}
|
||||
|
||||
// New is a mock beacon committee subscriber service.
|
||||
func New() beaconcommitteesubscriber.Service {
|
||||
return &service{}
|
||||
}
|
||||
|
||||
// Subscribe is a mock.
|
||||
func (s *service) Subscribe(ctx context.Context,
|
||||
epoch spec.Epoch,
|
||||
accounts map[spec.ValidatorIndex]e2wtypes.Account,
|
||||
) (map[spec.Slot]map[spec.CommitteeIndex]*beaconcommitteesubscriber.Subscription, error) {
|
||||
return make(map[spec.Slot]map[spec.CommitteeIndex]*beaconcommitteesubscriber.Subscription), nil
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
// Copyright © 2020 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"
|
||||
"time"
|
||||
|
||||
"github.com/attestantio/vouch/services/scheduler"
|
||||
)
|
||||
|
||||
// Service is a mock scheduler service.
|
||||
type service struct{}
|
||||
|
||||
// New creates a new mock scheduling service.
|
||||
func New() scheduler.Service {
|
||||
return &service{}
|
||||
}
|
||||
|
||||
// ScheduleJob schedules a one-off job for a given time.
|
||||
func (s *service) ScheduleJob(ctx context.Context, name string, runtime time.Time, jobFunc scheduler.JobFunc, data interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SchedulePeriodicJob schedules a job to run in a loop.
|
||||
func (s *service) SchedulePeriodicJob(ctx context.Context, name string, runtimeFunc scheduler.RuntimeFunc, runtimeData interface{}, jobFunc scheduler.JobFunc, jobData interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RunJob runs a named job immediately.
|
||||
func (s *service) RunJob(ctx context.Context, name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// JobExists returns true if a job exists.
|
||||
func (s *service) JobExists(ctx context.Context, name string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// ListJobs returns the names of all jobs.
|
||||
func (s *service) ListJobs(ctx context.Context) []string {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
// RunJobIfExists runs a job if it exists.
|
||||
func (s *service) RunJobIfExists(ctx context.Context, name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// CancelJob removes a named job.
|
||||
func (s *service) CancelJob(ctx context.Context, name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// CancelJobs cancels all jobs with the given prefix.
|
||||
func (s *service) CancelJobs(ctx context.Context, prefix string) error {
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue