Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Utility] Add servicer module mock #960

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions shared/modules/fisherman_module.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package modules

type FishermanModule interface {
Module
}
16 changes: 16 additions & 0 deletions shared/modules/servicer_module.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package modules

//go:generate mockgen -destination=./mocks/servicer_module_mock.go github.com/pokt-network/pocket/shared/modules ServicerModule

import (
coreTypes "github.com/pokt-network/pocket/shared/core/types"
)

const (
ServicerModuleName = "servicer"
)

type ServicerModule interface {
Module
adshmh marked this conversation as resolved.
Show resolved Hide resolved
HandleRelay(*coreTypes.Relay) (*coreTypes.RelayResponse, error)
}
13 changes: 0 additions & 13 deletions shared/modules/utility_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,6 @@ type UtilityModule interface {
GetValidatorModule() (ValidatorModule, error)
}

type FishermanModule interface {
Module
}

type ServicerModule interface {
Module
HandleRelay(*coreTypes.Relay) (*coreTypes.RelayResponse, error)
}

type ValidatorModule interface {
Module
}

// TECHDEBT: Remove this interface from `shared/modules` and use the `Actor` protobuf type instead
// There will need to be some documentation or indicator that the Actor struct returned may not be
// fully hydrated. Alternatively, we could eat the performance cost and just hydrate the entire struct
Expand Down
5 changes: 5 additions & 0 deletions shared/modules/validator_module.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package modules

type ValidatorModule interface {
Module
}
4 changes: 2 additions & 2 deletions utility/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ func (u *utilityModule) GetActorModules() map[string]modules.Module {
}

func (u *utilityModule) GetServicerModule() (modules.ServicerModule, error) {
if u.actorModules[servicer.ServicerModuleName] == nil {
if u.actorModules[modules.ServicerModuleName] == nil {
return nil, errors.New("servicer module not enabled")
}
if m, ok := u.actorModules[servicer.ServicerModuleName].(modules.ServicerModule); ok {
if m, ok := u.actorModules[modules.ServicerModuleName].(modules.ServicerModule); ok {
return m, nil
}
return nil, errors.New("failed to cast servicer module")
Expand Down
6 changes: 1 addition & 5 deletions utility/servicer/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ var (
_ modules.ServicerModule = &servicer{}
)

const (
ServicerModuleName = "servicer"
)

// sessionTokens is used to cache the starting number of tokens available
// during a specific session: it is used as the value for a map with keys being applications' public keys
// TODO: What if we have a servicer managing more than one session from the same app at once? We may/may not need to resolve this in the future.
Expand Down Expand Up @@ -121,7 +117,7 @@ func (s *servicer) Stop() error {
}

func (s *servicer) GetModuleName() string {
return ServicerModuleName
return modules.ServicerModuleName
}

// HandleRelay processes a relay after performing validation.
Expand Down
Loading