Skip to content

Commit

Permalink
chore: lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MishkaRogachev committed Oct 27, 2023
1 parent a6da7c6 commit 957acd7
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 34 deletions.
2 changes: 1 addition & 1 deletion protocol/identity/profile_showcase.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package identity
import "reflect"

type VisibleProfileShowcaseEntry struct {
EntryId string `json:"entryId"`
EntryID string `json:"entryId"`
Order int `json:"order"`
}

Expand Down
9 changes: 5 additions & 4 deletions protocol/messenger_profile_showcase.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"errors"
"fmt"

"google.golang.org/protobuf/proto"

"github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/identity"
"github.com/status-im/status-go/protocol/protobuf"
"google.golang.org/protobuf/proto"
)

type ProfileShowcasePreferences struct {
Expand All @@ -25,7 +26,7 @@ func toProfileShowcaseUpdateEntries(entries []*ProfileShowcaseEntry, visibility
for _, entry := range entries {
if entry.ShowcaseVisibility == visibility {
update := &protobuf.ProfileShowcaseEntry{
EntryId: entry.ID,
EntryID: entry.ID,
Order: uint32(entry.Order),
}
result = append(result, update)
Expand All @@ -38,7 +39,7 @@ func fromProfileShowcaseUpdateEntries(messages []*protobuf.ProfileShowcaseEntry)
entries := []*identity.VisibleProfileShowcaseEntry{}
for _, entry := range messages {
entries = append(entries, &identity.VisibleProfileShowcaseEntry{
EntryId: entry.EntryId,
EntryID: entry.EntryID,
Order: int(entry.Order),
})
}
Expand Down Expand Up @@ -186,7 +187,7 @@ func (m *Messenger) DecryptProfileShowcaseEntriesWithContactPubKeys(senderPubKey
// Decrypt the main encryption AES key with AES encryption using the DH key
dAESKey, err := common.Decrypt(eAESKey, sharedKey)
if err != nil {
if err.Error() == "cipher: message authentication failed" {
if err.Error() == "cipher: message authentication failed" { // nolint: goconst
continue
}
return nil, err
Expand Down
37 changes: 19 additions & 18 deletions protocol/messenger_profile_showcase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import (
"crypto/ecdsa"
"testing"

"github.com/stretchr/testify/suite"
"go.uber.org/zap"

gethbridge "github.com/status-im/status-go/eth-node/bridge/geth"
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
Expand All @@ -14,8 +17,6 @@ import (
"github.com/status-im/status-go/protocol/requests"
"github.com/status-im/status-go/protocol/tt"
"github.com/status-im/status-go/waku"
"github.com/stretchr/testify/suite"
"go.uber.org/zap"
)

func TestMessengerProfileShowcaseSuite(t *testing.T) { // nolint: deadcode,unused
Expand Down Expand Up @@ -238,31 +239,31 @@ func (s *TestMessengerProfileShowcase) TestEncryptAndDecryptProfileShowcaseEntri
entries := &protobuf.ProfileShowcaseEntries{
Communities: []*protobuf.ProfileShowcaseEntry{
&protobuf.ProfileShowcaseEntry{
EntryId: "0x01312357798976535235432345",
EntryID: "0x01312357798976535235432345",
Order: 12,
},
&protobuf.ProfileShowcaseEntry{
EntryId: "0x12378534257568678487683576",
EntryID: "0x12378534257568678487683576",
Order: 11,
},
},
Accounts: []*protobuf.ProfileShowcaseEntry{
&protobuf.ProfileShowcaseEntry{
EntryId: "0x00000323245",
EntryID: "0x00000323245",
Order: 1,
},
},
Assets: []*protobuf.ProfileShowcaseEntry{
&protobuf.ProfileShowcaseEntry{
EntryId: "ETH",
EntryID: "ETH",
Order: 2,
},
&protobuf.ProfileShowcaseEntry{
EntryId: "DAI",
EntryID: "DAI",
Order: 3,
},
&protobuf.ProfileShowcaseEntry{
EntryId: "SNT",
EntryID: "SNT",
Order: 1,
},
},
Expand All @@ -274,9 +275,9 @@ func (s *TestMessengerProfileShowcase) TestEncryptAndDecryptProfileShowcaseEntri
s.Require().NoError(err)

s.Require().Equal(2, len(entriesBack.Communities))
s.Require().Equal(entries.Communities[0].EntryId, entriesBack.Communities[0].EntryId)
s.Require().Equal(entries.Communities[0].EntryID, entriesBack.Communities[0].EntryID)
s.Require().Equal(entries.Communities[0].Order, entriesBack.Communities[0].Order)
s.Require().Equal(entries.Communities[1].EntryId, entriesBack.Communities[1].EntryId)
s.Require().Equal(entries.Communities[1].EntryID, entriesBack.Communities[1].EntryID)
s.Require().Equal(entries.Communities[1].Order, entriesBack.Communities[1].Order)
}

Expand Down Expand Up @@ -328,15 +329,15 @@ func (s *TestMessengerProfileShowcase) TestShareShowcasePreferences() {
profileShowcase := resp.Contacts[0].ProfileShowcase
s.Require().Len(profileShowcase.Communities, 2)
// For everyone
s.Require().Equal(profileShowcase.Communities[0].EntryId, request.Communities[0].ID)
s.Require().Equal(profileShowcase.Communities[0].EntryID, request.Communities[0].ID)
s.Require().Equal(profileShowcase.Communities[0].Order, request.Communities[0].Order)

// For contacts
s.Require().Equal(profileShowcase.Communities[1].EntryId, request.Communities[1].ID)
s.Require().Equal(profileShowcase.Communities[1].EntryID, request.Communities[1].ID)
s.Require().Equal(profileShowcase.Communities[1].Order, request.Communities[1].Order)

s.Require().Len(profileShowcase.Accounts, 1)
s.Require().Equal(profileShowcase.Accounts[0].EntryId, request.Accounts[0].ID)
s.Require().Equal(profileShowcase.Accounts[0].EntryID, request.Accounts[0].ID)
s.Require().Equal(profileShowcase.Accounts[0].Order, request.Accounts[0].Order)

s.Require().Len(profileShowcase.Collectibles, 0)
Expand All @@ -357,23 +358,23 @@ func (s *TestMessengerProfileShowcase) TestShareShowcasePreferences() {
profileShowcase = resp.Contacts[0].ProfileShowcase
s.Require().Len(profileShowcase.Communities, 3)
// For everyone
s.Require().Equal(profileShowcase.Communities[0].EntryId, request.Communities[0].ID)
s.Require().Equal(profileShowcase.Communities[0].EntryID, request.Communities[0].ID)
s.Require().Equal(profileShowcase.Communities[0].Order, request.Communities[0].Order)

// For contacts
s.Require().Equal(profileShowcase.Communities[1].EntryId, request.Communities[1].ID)
s.Require().Equal(profileShowcase.Communities[1].EntryID, request.Communities[1].ID)
s.Require().Equal(profileShowcase.Communities[1].Order, request.Communities[1].Order)

// For id verified
s.Require().Equal(profileShowcase.Communities[2].EntryId, request.Communities[2].ID)
s.Require().Equal(profileShowcase.Communities[2].EntryID, request.Communities[2].ID)
s.Require().Equal(profileShowcase.Communities[2].Order, request.Communities[2].Order)

s.Require().Len(profileShowcase.Accounts, 1)
s.Require().Equal(profileShowcase.Accounts[0].EntryId, request.Accounts[0].ID)
s.Require().Equal(profileShowcase.Accounts[0].EntryID, request.Accounts[0].ID)
s.Require().Equal(profileShowcase.Accounts[0].Order, request.Accounts[0].Order)

s.Require().Len(profileShowcase.Collectibles, 1)
s.Require().Equal(profileShowcase.Collectibles[0].EntryId, request.Collectibles[0].ID)
s.Require().Equal(profileShowcase.Collectibles[0].EntryID, request.Collectibles[0].ID)
s.Require().Equal(profileShowcase.Collectibles[0].Order, request.Collectibles[0].Order)

s.Require().Len(profileShowcase.Assets, 0)
Expand Down
4 changes: 2 additions & 2 deletions protocol/persistence_profile_showcase.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (db sqlitePersistence) GetProfileShowcaseForContact(contactId string) (*ide
entry := &identity.VisibleProfileShowcaseEntry{}

err := rows.Scan(
&entry.EntryId,
&entry.EntryID,
&entry.Order,
&entryType,
)
Expand Down Expand Up @@ -177,7 +177,7 @@ func (db sqlitePersistence) saveProfileShowcaseContactEntries(tx *sql.Tx, contac
for _, entry := range entries {
_, err := tx.Exec(insertOrUpdateProfileShowcaseContactQuery,
contactId,
entry.EntryId,
entry.EntryID,
entryType,
entry.Order,
)
Expand Down
15 changes: 8 additions & 7 deletions protocol/persistence_profile_showcase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package protocol
import (
"testing"

"github.com/status-im/status-go/protocol/identity"
"github.com/stretchr/testify/suite"

"github.com/status-im/status-go/protocol/identity"
)

func TestProfileShowcasePersistenceSuite(t *testing.T) {
Expand Down Expand Up @@ -91,17 +92,17 @@ func (s *TestProfileShowcasePersistence) TestProfileShowcaseContacts() {
showcase1 := &identity.ProfileShowcase{
Communities: []*identity.VisibleProfileShowcaseEntry{
&identity.VisibleProfileShowcaseEntry{
EntryId: "0x012312234234234",
EntryID: "0x012312234234234",
Order: 6,
},
&identity.VisibleProfileShowcaseEntry{
EntryId: "0x04523233466753",
EntryID: "0x04523233466753",
Order: 7,
},
},
Assets: []*identity.VisibleProfileShowcaseEntry{
&identity.VisibleProfileShowcaseEntry{
EntryId: "ETH",
EntryID: "ETH",
Order: 1,
},
},
Expand All @@ -112,17 +113,17 @@ func (s *TestProfileShowcasePersistence) TestProfileShowcaseContacts() {
showcase2 := &identity.ProfileShowcase{
Communities: []*identity.VisibleProfileShowcaseEntry{
&identity.VisibleProfileShowcaseEntry{
EntryId: "0x012312234234234", // same id to check query
EntryID: "0x012312234234234", // same id to check query
Order: 3,
},
&identity.VisibleProfileShowcaseEntry{
EntryId: "0x096783478384593",
EntryID: "0x096783478384593",
Order: 7,
},
},
Collectibles: []*identity.VisibleProfileShowcaseEntry{
&identity.VisibleProfileShowcaseEntry{
EntryId: "d378662f-3d71-44e0-81ee-ff7f1778c13a",
EntryID: "d378662f-3d71-44e0-81ee-ff7f1778c13a",
Order: 1,
},
},
Expand Down
4 changes: 2 additions & 2 deletions protocol/protobuf/profile_showcase.pb.go

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

0 comments on commit 957acd7

Please sign in to comment.