Skip to content

Commit

Permalink
Update to newest protos
Browse files Browse the repository at this point in the history
  • Loading branch information
mkysel committed Jan 23, 2025
1 parent f6c43e0 commit 5c00374
Show file tree
Hide file tree
Showing 54 changed files with 6,670 additions and 4,266 deletions.
25 changes: 0 additions & 25 deletions pkg/mlsvalidate/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ type IdentityInput struct {

type MLSValidationService interface {
ValidateInboxIdKeyPackages(ctx context.Context, keyPackages [][]byte) ([]InboxIdValidationResult, error)
ValidateV3KeyPackages(ctx context.Context, keyPackages [][]byte) ([]IdentityValidationResult, error)
ValidateGroupMessages(ctx context.Context, groupMessages []*mlsv1.GroupMessageInput) ([]GroupMessageValidationResult, error)
GetAssociationState(ctx context.Context, oldUpdates []*associations.IdentityUpdate, newUpdates []*associations.IdentityUpdate) (*AssociationStateResult, error)
VerifySmartContractWalletSignatures(ctx context.Context, req *identity.VerifySmartContractWalletSignaturesRequest) (*identity.VerifySmartContractWalletSignaturesResponse, error)
Expand Down Expand Up @@ -110,30 +109,6 @@ func (s *MLSValidationServiceImpl) ValidateInboxIdKeyPackages(ctx context.Contex
return out, nil
}

func (s *MLSValidationServiceImpl) ValidateV3KeyPackages(ctx context.Context, keyPackages [][]byte) ([]IdentityValidationResult, error) {
req := makeValidateKeyPackageRequest(keyPackages, false)

response, err := s.grpcClient.ValidateKeyPackages(ctx, req)
if err != nil {
return nil, err
}

out := make([]IdentityValidationResult, len(response.Responses))
for i, response := range response.Responses {
if !response.IsOk {
return nil, fmt.Errorf("validation failed with error %s", response.ErrorMessage)
}
out[i] = IdentityValidationResult{
AccountAddress: response.AccountAddress,
InstallationKey: response.InstallationId,
CredentialIdentity: response.CredentialIdentityBytes,
Expiration: response.Expiration,
}
}

return out, nil
}

func makeValidateKeyPackageRequest(keyPackageBytes [][]byte, isInboxIdCredential bool) *svc.ValidateKeyPackagesRequest {
keyPackageRequests := make([]*svc.ValidateKeyPackagesRequest_KeyPackage, len(keyPackageBytes))
for i, keyPackage := range keyPackageBytes {
Expand Down
25 changes: 0 additions & 25 deletions pkg/mlsvalidate/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,6 @@ func getMockedService() (*MockedGRPCService, MLSValidationService) {
return mockService, service
}

func TestValidateKeyPackages(t *testing.T) {
mockGrpc, service := getMockedService()

ctx := context.Background()

firstResponse := svc.ValidateKeyPackagesResponse_ValidationResponse{
IsOk: true,
AccountAddress: "0x123",
InstallationId: []byte("123"),
CredentialIdentityBytes: []byte("456"),
ErrorMessage: "",
}

mockGrpc.On("ValidateKeyPackages", ctx, mock.Anything).Return(&svc.ValidateKeyPackagesResponse{
Responses: []*svc.ValidateKeyPackagesResponse_ValidationResponse{&firstResponse},
}, nil)

res, err := service.ValidateV3KeyPackages(ctx, nil)
assert.NoError(t, err)
assert.Equal(t, 1, len(res))
assert.Equal(t, "0x123", res[0].AccountAddress)
assert.Equal(t, []byte("123"), res[0].InstallationKey)
assert.Equal(t, []byte("456"), res[0].CredentialIdentity)
}

func TestValidateInboxIdKeyPackages(t *testing.T) {
mockGrpc, service := getMockedService()

Expand Down
61 changes: 1 addition & 60 deletions pkg/mocks/mock_MLSValidationService.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/mocks/mock_MlsApi_SubscribeGroupMessagesServer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/mocks/mock_MlsApi_SubscribeWelcomeMessagesServer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5c00374

Please sign in to comment.