Skip to content

Commit

Permalink
fix: hex decode group id from mls validation service
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Normore committed Jan 12, 2024
1 parent 5da9062 commit d0f3294
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions pkg/mls/api/v1/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package api

import (
"context"
"encoding/hex"

wakunode "github.com/waku-org/go-waku/waku/v2/node"
wakupb "github.com/waku-org/go-waku/waku/v2/protocol/pb"
Expand Down Expand Up @@ -175,8 +176,12 @@ func (s *Service) SendGroupMessages(ctx context.Context, req *proto.SendGroupMes
}

// TODO: Wrap this in a transaction so publishing is all or nothing
wakuTopic := topic.BuildGroupTopic([]byte(result.GroupId))
msg, err := s.store.InsertGroupMessage(ctx, []byte(result.GroupId), data)
decodedGroupId, err := hex.DecodeString(result.GroupId)
if err != nil {
return nil, err
}
wakuTopic := topic.BuildGroupTopic(decodedGroupId)
msg, err := s.store.InsertGroupMessage(ctx, decodedGroupId, data)
if err != nil {
if store.IsAlreadyExistsError(err) {
continue
Expand Down
3 changes: 2 additions & 1 deletion pkg/mls/api/v1/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package api
import (
"context"
"errors"
"fmt"
"testing"

"github.com/stretchr/testify/mock"
Expand Down Expand Up @@ -54,7 +55,7 @@ func (m *mockedMLSValidationService) mockValidateKeyPackages(installationId []by
func (m *mockedMLSValidationService) mockValidateGroupMessages(groupId []byte) *mock.Call {
return m.On("ValidateGroupMessages", mock.Anything, mock.Anything).Return([]mlsvalidate.GroupMessageValidationResult{
{
GroupId: string(groupId),
GroupId: fmt.Sprintf("%x", groupId),
},
}, nil)
}
Expand Down

0 comments on commit d0f3294

Please sign in to comment.