diff --git a/eth-node/types/topic.go b/eth-node/types/topic.go index 218fc443c..78466ce1e 100644 --- a/eth-node/types/topic.go +++ b/eth-node/types/topic.go @@ -95,9 +95,5 @@ func StringToTopic(s string) (t TopicType) { } func TopicTypeToByteArray(t TopicType) []byte { - topic := make([]byte, 4) - for i, b := range t { - topic[i] = b - } - return topic + return t[:4] } diff --git a/protocol/messenger_contact_requests_test.go b/protocol/messenger_contact_requests_test.go index fda40a318..c4a864b0e 100644 --- a/protocol/messenger_contact_requests_test.go +++ b/protocol/messenger_contact_requests_test.go @@ -936,7 +936,7 @@ func (s *MessengerContactRequestSuite) TestLegacyContactRequestNotifications() { myID := types.EncodeHex(crypto.FromECDSAPub(&s.m.identity.PublicKey)) // Send contact request - resp, err = s.m.SendContactRequest(context.Background(), crRequest) + _, err = s.m.SendContactRequest(context.Background(), crRequest) s.Require().NoError(err) paginationResponse, err := theirMessenger.ActivityCenterNotifications("", 10) diff --git a/protocol/requests/community_tags.go b/protocol/requests/community_tags.go index 03aa57e7a..0e50b19a7 100644 --- a/protocol/requests/community_tags.go +++ b/protocol/requests/community_tags.go @@ -66,12 +66,8 @@ func ValidateTags(input []string) bool { } } - if len(unique(input)) != len(input) { - // Contains duplicates. Shouldn't have happened - return false - } - - return true + // False if contains duplicates. Shouldn't have happened + return len(unique(input)) == len(input) } func RemoveUnknownAndDeduplicateTags(input []string) []string { diff --git a/server/handlers.go b/server/handlers.go index 496b216d9..f081c8ac1 100644 --- a/server/handlers.go +++ b/server/handlers.go @@ -396,7 +396,7 @@ func challengeMiddleware(ps *PairingServer, next http.Handler) http.HandlerFunc // Only if we have both a challenge in the session store and in the request header // do we entertain blocking the client. Because then we know someone is trying to be sneaky. - if bytes.Compare(c, challenge) != 0 { + if !bytes.Equal(c, challenge) { s.Values[sessionBlocked] = true err = s.Save(r, w) if err != nil { diff --git a/server/payload_manager_test.go b/server/payload_manager_test.go index 0a083bf94..f4de40eee 100644 --- a/server/payload_manager_test.go +++ b/server/payload_manager_test.go @@ -198,7 +198,7 @@ func (pms *PayloadMarshallerSuite) TestPayloadMarshaller_MarshalToProtobuf() { // Because file-walk will pull files in an unpredictable order from a target dir // there are 2 potential valid hashes, because there are 2 key files in the test dir - if bytes.Compare(hashA, h.Sum(nil)) != 0 { + if !bytes.Equal(hashA, h.Sum(nil)) { pms.Require().Exactly(hashB, h.Sum(nil)) } } diff --git a/server/server_test.go b/server/server_test.go index a8edcfea4..69de11cbc 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -14,9 +14,8 @@ type ServerURLSuite struct { suite.Suite TestKeyComponents - server *MediaServer - serverNoPort *MediaServer - pairingServer *PairingServer + server *MediaServer + serverNoPort *MediaServer } func (s *ServerURLSuite) SetupSuite() { diff --git a/services/accounts/accounts.go b/services/accounts/accounts.go index beb7d721b..c1f2dee28 100644 --- a/services/accounts/accounts.go +++ b/services/accounts/accounts.go @@ -312,10 +312,7 @@ func (api *API) generateAccount( func (api *API) VerifyPassword(password string) bool { err := api.verifyPassword(password) - if err != nil { - return false - } - return true + return err == nil } func (api *API) AddMigratedKeyPair(ctx context.Context, kcUID string, kpName string, keyUID string, accountAddresses []string) error { diff --git a/transactions/types.go b/transactions/types.go index 69b3d310f..6f83ce1b9 100644 --- a/transactions/types.go +++ b/transactions/types.go @@ -118,5 +118,5 @@ func (args SendTxArgs) ToTransactOpts(signerFn bind.SignerFn) *bind.TransactOpts } func isNilOrEmpty(bytes types.HexBytes) bool { - return bytes == nil || len(bytes) == 0 + return len(bytes) == 0 }