Use base test messenger suite

This commit is contained in:
Andrea Maria Piana 2023-07-13 11:44:09 +01:00
parent 23ca4ba204
commit 7da855c0bf
16 changed files with 29 additions and 466 deletions

View File

@ -8,7 +8,6 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
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/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"
@ -41,15 +40,6 @@ func (s *BrowserSuite) TearDownTest() {
s.Require().NoError(s.m.Shutdown()) s.Require().NoError(s.m.Shutdown())
} }
func (s *BrowserSuite) 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) TestBrowsersOrderedNewestFirst() { func (s *MessengerBackupSuite) TestBrowsersOrderedNewestFirst() {
msngr := s.newMessenger() msngr := s.newMessenger()
testBrowsers := []*browsers.Browser{ testBrowsers := []*browsers.Browser{

View File

@ -7,15 +7,12 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
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/eth-node/types"
"github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/multiaccounts/settings"
"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"
"github.com/status-im/status-go/protocol/requests" "github.com/status-im/status-go/protocol/requests"
"github.com/status-im/status-go/protocol/tt"
"github.com/status-im/status-go/waku"
) )
func TestMessengerContactRequestSuite(t *testing.T) { func TestMessengerContactRequestSuite(t *testing.T) {
@ -26,34 +23,6 @@ type MessengerContactRequestSuite struct {
MessengerBaseTestSuite MessengerBaseTestSuite
} }
func (s *MessengerContactRequestSuite) SetupTest() {
s.logger = tt.MustCreateTestLogger()
config := waku.DefaultConfig
config.MinimumAcceptedPoW = 0
shh := waku.New(&config, s.logger)
s.shh = gethbridge.NewGethWakuWrapper(shh)
s.Require().NoError(shh.Start())
s.m = s.newMessenger(s.shh)
s.privateKey = s.m.identity
_, err := s.m.Start()
s.Require().NoError(err)
}
func (s *MessengerContactRequestSuite) TearDownTest() {
s.Require().NoError(s.m.Shutdown())
}
func (s *MessengerContactRequestSuite) newMessenger(shh types.Waku) *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 *MessengerContactRequestSuite) findFirstByContentType(messages []*common.Message, contentType protobuf.ChatMessage_ContentType) *common.Message { func (s *MessengerContactRequestSuite) findFirstByContentType(messages []*common.Message, contentType protobuf.ChatMessage_ContentType) *common.Message {
return FindFirstByContentType(messages, contentType) return FindFirstByContentType(messages, contentType)
} }
@ -380,7 +349,7 @@ func (s *MessengerContactRequestSuite) syncInstallationContactV2FromContact(cont
func (s *MessengerContactRequestSuite) TestReceiveAndAcceptContactRequest() { //nolint: unused func (s *MessengerContactRequestSuite) TestReceiveAndAcceptContactRequest() { //nolint: unused
messageText := "hello!" messageText := "hello!"
theirMessenger := s.newMessenger(s.shh) theirMessenger := s.newMessenger()
_, err := theirMessenger.Start() _, err := theirMessenger.Start()
s.Require().NoError(err) s.Require().NoError(err)
defer theirMessenger.Shutdown() // nolint: errcheck defer theirMessenger.Shutdown() // nolint: errcheck
@ -398,7 +367,7 @@ func (s *MessengerContactRequestSuite) TestReceiveAndAcceptContactRequest() { //
func (s *MessengerContactRequestSuite) TestReceiveAndDismissContactRequest() { func (s *MessengerContactRequestSuite) TestReceiveAndDismissContactRequest() {
messageText := "hello!" messageText := "hello!"
theirMessenger := s.newMessenger(s.shh) theirMessenger := s.newMessenger()
_, err := theirMessenger.Start() _, err := theirMessenger.Start()
s.Require().NoError(err) s.Require().NoError(err)
defer theirMessenger.Shutdown() // nolint: errcheck defer theirMessenger.Shutdown() // nolint: errcheck
@ -416,7 +385,7 @@ func (s *MessengerContactRequestSuite) TestReceiveAndDismissContactRequest() {
func (s *MessengerContactRequestSuite) TestReceiveAcceptAndRetractContactRequest() { //nolint: unused func (s *MessengerContactRequestSuite) TestReceiveAcceptAndRetractContactRequest() { //nolint: unused
messageText := "hello!" messageText := "hello!"
theirMessenger := s.newMessenger(s.shh) theirMessenger := s.newMessenger()
_, err := theirMessenger.Start() _, err := theirMessenger.Start()
s.Require().NoError(err) s.Require().NoError(err)
defer theirMessenger.Shutdown() // nolint: errcheck defer theirMessenger.Shutdown() // nolint: errcheck
@ -437,7 +406,7 @@ func (s *MessengerContactRequestSuite) TestReceiveAcceptAndRetractContactRequest
func (s *MessengerContactRequestSuite) TestReceiveAndAcceptContactRequestTwice() { //nolint: unused func (s *MessengerContactRequestSuite) TestReceiveAndAcceptContactRequestTwice() { //nolint: unused
messageText := "hello!" messageText := "hello!"
theirMessenger := s.newMessenger(s.shh) theirMessenger := s.newMessenger()
_, err := theirMessenger.Start() _, err := theirMessenger.Start()
s.Require().NoError(err) s.Require().NoError(err)
defer theirMessenger.Shutdown() // nolint: errcheck defer theirMessenger.Shutdown() // nolint: errcheck
@ -494,7 +463,7 @@ func (s *MessengerContactRequestSuite) TestReceiveAndAcceptContactRequestTwice()
func (s *MessengerContactRequestSuite) TestAcceptLatestContactRequestForContact() { func (s *MessengerContactRequestSuite) TestAcceptLatestContactRequestForContact() {
messageText := "hello!" messageText := "hello!"
theirMessenger := s.newMessenger(s.shh) theirMessenger := s.newMessenger()
_, err := theirMessenger.Start() _, err := theirMessenger.Start()
s.Require().NoError(err) s.Require().NoError(err)
defer theirMessenger.Shutdown() // nolint: errcheck defer theirMessenger.Shutdown() // nolint: errcheck
@ -589,7 +558,7 @@ func (s *MessengerContactRequestSuite) TestAcceptLatestContactRequestForContact(
func (s *MessengerContactRequestSuite) TestDismissLatestContactRequestForContact() { func (s *MessengerContactRequestSuite) TestDismissLatestContactRequestForContact() {
messageText := "hello!" messageText := "hello!"
theirMessenger := s.newMessenger(s.shh) theirMessenger := s.newMessenger()
_, err := theirMessenger.Start() _, err := theirMessenger.Start()
s.Require().NoError(err) s.Require().NoError(err)
defer theirMessenger.Shutdown() // nolint: errcheck defer theirMessenger.Shutdown() // nolint: errcheck
@ -635,7 +604,7 @@ func (s *MessengerContactRequestSuite) TestPairedDevicesRemoveContact() {
pairTwoDevices(&s.Suite, alice1, alice2) pairTwoDevices(&s.Suite, alice1, alice2)
pairTwoDevices(&s.Suite, alice2, alice1) pairTwoDevices(&s.Suite, alice2, alice1)
bob := s.newMessenger(s.shh) bob := s.newMessenger()
_, err = bob.Start() _, err = bob.Start()
s.Require().NoError(err) s.Require().NoError(err)
defer bob.Shutdown() // nolint: errcheck defer bob.Shutdown() // nolint: errcheck
@ -699,7 +668,7 @@ func (s *MessengerContactRequestSuite) TestAliceRecoverStateSendContactRequest()
alice1 := s.m alice1 := s.m
bob := s.newMessenger(s.shh) bob := s.newMessenger()
_, err := bob.Start() _, err := bob.Start()
s.Require().NoError(err) s.Require().NoError(err)
defer bob.Shutdown() // nolint: errcheck defer bob.Shutdown() // nolint: errcheck
@ -771,7 +740,7 @@ func (s *MessengerContactRequestSuite) TestAliceRecoverStateReceiveContactReques
alice1 := s.m alice1 := s.m
bob := s.newMessenger(s.shh) bob := s.newMessenger()
_, err := bob.Start() _, err := bob.Start()
s.Require().NoError(err) s.Require().NoError(err)
defer bob.Shutdown() // nolint: errcheck defer bob.Shutdown() // nolint: errcheck
@ -852,7 +821,7 @@ func (s *MessengerContactRequestSuite) TestAliceOfflineRetractsAndAddsCorrectOrd
alice1 := s.m alice1 := s.m
bob := s.newMessenger(s.shh) bob := s.newMessenger()
_, err := bob.Start() _, err := bob.Start()
s.Require().NoError(err) s.Require().NoError(err)
defer bob.Shutdown() // nolint: errcheck defer bob.Shutdown() // nolint: errcheck
@ -902,7 +871,7 @@ func (s *MessengerContactRequestSuite) TestAliceOfflineRetractsAndAddsWrongOrder
alice1 := s.m alice1 := s.m
bob := s.newMessenger(s.shh) bob := s.newMessenger()
_, err := bob.Start() _, err := bob.Start()
s.Require().NoError(err) s.Require().NoError(err)
defer bob.Shutdown() // nolint: errcheck defer bob.Shutdown() // nolint: errcheck
@ -954,7 +923,7 @@ func (s *MessengerContactRequestSuite) TestAliceOfflineRetractsAndAddsWrongOrder
func (s *MessengerContactRequestSuite) TestAliceResendsContactRequestAfterRemovingBobFromContacts() { func (s *MessengerContactRequestSuite) TestAliceResendsContactRequestAfterRemovingBobFromContacts() {
messageTextFirst := "hello 1!" messageTextFirst := "hello 1!"
theirMessenger := s.newMessenger(s.shh) theirMessenger := s.newMessenger()
_, err := theirMessenger.Start() _, err := theirMessenger.Start()
s.Require().NoError(err) s.Require().NoError(err)
defer theirMessenger.Shutdown() // nolint: errcheck defer theirMessenger.Shutdown() // nolint: errcheck
@ -1010,7 +979,7 @@ func (s *MessengerContactRequestSuite) TestBobSendsContactRequestAfterDecliningO
alice := s.m alice := s.m
bob := s.newMessenger(s.shh) bob := s.newMessenger()
_, err := bob.Start() _, err := bob.Start()
s.Require().NoError(err) s.Require().NoError(err)
defer bob.Shutdown() // nolint: errcheck defer bob.Shutdown() // nolint: errcheck
@ -1193,7 +1162,7 @@ func (s *MessengerContactRequestSuite) TestBobRestoresIncomingContactRequestFrom
alice := s.m alice := s.m
bob1 := s.newMessenger(s.shh) bob1 := s.newMessenger()
_, err := bob1.Start() _, err := bob1.Start()
s.Require().NoError(err) s.Require().NoError(err)
defer bob1.Shutdown() // nolint: errcheck defer bob1.Shutdown() // nolint: errcheck
@ -1273,7 +1242,7 @@ func (s *MessengerContactRequestSuite) TestAliceRestoresOutgoingContactRequestFr
alice1 := s.m alice1 := s.m
bob := s.newMessenger(s.shh) bob := s.newMessenger()
_, err := bob.Start() _, err := bob.Start()
s.Require().NoError(err) s.Require().NoError(err)
defer bob.Shutdown() // nolint: errcheck defer bob.Shutdown() // nolint: errcheck

View File

@ -32,31 +32,18 @@ func (s *MessengerContactUpdateSuite) SetupTest() {
s.shh = gethbridge.NewGethWakuWrapper(shh) s.shh = gethbridge.NewGethWakuWrapper(shh)
s.Require().NoError(shh.Start()) s.Require().NoError(shh.Start())
s.m = s.newMessenger(s.shh) s.m = s.newMessenger()
s.privateKey = s.m.identity s.privateKey = s.m.identity
_, err := s.m.Start() _, err := s.m.Start()
s.Require().NoError(err) s.Require().NoError(err)
} }
func (s *MessengerContactUpdateSuite) TearDownTest() {
s.Require().NoError(s.m.Shutdown())
}
func (s *MessengerContactUpdateSuite) newMessenger(shh types.Waku) *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 *MessengerContactUpdateSuite) TestReceiveContactUpdate() { func (s *MessengerContactUpdateSuite) TestReceiveContactUpdate() {
theirName := "ens-name.stateofus.eth" theirName := "ens-name.stateofus.eth"
contactID := types.EncodeHex(crypto.FromECDSAPub(&s.m.identity.PublicKey)) contactID := types.EncodeHex(crypto.FromECDSAPub(&s.m.identity.PublicKey))
theirMessenger := s.newMessenger(s.shh) theirMessenger := s.newMessenger()
_, err := theirMessenger.Start() _, err := theirMessenger.Start()
s.Require().NoError(err) s.Require().NoError(err)
defer theirMessenger.Shutdown() // nolint: errcheck defer theirMessenger.Shutdown() // nolint: errcheck
@ -124,7 +111,7 @@ func (s *MessengerContactUpdateSuite) TestReceiveContactUpdate() {
func (s *MessengerContactUpdateSuite) TestAddContact() { func (s *MessengerContactUpdateSuite) TestAddContact() {
contactID := types.EncodeHex(crypto.FromECDSAPub(&s.m.identity.PublicKey)) contactID := types.EncodeHex(crypto.FromECDSAPub(&s.m.identity.PublicKey))
theirMessenger := s.newMessenger(s.shh) theirMessenger := s.newMessenger()
_, err := theirMessenger.Start() _, err := theirMessenger.Start()
s.Require().NoError(err) s.Require().NoError(err)
defer theirMessenger.Shutdown() // nolint: errcheck defer theirMessenger.Shutdown() // nolint: errcheck
@ -158,7 +145,7 @@ func (s *MessengerContactUpdateSuite) TestAddContactWithENS() {
contactID := types.EncodeHex(crypto.FromECDSAPub(&s.m.identity.PublicKey)) contactID := types.EncodeHex(crypto.FromECDSAPub(&s.m.identity.PublicKey))
ensName := "blah.stateofus.eth" ensName := "blah.stateofus.eth"
theirMessenger := s.newMessenger(s.shh) theirMessenger := s.newMessenger()
_, err := theirMessenger.Start() _, err := theirMessenger.Start()
s.Require().NoError(err) s.Require().NoError(err)
defer theirMessenger.Shutdown() // nolint: errcheck defer theirMessenger.Shutdown() // nolint: errcheck

View File

@ -6,14 +6,11 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
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/eth-node/types"
"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"
"github.com/status-im/status-go/protocol/requests" "github.com/status-im/status-go/protocol/requests"
"github.com/status-im/status-go/protocol/tt"
"github.com/status-im/status-go/waku"
) )
func TestMessengerEditMessageSuite(t *testing.T) { func TestMessengerEditMessageSuite(t *testing.T) {
@ -24,34 +21,6 @@ type MessengerEditMessageSuite struct {
MessengerBaseTestSuite MessengerBaseTestSuite
} }
func (s *MessengerEditMessageSuite) SetupTest() {
s.logger = tt.MustCreateTestLogger()
config := waku.DefaultConfig
config.MinimumAcceptedPoW = 0
shh := waku.New(&config, s.logger)
s.shh = gethbridge.NewGethWakuWrapper(shh)
s.Require().NoError(shh.Start())
s.m = s.newMessenger()
s.privateKey = s.m.identity
_, err := s.m.Start()
s.Require().NoError(err)
}
func (s *MessengerEditMessageSuite) TearDownTest() {
s.Require().NoError(s.m.Shutdown())
}
func (s *MessengerEditMessageSuite) 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 *MessengerEditMessageSuite) TestEditMessage() { func (s *MessengerEditMessageSuite) TestEditMessage() {
theirMessenger := s.newMessenger() theirMessenger := s.newMessenger()
_, err := theirMessenger.Start() _, err := theirMessenger.Start()

View File

@ -8,14 +8,11 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
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/eth-node/types"
"github.com/status-im/status-go/multiaccounts" "github.com/status-im/status-go/multiaccounts"
"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"
"github.com/status-im/status-go/protocol/tt"
"github.com/status-im/status-go/waku"
) )
func TestMessengerEmojiSuite(t *testing.T) { func TestMessengerEmojiSuite(t *testing.T) {
@ -26,34 +23,6 @@ type MessengerEmojiSuite struct {
MessengerBaseTestSuite MessengerBaseTestSuite
} }
func (s *MessengerEmojiSuite) SetupTest() {
s.logger = tt.MustCreateTestLogger()
config := waku.DefaultConfig
config.MinimumAcceptedPoW = 0
shh := waku.New(&config, s.logger)
s.shh = gethbridge.NewGethWakuWrapper(shh)
s.Require().NoError(shh.Start())
s.m = s.newMessenger(s.shh)
s.privateKey = s.m.identity
_, err := s.m.Start()
s.Require().NoError(err)
}
func (s *MessengerEmojiSuite) TearDownTest() {
s.Require().NoError(s.m.Shutdown())
}
func (s *MessengerEmojiSuite) newMessenger(shh types.Waku) *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 *MessengerEmojiSuite) TestSendEmoji() { func (s *MessengerEmojiSuite) TestSendEmoji() {
alice := s.m alice := s.m
alice.account = &multiaccounts.Account{KeyUID: "0xdeadbeef"} alice.account = &multiaccounts.Account{KeyUID: "0xdeadbeef"}
@ -140,7 +109,7 @@ func (s *MessengerEmojiSuite) TestSendEmoji() {
func (s *MessengerEmojiSuite) TestEmojiPrivateGroup() { func (s *MessengerEmojiSuite) TestEmojiPrivateGroup() {
bob := s.m bob := s.m
alice := s.newMessenger(s.shh) alice := s.newMessenger()
_, err := alice.Start() _, err := alice.Start()
s.Require().NoError(err) s.Require().NoError(err)
defer alice.Shutdown() // nolint: errcheck defer alice.Shutdown() // nolint: errcheck

View File

@ -8,13 +8,9 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth"
"github.com/status-im/status-go/eth-node/crypto"
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"
"github.com/status-im/status-go/protocol/tt"
"github.com/status-im/status-go/waku"
) )
func TestGroupChatSuite(t *testing.T) { func TestGroupChatSuite(t *testing.T) {
@ -25,16 +21,6 @@ type MessengerGroupChatSuite struct {
MessengerBaseTestSuite MessengerBaseTestSuite
} }
func (s *MessengerGroupChatSuite) newMessenger() *Messenger {
privateKey, err := crypto.GenerateKey()
s.Require().NoError(err)
messenger, err := newMessengerWithKey(s.shh, privateKey, s.logger, []Option{})
s.Require().NoError(err)
return messenger
}
func (s *MessengerGroupChatSuite) startNewMessenger() *Messenger { func (s *MessengerGroupChatSuite) startNewMessenger() *Messenger {
messenger := s.newMessenger() messenger := s.newMessenger()
@ -44,19 +30,6 @@ func (s *MessengerGroupChatSuite) startNewMessenger() *Messenger {
return messenger return messenger
} }
func (s *MessengerGroupChatSuite) SetupTest() {
s.logger = tt.MustCreateTestLogger()
config := waku.DefaultConfig
config.MinimumAcceptedPoW = 0
shh := waku.New(&config, s.logger)
s.shh = gethbridge.NewGethWakuWrapper(shh)
s.Require().NoError(shh.Start())
}
func (s *MessengerGroupChatSuite) TearDownTest() {
}
func (s *MessengerGroupChatSuite) createGroupChat(creator *Messenger, name string, members []string) *Chat { func (s *MessengerGroupChatSuite) createGroupChat(creator *Messenger, name string, members []string) *Chat {
response, err := creator.CreateGroupChatWithMembers(context.Background(), name, members) response, err := creator.CreateGroupChatWithMembers(context.Background(), name, members)
s.Require().NoError(err) s.Require().NoError(err)

View File

@ -5,16 +5,11 @@ import (
"errors" "errors"
"testing" "testing"
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/multiaccounts/accounts" "github.com/status-im/status-go/multiaccounts/accounts"
"github.com/status-im/status-go/protocol/encryption/multidevice" "github.com/status-im/status-go/protocol/encryption/multidevice"
"github.com/status-im/status-go/protocol/tt" "github.com/status-im/status-go/protocol/tt"
"github.com/status-im/status-go/waku"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/status-im/status-go/eth-node/types"
) )
const testDisplayName = "My New Display Name" const testDisplayName = "My New Display Name"
@ -27,35 +22,6 @@ type MessengerProfileDisplayNameHandlerSuite struct {
MessengerBaseTestSuite MessengerBaseTestSuite
} }
func (s *MessengerProfileDisplayNameHandlerSuite) SetupTest() {
s.logger = tt.MustCreateTestLogger()
config := waku.DefaultConfig
config.MinimumAcceptedPoW = 0
shh := waku.New(&config, s.logger)
s.shh = gethbridge.NewGethWakuWrapper(shh)
s.Require().NoError(shh.Start())
s.m = s.newMessenger(s.shh)
s.privateKey = s.m.identity
// We start the messenger in order to receive installations
_, err := s.m.Start()
s.Require().NoError(err)
}
func (s *MessengerProfileDisplayNameHandlerSuite) TearDownTest() {
s.Require().NoError(s.m.Shutdown())
}
func (s *MessengerProfileDisplayNameHandlerSuite) newMessenger(shh types.Waku) *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 *MessengerProfileDisplayNameHandlerSuite) TestDisplayNameChange() { func (s *MessengerProfileDisplayNameHandlerSuite) TestDisplayNameChange() {
// check display name for the created instance // check display name for the created instance
displayName, err := s.m.settings.DisplayName() displayName, err := s.m.settings.DisplayName()

View File

@ -9,13 +9,11 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
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/eth-node/types"
"github.com/status-im/status-go/protocol/encryption/multidevice" "github.com/status-im/status-go/protocol/encryption/multidevice"
"github.com/status-im/status-go/protocol/requests" "github.com/status-im/status-go/protocol/requests"
"github.com/status-im/status-go/protocol/tt" "github.com/status-im/status-go/protocol/tt"
"github.com/status-im/status-go/waku"
) )
const statusChatID = "status" const statusChatID = "status"
@ -29,36 +27,6 @@ type MessengerInstallationSuite struct {
MessengerBaseTestSuite MessengerBaseTestSuite
} }
func (s *MessengerInstallationSuite) SetupTest() {
s.logger = tt.MustCreateTestLogger()
config := waku.DefaultConfig
config.MinimumAcceptedPoW = 0
shh := waku.New(&config, s.logger)
s.shh = gethbridge.NewGethWakuWrapper(shh)
s.Require().NoError(shh.Start())
s.m = s.newMessenger(s.shh)
s.privateKey = s.m.identity
// We start the messenger in order to receive installations
_, err := s.m.Start()
s.Require().NoError(err)
}
func (s *MessengerInstallationSuite) TearDownTest() {
s.Require().NoError(s.m.Shutdown())
}
func (s *MessengerInstallationSuite) newMessenger(shh types.Waku) *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 *MessengerInstallationSuite) TestReceiveInstallation() { func (s *MessengerInstallationSuite) TestReceiveInstallation() {
theirMessenger, err := newMessengerWithKey(s.shh, s.privateKey, s.logger, nil) theirMessenger, err := newMessengerWithKey(s.shh, s.privateKey, s.logger, nil)
s.Require().NoError(err) s.Require().NoError(err)
@ -297,7 +265,7 @@ func (s *MessengerInstallationSuite) TestSyncInstallationNewMessages() {
// pair // pair
bob2, err := newMessengerWithKey(s.shh, s.privateKey, s.logger, nil) bob2, err := newMessengerWithKey(s.shh, s.privateKey, s.logger, nil)
s.Require().NoError(err) s.Require().NoError(err)
alice := s.newMessenger(s.shh) alice := s.newMessenger()
err = bob2.SetInstallationMetadata(bob2.installationID, &multidevice.InstallationMetadata{ err = bob2.SetInstallationMetadata(bob2.installationID, &multidevice.InstallationMetadata{
Name: "their-name", Name: "their-name",

View File

@ -7,12 +7,8 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"go.uber.org/zap" "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/crypto"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/protocol/requests" "github.com/status-im/status-go/protocol/requests"
"github.com/status-im/status-go/protocol/tt"
"github.com/status-im/status-go/waku"
) )
func TestMessengerMuteSuite(t *testing.T) { func TestMessengerMuteSuite(t *testing.T) {
@ -23,34 +19,6 @@ type MessengerMuteSuite struct {
MessengerBaseTestSuite MessengerBaseTestSuite
} }
func (s *MessengerMuteSuite) SetupTest() {
s.logger = tt.MustCreateTestLogger()
config := waku.DefaultConfig
config.MinimumAcceptedPoW = 0
shh := waku.New(&config, s.logger)
s.shh = gethbridge.NewGethWakuWrapper(shh)
s.Require().NoError(shh.Start())
s.m = s.newMessenger(s.shh)
s.privateKey = s.m.identity
_, err := s.m.Start()
s.Require().NoError(err)
}
func (s *MessengerMuteSuite) TearDownTest() {
s.Require().NoError(s.m.Shutdown())
}
func (s *MessengerMuteSuite) newMessenger(shh types.Waku) *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 *MessengerMuteSuite) TestSetMute() { func (s *MessengerMuteSuite) TestSetMute() {
key, err := crypto.GenerateKey() key, err := crypto.GenerateKey()
s.Require().NoError(err) s.Require().NoError(err)

View File

@ -6,12 +6,8 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
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/multiaccounts" "github.com/status-im/status-go/multiaccounts"
"github.com/status-im/status-go/protocol/tt"
"github.com/status-im/status-go/waku"
) )
func TestMessengerReplySuite(t *testing.T) { func TestMessengerReplySuite(t *testing.T) {
@ -22,34 +18,6 @@ type MessengerReplySuite struct {
MessengerBaseTestSuite MessengerBaseTestSuite
} }
func (s *MessengerReplySuite) SetupTest() {
s.logger = tt.MustCreateTestLogger()
config := waku.DefaultConfig
config.MinimumAcceptedPoW = 0
shh := waku.New(&config, s.logger)
s.shh = gethbridge.NewGethWakuWrapper(shh)
s.Require().NoError(shh.Start())
s.m = s.newMessenger(s.shh)
s.privateKey = s.m.identity
_, err := s.m.Start()
s.Require().NoError(err)
}
func (s *MessengerReplySuite) TearDownTest() {
s.Require().NoError(s.m.Shutdown())
}
func (s *MessengerReplySuite) newMessenger(shh types.Waku) *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 *MessengerReplySuite) TestReceiveReply() { func (s *MessengerReplySuite) TestReceiveReply() {
alice := s.m alice := s.m
alice.account = &multiaccounts.Account{KeyUID: "0xdeadbeef"} alice.account = &multiaccounts.Account{KeyUID: "0xdeadbeef"}

View File

@ -8,16 +8,13 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
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/eth-node/types"
"github.com/status-im/status-go/protocol/common" "github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/communities" "github.com/status-im/status-go/protocol/communities"
"github.com/status-im/status-go/protocol/protobuf" "github.com/status-im/status-go/protocol/protobuf"
"github.com/status-im/status-go/protocol/requests" "github.com/status-im/status-go/protocol/requests"
"github.com/status-im/status-go/protocol/tt"
"github.com/status-im/status-go/protocol/urls" "github.com/status-im/status-go/protocol/urls"
"github.com/status-im/status-go/waku"
) )
func TestMessengerShareUrlsSuite(t *testing.T) { func TestMessengerShareUrlsSuite(t *testing.T) {
@ -28,34 +25,6 @@ type MessengerShareUrlsSuite struct {
MessengerBaseTestSuite MessengerBaseTestSuite
} }
func (s *MessengerShareUrlsSuite) SetupTest() {
s.logger = tt.MustCreateTestLogger()
config := waku.DefaultConfig
config.MinimumAcceptedPoW = 0
shh := waku.New(&config, s.logger)
s.shh = gethbridge.NewGethWakuWrapper(shh)
s.Require().NoError(shh.Start())
s.m = s.newMessenger()
s.privateKey = s.m.identity
_, err := s.m.Start()
s.Require().NoError(err)
}
func (s *MessengerShareUrlsSuite) TearDownTest() {
s.Require().NoError(s.m.Shutdown())
}
func (s *MessengerShareUrlsSuite) 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 *MessengerShareUrlsSuite) createCommunity() *communities.Community { func (s *MessengerShareUrlsSuite) createCommunity() *communities.Community {
description := &requests.CreateCommunity{ description := &requests.CreateCommunity{
Membership: protobuf.CommunityPermissions_NO_MEMBERSHIP, Membership: protobuf.CommunityPermissions_NO_MEMBERSHIP,

View File

@ -8,15 +8,10 @@ import (
"github.com/status-im/status-go/protocol/common" "github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/requests" "github.com/status-im/status-go/protocol/requests"
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/protocol/encryption/multidevice" "github.com/status-im/status-go/protocol/encryption/multidevice"
"github.com/status-im/status-go/protocol/tt" "github.com/status-im/status-go/protocol/tt"
"github.com/status-im/status-go/waku"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/status-im/status-go/eth-node/types"
) )
func TestMessengerSyncClearHistorySuite(t *testing.T) { func TestMessengerSyncClearHistorySuite(t *testing.T) {
@ -27,36 +22,6 @@ type MessengerSyncClearHistory struct {
MessengerBaseTestSuite MessengerBaseTestSuite
} }
func (s *MessengerSyncClearHistory) SetupTest() {
s.logger = tt.MustCreateTestLogger()
config := waku.DefaultConfig
config.MinimumAcceptedPoW = 0
shh := waku.New(&config, s.logger)
s.shh = gethbridge.NewGethWakuWrapper(shh)
s.Require().NoError(shh.Start())
s.m = s.newMessenger(s.shh)
s.privateKey = s.m.identity
// We start the messenger in order to receive installations
_, err := s.m.Start()
s.Require().NoError(err)
}
func (s *MessengerSyncClearHistory) TearDownTest() {
s.Require().NoError(s.m.Shutdown())
}
func (s *MessengerSyncClearHistory) newMessenger(shh types.Waku) *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 *MessengerSyncClearHistory) pair() *Messenger { func (s *MessengerSyncClearHistory) pair() *Messenger {
theirMessenger, err := newMessengerWithKey(s.shh, s.privateKey, s.logger, nil) theirMessenger, err := newMessengerWithKey(s.shh, s.privateKey, s.logger, nil)
s.Require().NoError(err) s.Require().NoError(err)

View File

@ -6,16 +6,11 @@ import (
"fmt" "fmt"
"testing" "testing"
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/images" "github.com/status-im/status-go/images"
"github.com/status-im/status-go/protocol/encryption/multidevice" "github.com/status-im/status-go/protocol/encryption/multidevice"
"github.com/status-im/status-go/protocol/tt" "github.com/status-im/status-go/protocol/tt"
"github.com/status-im/status-go/waku"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/status-im/status-go/eth-node/types"
) )
func TestMessengerSyncProfilePictureSuite(t *testing.T) { func TestMessengerSyncProfilePictureSuite(t *testing.T) {
@ -26,36 +21,6 @@ type MessengerSyncProfilePictureSuite struct {
MessengerBaseTestSuite MessengerBaseTestSuite
} }
func (s *MessengerSyncProfilePictureSuite) SetupTest() {
s.logger = tt.MustCreateTestLogger()
config := waku.DefaultConfig
config.MinimumAcceptedPoW = 0
shh := waku.New(&config, s.logger)
s.shh = gethbridge.NewGethWakuWrapper(shh)
s.Require().NoError(shh.Start())
s.m = s.newMessenger(s.shh)
s.privateKey = s.m.identity
// We start the messenger in order to receive installations
_, err := s.m.Start()
s.Require().NoError(err)
}
func (s *MessengerSyncProfilePictureSuite) TearDownTest() {
s.Require().NoError(s.m.Shutdown())
}
func (s *MessengerSyncProfilePictureSuite) newMessenger(shh types.Waku) *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 *MessengerSyncProfilePictureSuite) TestSyncProfilePicture() { func (s *MessengerSyncProfilePictureSuite) TestSyncProfilePicture() {
// Add identity images // Add identity images

View File

@ -5,16 +5,11 @@ import (
"errors" "errors"
"testing" "testing"
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/multiaccounts/accounts" "github.com/status-im/status-go/multiaccounts/accounts"
"github.com/status-im/status-go/protocol/encryption/multidevice" "github.com/status-im/status-go/protocol/encryption/multidevice"
"github.com/status-im/status-go/protocol/tt" "github.com/status-im/status-go/protocol/tt"
"github.com/status-im/status-go/waku"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/status-im/status-go/eth-node/types"
) )
func TestMessengerSyncWalletSuite(t *testing.T) { func TestMessengerSyncWalletSuite(t *testing.T) {
@ -25,36 +20,6 @@ type MessengerSyncWalletSuite struct {
MessengerBaseTestSuite MessengerBaseTestSuite
} }
func (s *MessengerSyncWalletSuite) SetupTest() {
s.logger = tt.MustCreateTestLogger()
config := waku.DefaultConfig
config.MinimumAcceptedPoW = 0
shh := waku.New(&config, s.logger)
s.shh = gethbridge.NewGethWakuWrapper(shh)
s.Require().NoError(shh.Start())
s.m = s.newMessenger(s.shh)
s.privateKey = s.m.identity
// We start the messenger in order to receive installations
_, err := s.m.Start()
s.Require().NoError(err)
}
func (s *MessengerSyncWalletSuite) TearDownTest() {
s.Require().NoError(s.m.Shutdown())
}
func (s *MessengerSyncWalletSuite) newMessenger(shh types.Waku) *Messenger {
privateKey, err := crypto.GenerateKey()
s.Require().NoError(err)
messenger, err := newMessengerWithKey(s.shh, privateKey, s.logger, nil)
s.Require().NoError(err)
return messenger
}
// user should not be able to change a keypair name directly, it follows display name // user should not be able to change a keypair name directly, it follows display name
func (s *MessengerSyncWalletSuite) TestProfileKeypairNameChange() { func (s *MessengerSyncWalletSuite) TestProfileKeypairNameChange() {
profileKp := accounts.GetProfileKeypairForTest(true, false, false) profileKp := accounts.GetProfileKeypairForTest(true, false, false)

View File

@ -5,12 +5,7 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
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"
"github.com/status-im/status-go/protocol/requests" "github.com/status-im/status-go/protocol/requests"
"github.com/status-im/status-go/protocol/tt"
"github.com/status-im/status-go/waku"
) )
func TestWalletConnectSessionsSuite(t *testing.T) { func TestWalletConnectSessionsSuite(t *testing.T) {
@ -21,36 +16,6 @@ type WalletConnectSessionsSuite struct {
MessengerBaseTestSuite MessengerBaseTestSuite
} }
func (s *WalletConnectSessionsSuite) SetupTest() {
s.logger = tt.MustCreateTestLogger()
config := waku.DefaultConfig
config.MinimumAcceptedPoW = 0
shh := waku.New(&config, s.logger)
s.shh = gethbridge.NewGethWakuWrapper(shh)
s.Require().NoError(shh.Start())
s.m = s.newMessenger(s.shh)
s.privateKey = s.m.identity
// We start the messenger in order to receive installations
_, err := s.m.Start()
s.Require().NoError(err)
}
func (s *WalletConnectSessionsSuite) TearDownTest() {
s.Require().NoError(s.m.Shutdown())
}
func (s *WalletConnectSessionsSuite) newMessenger(shh types.Waku) *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 *WalletConnectSessionsSuite) TestCreateReadAndDeleteSessions() { func (s *WalletConnectSessionsSuite) TestCreateReadAndDeleteSessions() {
peerID1 := "0643983b-0000-2222-1111-b05fdac338zd1" peerID1 := "0643983b-0000-2222-1111-b05fdac338zd1"
peerID2 := "0643983b-0000-2222-1111-b05fdac338zd2" peerID2 := "0643983b-0000-2222-1111-b05fdac338zd2"

View File

@ -8,6 +8,7 @@ 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"
@ -33,7 +34,13 @@ func TestMessengerPushNotificationSuite(t *testing.T) {
} }
type MessengerPushNotificationSuite struct { type MessengerPushNotificationSuite struct {
MessengerBaseTestSuite suite.Suite
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() {