Skip to content

Commit

Permalink
Change method casing
Browse files Browse the repository at this point in the history
  • Loading branch information
neekolas committed Oct 24, 2023
1 parent 8c94283 commit da11034
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 36 deletions.
4 changes: 2 additions & 2 deletions pkg/api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ type Config struct {
Waku *wakunode.WakuNode
Log *zap.Logger
Store *store.Store
MlsStore mlsstore.MlsStore
MlsValidator mlsvalidate.MlsValidationService
MLSStore mlsstore.MlsStore
MLSValidator mlsvalidate.MLSValidationService
}

// AuthnOptions bundle command line options associated with the authn package.
Expand Down
14 changes: 7 additions & 7 deletions pkg/api/message/v3/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ type Service struct {
log *zap.Logger
waku *wakunode.WakuNode
messageStore *store.Store
mlsStore mlsstore.MlsStore
validationService mlsvalidate.MlsValidationService
MLSStore mlsstore.MlsStore
validationService mlsvalidate.MLSValidationService

ctx context.Context
ctxCancel func()
}

func NewService(node *wakunode.WakuNode, logger *zap.Logger, messageStore *store.Store, mlsStore mlsstore.MlsStore, validationService mlsvalidate.MlsValidationService) (s *Service, err error) {
func NewService(node *wakunode.WakuNode, logger *zap.Logger, messageStore *store.Store, mlsStore mlsstore.MlsStore, validationService mlsvalidate.MLSValidationService) (s *Service, err error) {
s = &Service{
log: logger.Named("message/v3"),
waku: node,
messageStore: messageStore,
mlsStore: mlsStore,
MLSStore: mlsStore,
validationService: validationService,
}

Expand All @@ -59,7 +59,7 @@ func (s *Service) RegisterInstallation(ctx context.Context, req *proto.RegisterI
installationId := results[0].InstallationId
walletAddress := results[0].WalletAddress

err = s.mlsStore.CreateInstallation(ctx, installationId, walletAddress, req.LastResortKeyPackage.KeyPackageTlsSerialized)
err = s.MLSStore.CreateInstallation(ctx, installationId, walletAddress, req.LastResortKeyPackage.KeyPackageTlsSerialized)
if err != nil {
return nil, err
}
Expand All @@ -71,7 +71,7 @@ func (s *Service) RegisterInstallation(ctx context.Context, req *proto.RegisterI

func (s *Service) ConsumeKeyPackages(ctx context.Context, req *proto.ConsumeKeyPackagesRequest) (*proto.ConsumeKeyPackagesResponse, error) {
ids := req.InstallationIds
keyPackages, err := s.mlsStore.ConsumeKeyPackages(ctx, ids)
keyPackages, err := s.MLSStore.ConsumeKeyPackages(ctx, ids)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to consume key packages: %s", err)
}
Expand Down Expand Up @@ -122,7 +122,7 @@ func (s *Service) UploadKeyPackages(ctx context.Context, req *proto.UploadKeyPac
kp := mlsstore.NewKeyPackage(validationResult.InstallationId, keyPackageBytes[i], false)
keyPackageModels[i] = kp
}
err = s.mlsStore.InsertKeyPackages(ctx, keyPackageModels)
err = s.MLSStore.InsertKeyPackages(ctx, keyPackageModels)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to insert key packages: %s", err)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ func (s *Server) startGRPC() error {
proto.RegisterMessageApiServer(grpcServer, s.messagev1)

// Enable the MLS server if a store is provided
if s.Config.MlsStore != nil && s.Config.MlsValidator != nil && s.Config.EnableMls {
s.messagev3, err = messagev3.NewService(s.Waku, s.Log, s.Store, s.Config.MlsStore, s.Config.MlsValidator)
if s.Config.MLSStore != nil && s.Config.MLSValidator != nil && s.Config.EnableMls {
s.messagev3, err = messagev3.NewService(s.Waku, s.Log, s.Store, s.Config.MLSStore, s.Config.MLSValidator)
if err != nil {
return errors.Wrap(err, "creating mls service")
}
Expand Down Expand Up @@ -183,7 +183,7 @@ func (s *Server) startHTTP() error {
return errors.Wrap(err, "registering message handler")
}

if s.Config.MlsStore != nil && s.Config.EnableMls {
if s.Config.MLSStore != nil && s.Config.EnableMls {
err = v3Proto.RegisterMlsApiHandler(s.ctx, gwmux, conn)
if err != nil {
return errors.Wrap(err, "registering mls handler")
Expand Down
6 changes: 3 additions & 3 deletions pkg/mlsstore/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ func TestCreateInstallation(t *testing.T) {
require.NoError(t, store.db.NewSelect().Model(installationFromDb).Where("id = ?", installationId).Scan(ctx))
require.Equal(t, walletAddress, installationFromDb.WalletAddress)

keyPackageFromDb := &KeyPackage{}
require.NoError(t, store.db.NewSelect().Model(keyPackageFromDb).Where("installation_id = ?", installationId).Scan(ctx))
require.Equal(t, installationId, keyPackageFromDb.InstallationId)
keyPackageFromDB := &KeyPackage{}
require.NoError(t, store.db.NewSelect().Model(keyPackageFromDB).Where("installation_id = ?", installationId).Scan(ctx))
require.Equal(t, installationId, keyPackageFromDB.InstallationId)
}

func TestCreateInstallationIdempotent(t *testing.T) {
Expand Down
12 changes: 6 additions & 6 deletions pkg/mlsvalidate/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ type IdentityInput struct {
Identity []byte
}

type MlsValidationService interface {
type MLSValidationService interface {
ValidateKeyPackages(ctx context.Context, keyPackages [][]byte) ([]IdentityValidationResult, error)
ValidateGroupMessages(ctx context.Context, groupMessages [][]byte) ([]GroupMessageValidationResult, error)
}

type MlsValidationServiceImpl struct {
type MLSValidationServiceImpl struct {
grpcClient svc.ValidationApiClient
}

func NewMlsValidationService(ctx context.Context, options MlsValidationOptions) (*MlsValidationServiceImpl, error) {
func NewMlsValidationService(ctx context.Context, options MlsValidationOptions) (*MLSValidationServiceImpl, error) {
conn, err := grpc.DialContext(ctx, options.GrpcAddress, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return nil, err
}
return &MlsValidationServiceImpl{
return &MLSValidationServiceImpl{
grpcClient: svc.NewValidationApiClient(conn),
}, nil
}

func (s *MlsValidationServiceImpl) ValidateKeyPackages(ctx context.Context, keyPackages [][]byte) ([]IdentityValidationResult, error) {
func (s *MLSValidationServiceImpl) ValidateKeyPackages(ctx context.Context, keyPackages [][]byte) ([]IdentityValidationResult, error) {
req := makeValidateKeyPackageRequest(keyPackages)
response, err := s.grpcClient.ValidateKeyPackages(ctx, req)
if err != nil {
Expand Down Expand Up @@ -73,7 +73,7 @@ func makeValidateKeyPackageRequest(keyPackageBytes [][]byte) *svc.ValidateKeyPac
}
}

func (s *MlsValidationServiceImpl) ValidateGroupMessages(ctx context.Context, groupMessages [][]byte) ([]GroupMessageValidationResult, error) {
func (s *MLSValidationServiceImpl) ValidateGroupMessages(ctx context.Context, groupMessages [][]byte) ([]GroupMessageValidationResult, error) {
req := makeValidateGroupMessagesRequest(groupMessages)

response, err := s.grpcClient.ValidateGroupMessages(ctx, req)
Expand Down
12 changes: 6 additions & 6 deletions pkg/mlsvalidate/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ import (
"google.golang.org/grpc"
)

type MockedGrpcService struct {
type MockedGRPCService struct {
mock.Mock
}

func (m *MockedGrpcService) ValidateKeyPackages(ctx context.Context, req *svc.ValidateKeyPackagesRequest, opts ...grpc.CallOption) (*svc.ValidateKeyPackagesResponse, error) {
func (m *MockedGRPCService) ValidateKeyPackages(ctx context.Context, req *svc.ValidateKeyPackagesRequest, opts ...grpc.CallOption) (*svc.ValidateKeyPackagesResponse, error) {
args := m.Called(ctx, req)

return args.Get(0).(*svc.ValidateKeyPackagesResponse), args.Error(1)
}

func (m *MockedGrpcService) ValidateGroupMessages(ctx context.Context, req *svc.ValidateGroupMessagesRequest, opts ...grpc.CallOption) (*svc.ValidateGroupMessagesResponse, error) {
func (m *MockedGRPCService) ValidateGroupMessages(ctx context.Context, req *svc.ValidateGroupMessagesRequest, opts ...grpc.CallOption) (*svc.ValidateGroupMessagesResponse, error) {
args := m.Called(ctx, req)

return args.Get(0).(*svc.ValidateGroupMessagesResponse), args.Error(1)
}

func getMockedService() (*MockedGrpcService, MlsValidationService) {
mockService := new(MockedGrpcService)
service := &MlsValidationServiceImpl{
func getMockedService() (*MockedGRPCService, MLSValidationService) {
mockService := new(MockedGRPCService)
service := &MLSValidationServiceImpl{
grpcClient: mockService,
}

Expand Down
18 changes: 9 additions & 9 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type Server struct {
allowLister authz.WalletAllowLister
authenticator *authn.XmtpAuthentication
grpc *api.Server
mlsStore *mlsstore.Store
MLSStore *mlsstore.Store
}

// Create a new Server
Expand Down Expand Up @@ -229,15 +229,15 @@ func New(ctx context.Context, log *zap.Logger, options Options) (*Server, error)
}
s.log.With(logging.MultiAddrs("listen", maddrs...)).Info("got server")

var mlsStore mlsstore.MlsStore
var MLSStore mlsstore.MlsStore

if options.MlsStore.DbConnectionString != "" {
mlsDb, err := createBunDB(options.MlsStore.DbConnectionString, options.WaitForDB, options.MlsStore.ReadTimeout, options.MlsStore.WriteTimeout, options.MlsStore.MaxOpenConns)
if err != nil {
return nil, errors.Wrap(err, "creating mls db")
}

s.mlsStore, err = mlsstore.New(s.ctx, mlsstore.Config{
s.MLSStore, err = mlsstore.New(s.ctx, mlsstore.Config{
Log: s.log,
DB: mlsDb,
})
Expand All @@ -247,9 +247,9 @@ func New(ctx context.Context, log *zap.Logger, options Options) (*Server, error)
}
}

var mlsValidator mlsvalidate.MlsValidationService
var MLSValidator mlsvalidate.MLSValidationService
if options.MlsValidation.GrpcAddress != "" {
mlsValidator, err = mlsvalidate.NewMlsValidationService(ctx, options.MlsValidation)
MLSValidator, err = mlsvalidate.NewMlsValidationService(ctx, options.MlsValidation)
if err != nil {
return nil, errors.Wrap(err, "creating mls validation service")
}
Expand All @@ -263,9 +263,9 @@ func New(ctx context.Context, log *zap.Logger, options Options) (*Server, error)
Log: s.log.Named("`api"),
Waku: s.wakuNode,
Store: s.store,
MlsStore: mlsStore,
MLSStore: MLSStore,
AllowLister: s.allowLister,
MlsValidator: mlsValidator,
MLSValidator: MLSValidator,
},
)
if err != nil {
Expand Down Expand Up @@ -306,8 +306,8 @@ func (s *Server) Shutdown() {
if s.store != nil {
s.store.Close()
}
if s.mlsStore != nil {
s.mlsStore.Close()
if s.MLSStore != nil {
s.MLSStore.Close()
}

// Close metrics server.
Expand Down

0 comments on commit da11034

Please sign in to comment.