mirror of
https://github.com/status-im/status-go.git
synced 2026-08-31 00:51:12 +00:00
Part of the Go project layout migration, item 27. Pure move plus import-path rewrite across 502 files. No API or behaviour change. `internal/` keeps the messaging application logic unimportable from outside the module, which is what the issue asks for -- status-go is consumed through the C-bindings in mobile/, not as a Go library. Things that had to follow the move, beyond the Go imports: - tools/generate-handlers/template.txt. messenger_handlers.go is generated, and the template hard-codes the imports it emits, so the generated file kept importing protocol/common and failed typecheck. - .gitignore. The ignore rule for that generated file was pinned to the old path; without moving it, a 1486-line generated file starts being tracked. - Makefile: the logosstorage and torrent test targets (both the archive packages and ./protocol itself), the archive README, migration-protocol. - scripts/run_unit_tests.sh, which names the protocol package explicitly to shard its tests. - scripts/cleanup_generated_files.sh and .golangci.yml. scripts/migration_check.sh also needed a fix that is not specific to this move: it validated every file the branch touched under a migration dir against the timestamp naming rule, and a directory rename makes every migration in it look newly added. It now excludes renames, so moving a migration is not mistaken for adding one. refs #7067
83 lines
2.8 KiB
Go
83 lines
2.8 KiB
Go
package protocol
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
"github.com/status-im/status-go/internal/db/multiaccounts/common"
|
|
"github.com/status-im/status-go/internal/protocol/requests"
|
|
messagingtypes "github.com/status-im/status-go/pkg/messaging/types"
|
|
)
|
|
|
|
func TestMessengerSettings(t *testing.T) {
|
|
suite.Run(t, new(MessengerSettingsSuite))
|
|
}
|
|
|
|
type MessengerSettingsSuite struct {
|
|
MessengerBaseTestSuite
|
|
m2 *Messenger
|
|
}
|
|
|
|
func (s *MessengerSettingsSuite) SetupTest() {
|
|
s.MessengerBaseTestSuite.SetupTest()
|
|
s.m2 = s.anotherMessenger()
|
|
|
|
prepareMessengersForPairing(&s.Suite, s.m, s.m2)
|
|
}
|
|
func prepareMessengersForPairing(s *suite.Suite, m1, m2 *Messenger) {
|
|
// Set m's installation metadata
|
|
aim := &messagingtypes.InstallationMetadata{
|
|
Name: "m's-device",
|
|
DeviceType: "m's-device-type",
|
|
}
|
|
err := m1.SetInstallationMetadata(m1.installationID, aim)
|
|
s.Require().NoError(err)
|
|
|
|
// Set m 2's installation metadata
|
|
a2im := &messagingtypes.InstallationMetadata{
|
|
Name: "m's-other-device",
|
|
DeviceType: "m's-other-device-type",
|
|
}
|
|
err = m2.SetInstallationMetadata(m2.installationID, a2im)
|
|
s.Require().NoError(err)
|
|
}
|
|
|
|
func (s *MessengerSettingsSuite) TestSetCustomizationColor() {
|
|
PairDevices(&s.Suite, s.m2, s.m)
|
|
PairDevices(&s.Suite, s.m, s.m2)
|
|
|
|
s.Require().Equal(s.m.account.KeyUID, s.m2.account.KeyUID)
|
|
|
|
err := s.m.multiAccounts.SaveAccount(*s.m.account)
|
|
s.Require().NoError(err)
|
|
err = s.m2.multiAccounts.SaveAccount(*s.m2.account)
|
|
s.Require().NoError(err)
|
|
|
|
// check that accounts have no customization color
|
|
acc, err := s.m.multiAccounts.GetAccount(s.m.account.KeyUID)
|
|
s.Require().NoError(err)
|
|
acc2, err := s.m2.multiAccounts.GetAccount(s.m2.account.KeyUID)
|
|
s.Require().NoError(err)
|
|
s.Require().Equal(acc.CustomizationColor, common.CustomizationColor(""))
|
|
s.Require().Equal(acc.CustomizationColorClock, uint64(0))
|
|
s.Require().Equal(acc2.CustomizationColor, common.CustomizationColor(""))
|
|
s.Require().Equal(acc2.CustomizationColorClock, uint64(0))
|
|
|
|
err = s.m.SetCustomizationColor(context.TODO(), &requests.SetCustomizationColor{KeyUID: s.m.account.KeyUID, CustomizationColor: common.CustomizationColorBlue})
|
|
s.Require().NoError(err)
|
|
s.Require().Equal(s.m.account.GetCustomizationColor(), common.CustomizationColorBlue)
|
|
_, err = WaitOnMessengerResponse(s.m2, func(r *MessengerResponse) bool {
|
|
return len(r.CustomizationColor) > 0
|
|
}, "message syncAccountCustomizationColor not received")
|
|
s.Require().NoError(err)
|
|
s.Require().Equal(s.m2.account.GetCustomizationColor(), common.CustomizationColorBlue)
|
|
acc, err = s.m2.multiAccounts.GetAccount(s.m.account.KeyUID)
|
|
s.Require().NoError(err)
|
|
acc2, err = s.m2.multiAccounts.GetAccount(s.m2.account.KeyUID)
|
|
s.Require().NoError(err)
|
|
s.Require().Equal(common.CustomizationColorBlue, acc.CustomizationColor)
|
|
s.Require().Equal(acc.CustomizationColor, acc2.CustomizationColor)
|
|
}
|