Use base test messenger suite

This commit is contained in:
Andrea Maria Piana 2023-07-13 11:28:34 +01:00
parent 8bfcb80ed6
commit 23ca4ba204
17 changed files with 17 additions and 178 deletions

View File

@ -2,7 +2,6 @@ package protocol
import ( import (
"context" "context"
"crypto/ecdsa"
"encoding/json" "encoding/json"
"fmt" "fmt"
"testing" "testing"
@ -10,7 +9,6 @@ import (
"github.com/status-im/status-go/protocol/identity" "github.com/status-im/status-go/protocol/identity"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"go.uber.org/zap"
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth" 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/crypto"
@ -29,13 +27,7 @@ func TestMessengerBackupSuite(t *testing.T) {
} }
type MessengerBackupSuite struct { type MessengerBackupSuite struct {
suite.Suite MessengerBaseTestSuite
m *Messenger // main instance of Messenger
privateKey *ecdsa.PrivateKey // private key for the main instance of Messenger
// If one wants to send messages between different instances of Messenger,
// a single waku service should be shared.
shh types.Waku
logger *zap.Logger
} }
func (s *MessengerBackupSuite) SetupTest() { func (s *MessengerBackupSuite) SetupTest() {
@ -57,15 +49,6 @@ func (s *MessengerBackupSuite) TearDownTest() {
s.Require().NoError(s.m.Shutdown()) s.Require().NoError(s.m.Shutdown())
} }
func (s *MessengerBackupSuite) newMessenger() *Messenger {
privateKey, err := crypto.GenerateKey()
s.Require().NoError(err)
messenger, err := newMessengerWithKey(s.shh, privateKey, s.logger, nil)
s.Require().NoError(err)
return messenger
}
func (s *MessengerBackupSuite) TestBackupContacts() { func (s *MessengerBackupSuite) TestBackupContacts() {
bob1 := s.m bob1 := s.m
// Create bob2 // Create bob2

View File

@ -2,16 +2,13 @@ package protocol
import ( import (
"context" "context"
"crypto/ecdsa"
"sort" "sort"
"testing" "testing"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"go.uber.org/zap"
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth" 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/crypto"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/protocol/tt" "github.com/status-im/status-go/protocol/tt"
"github.com/status-im/status-go/services/browsers" "github.com/status-im/status-go/services/browsers"
"github.com/status-im/status-go/waku" "github.com/status-im/status-go/waku"
@ -22,13 +19,7 @@ func TestBrowserSuite(t *testing.T) {
} }
type BrowserSuite struct { type BrowserSuite struct {
suite.Suite MessengerBaseTestSuite
m *Messenger // main instance of Messenger
privateKey *ecdsa.PrivateKey // private key for the main instance of Messenger
// If one wants to send messages between different instances of Messenger,
// a single waku service should be shared.
shh types.Waku
logger *zap.Logger
} }
func (s *BrowserSuite) SetupTest() { func (s *BrowserSuite) SetupTest() {

View File

@ -2,12 +2,10 @@ package protocol
import ( import (
"context" "context"
"crypto/ecdsa"
"fmt" "fmt"
"testing" "testing"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"go.uber.org/zap"
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth" 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/crypto"
@ -25,13 +23,7 @@ func TestMessengerContactRequestSuite(t *testing.T) {
} }
type MessengerContactRequestSuite struct { type MessengerContactRequestSuite struct {
suite.Suite MessengerBaseTestSuite
m *Messenger // main instance of Messenger
privateKey *ecdsa.PrivateKey // private key for the main instance of Messenger
// If one wants to send messages between different instances of Messenger,
// a single waku service should be shared.
shh types.Waku
logger *zap.Logger
} }
func (s *MessengerContactRequestSuite) SetupTest() { func (s *MessengerContactRequestSuite) SetupTest() {

View File

@ -2,11 +2,9 @@ package protocol
import ( import (
"context" "context"
"crypto/ecdsa"
"testing" "testing"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"go.uber.org/zap"
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth" 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/crypto"
@ -22,13 +20,7 @@ func TestMessengerContactUpdateSuite(t *testing.T) {
} }
type MessengerContactUpdateSuite struct { type MessengerContactUpdateSuite struct {
suite.Suite MessengerBaseTestSuite
m *Messenger // main instance of Messenger
privateKey *ecdsa.PrivateKey // private key for the main instance of Messenger
// If one wants to send messages between different instances of Messenger,
// a single waku service should be shared.
shh types.Waku
logger *zap.Logger
} }
func (s *MessengerContactUpdateSuite) SetupTest() { func (s *MessengerContactUpdateSuite) SetupTest() {

View File

@ -2,11 +2,9 @@ package protocol
import ( import (
"context" "context"
"crypto/ecdsa"
"testing" "testing"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"go.uber.org/zap"
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth" 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/crypto"
@ -23,13 +21,7 @@ func TestMessengerEditMessageSuite(t *testing.T) {
} }
type MessengerEditMessageSuite struct { type MessengerEditMessageSuite struct {
suite.Suite MessengerBaseTestSuite
m *Messenger // main instance of Messenger
privateKey *ecdsa.PrivateKey // private key for the main instance of Messenger
// If one wants to send messages between different instances of Messenger,
// a single waku service should be shared.
shh types.Waku
logger *zap.Logger
} }
func (s *MessengerEditMessageSuite) SetupTest() { func (s *MessengerEditMessageSuite) SetupTest() {

View File

@ -2,13 +2,11 @@ package protocol
import ( import (
"context" "context"
"crypto/ecdsa"
"encoding/json" "encoding/json"
"strings" "strings"
"testing" "testing"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"go.uber.org/zap"
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth" 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/crypto"
@ -25,15 +23,7 @@ func TestMessengerEmojiSuite(t *testing.T) {
} }
type MessengerEmojiSuite struct { type MessengerEmojiSuite struct {
suite.Suite MessengerBaseTestSuite
m *Messenger // main instance of Messenger
privateKey *ecdsa.PrivateKey // private key for the main instance of Messenger
// If one wants to send messages between different instances of Messenger,
// a single Waku service should be shared.
shh types.Waku
logger *zap.Logger
} }
func (s *MessengerEmojiSuite) SetupTest() { func (s *MessengerEmojiSuite) SetupTest() {

View File

@ -7,11 +7,9 @@ import (
"testing" "testing"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"go.uber.org/zap"
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth" 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/crypto"
"github.com/status-im/status-go/eth-node/types"
userimage "github.com/status-im/status-go/images" userimage "github.com/status-im/status-go/images"
"github.com/status-im/status-go/protocol/common" "github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/protobuf" "github.com/status-im/status-go/protocol/protobuf"
@ -24,12 +22,7 @@ func TestGroupChatSuite(t *testing.T) {
} }
type MessengerGroupChatSuite struct { type MessengerGroupChatSuite struct {
suite.Suite MessengerBaseTestSuite
// If one wants to send messages between different instances of Messenger,
// a single Waku service should be shared.
shh types.Waku
logger *zap.Logger
} }
func (s *MessengerGroupChatSuite) newMessenger() *Messenger { func (s *MessengerGroupChatSuite) newMessenger() *Messenger {

View File

@ -2,7 +2,6 @@ package protocol
import ( import (
"context" "context"
"crypto/ecdsa"
"errors" "errors"
"testing" "testing"
@ -14,7 +13,6 @@ import (
"github.com/status-im/status-go/waku" "github.com/status-im/status-go/waku"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"go.uber.org/zap"
"github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/eth-node/types"
) )
@ -26,15 +24,7 @@ func TestMessengerProfileDisplayNameHandlerSuite(t *testing.T) {
} }
type MessengerProfileDisplayNameHandlerSuite struct { type MessengerProfileDisplayNameHandlerSuite struct {
suite.Suite MessengerBaseTestSuite
m *Messenger // main instance of Messenger
privateKey *ecdsa.PrivateKey // private key for the main instance of Messenger
// If one wants to send messages between different instances of Messenger,
// a single Waku service should be shared.
shh types.Waku
logger *zap.Logger
} }
func (s *MessengerProfileDisplayNameHandlerSuite) SetupTest() { func (s *MessengerProfileDisplayNameHandlerSuite) SetupTest() {

View File

@ -2,14 +2,12 @@ package protocol
import ( import (
"context" "context"
"crypto/ecdsa"
"errors" "errors"
"testing" "testing"
"github.com/status-im/status-go/services/browsers" "github.com/status-im/status-go/services/browsers"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"go.uber.org/zap"
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth" 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/crypto"
@ -28,15 +26,7 @@ func TestMessengerInstallationSuite(t *testing.T) {
} }
type MessengerInstallationSuite struct { type MessengerInstallationSuite struct {
suite.Suite MessengerBaseTestSuite
m *Messenger // main instance of Messenger
privateKey *ecdsa.PrivateKey // private key for the main instance of Messenger
// If one wants to send messages between different instances of Messenger,
// a single Waku service should be shared.
shh types.Waku
logger *zap.Logger
} }
func (s *MessengerInstallationSuite) SetupTest() { func (s *MessengerInstallationSuite) SetupTest() {

View File

@ -1,7 +1,6 @@
package protocol package protocol
import ( import (
"crypto/ecdsa"
"testing" "testing"
"time" "time"
@ -21,15 +20,7 @@ func TestMessengerMuteSuite(t *testing.T) {
} }
type MessengerMuteSuite struct { type MessengerMuteSuite struct {
suite.Suite MessengerBaseTestSuite
m *Messenger // main instance of Messenger
privateKey *ecdsa.PrivateKey // private key for the main instance of Messenger
// If one wants to send messages between different instances of Messenger,
// a single Waku service should be shared.
shh types.Waku
logger *zap.Logger
} }
func (s *MessengerMuteSuite) SetupTest() { func (s *MessengerMuteSuite) SetupTest() {

View File

@ -2,11 +2,9 @@ package protocol
import ( import (
"context" "context"
"crypto/ecdsa"
"testing" "testing"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"go.uber.org/zap"
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth" 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/crypto"
@ -21,15 +19,7 @@ func TestMessengerReplySuite(t *testing.T) {
} }
type MessengerReplySuite struct { type MessengerReplySuite struct {
suite.Suite MessengerBaseTestSuite
m *Messenger // main instance of Messenger
privateKey *ecdsa.PrivateKey // private key for the main instance of Messenger
// If one wants to send messages between different instances of Messenger,
// a single Waku service should be shared.
shh types.Waku
logger *zap.Logger
} }
func (s *MessengerReplySuite) SetupTest() { func (s *MessengerReplySuite) SetupTest() {

View File

@ -2,13 +2,11 @@ package protocol
import ( import (
"context" "context"
"crypto/ecdsa"
"fmt" "fmt"
"strings" "strings"
"testing" "testing"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"go.uber.org/zap"
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth" 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/crypto"
@ -27,13 +25,7 @@ func TestMessengerShareUrlsSuite(t *testing.T) {
} }
type MessengerShareUrlsSuite struct { type MessengerShareUrlsSuite struct {
suite.Suite MessengerBaseTestSuite
m *Messenger // main instance of Messenger
privateKey *ecdsa.PrivateKey // private key for the main instance of Messenger
// If one wants to send messages between different instances of Messenger,
// a single waku service should be shared.
shh types.Waku
logger *zap.Logger
} }
func (s *MessengerShareUrlsSuite) SetupTest() { func (s *MessengerShareUrlsSuite) SetupTest() {

View File

@ -2,7 +2,6 @@ package protocol
import ( import (
"context" "context"
"crypto/ecdsa"
"errors" "errors"
"testing" "testing"
@ -16,7 +15,6 @@ import (
"github.com/status-im/status-go/waku" "github.com/status-im/status-go/waku"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"go.uber.org/zap"
"github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/eth-node/types"
) )
@ -26,15 +24,7 @@ func TestMessengerSyncClearHistorySuite(t *testing.T) {
} }
type MessengerSyncClearHistory struct { type MessengerSyncClearHistory struct {
suite.Suite MessengerBaseTestSuite
m *Messenger // main instance of Messenger
privateKey *ecdsa.PrivateKey // private key for the main instance of Messenger
// If one wants to send messages between different instances of Messenger,
// a single Waku service should be shared.
shh types.Waku
logger *zap.Logger
} }
func (s *MessengerSyncClearHistory) SetupTest() { func (s *MessengerSyncClearHistory) SetupTest() {

View File

@ -2,7 +2,6 @@ package protocol
import ( import (
"context" "context"
"crypto/ecdsa"
"errors" "errors"
"fmt" "fmt"
"testing" "testing"
@ -15,7 +14,6 @@ import (
"github.com/status-im/status-go/waku" "github.com/status-im/status-go/waku"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"go.uber.org/zap"
"github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/eth-node/types"
) )
@ -25,15 +23,7 @@ func TestMessengerSyncProfilePictureSuite(t *testing.T) {
} }
type MessengerSyncProfilePictureSuite struct { type MessengerSyncProfilePictureSuite struct {
suite.Suite MessengerBaseTestSuite
m *Messenger // main instance of Messenger
privateKey *ecdsa.PrivateKey // private key for the main instance of Messenger
// If one wants to send messages between different instances of Messenger,
// a single Waku service should be shared.
shh types.Waku
logger *zap.Logger
} }
func (s *MessengerSyncProfilePictureSuite) SetupTest() { func (s *MessengerSyncProfilePictureSuite) SetupTest() {

View File

@ -2,7 +2,6 @@ package protocol
import ( import (
"context" "context"
"crypto/ecdsa"
"errors" "errors"
"testing" "testing"
@ -14,7 +13,6 @@ import (
"github.com/status-im/status-go/waku" "github.com/status-im/status-go/waku"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"go.uber.org/zap"
"github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/eth-node/types"
) )
@ -24,15 +22,7 @@ func TestMessengerSyncWalletSuite(t *testing.T) {
} }
type MessengerSyncWalletSuite struct { type MessengerSyncWalletSuite struct {
suite.Suite MessengerBaseTestSuite
m *Messenger // main instance of Messenger
privateKey *ecdsa.PrivateKey // private key for the main instance of Messenger
// If one wants to send messages between different instances of Messenger,
// a single Waku service should be shared.
shh types.Waku
logger *zap.Logger
} }
func (s *MessengerSyncWalletSuite) SetupTest() { func (s *MessengerSyncWalletSuite) SetupTest() {

View File

@ -1,11 +1,9 @@
package protocol package protocol
import ( import (
"crypto/ecdsa"
"testing" "testing"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"go.uber.org/zap"
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth" 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/crypto"
@ -20,15 +18,7 @@ func TestWalletConnectSessionsSuite(t *testing.T) {
} }
type WalletConnectSessionsSuite struct { type WalletConnectSessionsSuite struct {
suite.Suite MessengerBaseTestSuite
m *Messenger // main instance of Messenger
privateKey *ecdsa.PrivateKey // private key for the main instance of Messenger
// If one wants to send messages between different instances of Messenger,
// a single Waku service should be shared.
shh types.Waku
logger *zap.Logger
} }
func (s *WalletConnectSessionsSuite) SetupTest() { func (s *WalletConnectSessionsSuite) SetupTest() {

View File

@ -8,7 +8,6 @@ import (
"testing" "testing"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"go.uber.org/zap"
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth" 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/crypto"
@ -34,13 +33,7 @@ func TestMessengerPushNotificationSuite(t *testing.T) {
} }
type MessengerPushNotificationSuite struct { type MessengerPushNotificationSuite struct {
suite.Suite MessengerBaseTestSuite
m *Messenger // main instance of Messenger
privateKey *ecdsa.PrivateKey // private key for the main instance of Messenger
// If one wants to send messages between different instances of Messenger,
// a single Waku service should be shared.
shh types.Waku
logger *zap.Logger
} }
func (s *MessengerPushNotificationSuite) SetupTest() { func (s *MessengerPushNotificationSuite) SetupTest() {