mirror of
https://github.com/status-im/status-go.git
synced 2025-02-16 16:56:53 +00:00
fix: lost wakuv2 nameserver with CreateAccountAndLogin
(#4813)
This commit is contained in:
parent
df930b1d73
commit
c32ab70c33
@ -822,6 +822,7 @@ func TestLoginAccount(t *testing.T) {
|
|||||||
utils.Init()
|
utils.Init()
|
||||||
password := "some-password"
|
password := "some-password"
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
nameserver := "8.8.8.8"
|
||||||
|
|
||||||
b := NewGethStatusBackend()
|
b := NewGethStatusBackend()
|
||||||
createAccountRequest := &requests.CreateAccount{
|
createAccountRequest := &requests.CreateAccount{
|
||||||
@ -832,15 +833,28 @@ func TestLoginAccount(t *testing.T) {
|
|||||||
BackupDisabledDataDir: tmpdir,
|
BackupDisabledDataDir: tmpdir,
|
||||||
NetworkID: 1,
|
NetworkID: 1,
|
||||||
LogFilePath: tmpdir + "/log",
|
LogFilePath: tmpdir + "/log",
|
||||||
|
WakuV2Nameserver: &nameserver,
|
||||||
}
|
}
|
||||||
c := make(chan interface{}, 10)
|
c := make(chan interface{}, 10)
|
||||||
signal.SetMobileSignalHandler(func(data []byte) {
|
signal.SetMobileSignalHandler(func(data []byte) {
|
||||||
if strings.Contains(string(data), "node.login") {
|
if strings.Contains(string(data), signal.EventLoggedIn) {
|
||||||
c <- struct{}{}
|
c <- struct{}{}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
waitForLogin := func(chan interface{}) {
|
||||||
|
select {
|
||||||
|
case <-c:
|
||||||
|
break
|
||||||
|
case <-time.After(5 * time.Second):
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_, err := b.CreateAccountAndLogin(createAccountRequest)
|
_, err := b.CreateAccountAndLogin(createAccountRequest)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, nameserver, b.config.WakuV2Config.Nameserver)
|
||||||
|
|
||||||
|
waitForLogin(c)
|
||||||
require.NoError(t, b.Logout())
|
require.NoError(t, b.Logout())
|
||||||
require.NoError(t, b.StopNode())
|
require.NoError(t, b.StopNode())
|
||||||
|
|
||||||
@ -849,16 +863,15 @@ func TestLoginAccount(t *testing.T) {
|
|||||||
require.Len(t, accounts, 1)
|
require.Len(t, accounts, 1)
|
||||||
|
|
||||||
loginAccountRequest := &requests.Login{
|
loginAccountRequest := &requests.Login{
|
||||||
KeyUID: accounts[0].KeyUID,
|
KeyUID: accounts[0].KeyUID,
|
||||||
Password: password,
|
Password: password,
|
||||||
}
|
WakuV2Nameserver: nameserver,
|
||||||
require.NoError(t, b.LoginAccount(loginAccountRequest))
|
|
||||||
select {
|
|
||||||
case <-c:
|
|
||||||
break
|
|
||||||
case <-time.After(5 * time.Second):
|
|
||||||
t.FailNow()
|
|
||||||
}
|
}
|
||||||
|
err = b.LoginAccount(loginAccountRequest)
|
||||||
|
require.NoError(t, err)
|
||||||
|
waitForLogin(c)
|
||||||
|
|
||||||
|
require.Equal(t, nameserver, b.config.WakuV2Config.Nameserver)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVerifyDatabasePassword(t *testing.T) {
|
func TestVerifyDatabasePassword(t *testing.T) {
|
||||||
|
@ -624,7 +624,7 @@ func (b *GethStatusBackend) loginAccount(request *requests.Login) error {
|
|||||||
|
|
||||||
defaultCfg.WalletConfig = buildWalletConfig(&request.WalletSecretsConfig)
|
defaultCfg.WalletConfig = buildWalletConfig(&request.WalletSecretsConfig)
|
||||||
|
|
||||||
err = b.updateNodeConfigFleet(defaultCfg)
|
err = b.UpdateNodeConfigFleet(defaultCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -694,10 +694,14 @@ func (b *GethStatusBackend) loginAccount(request *requests.Login) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// updateNodeConfigFleet loads the fleet from the settings and updates the node configuration
|
// UpdateNodeConfigFleet loads the fleet from the settings and updates the node configuration
|
||||||
// If the fleet in settings is empty, or not supported anymore, it will be overridden with the default fleet.
|
// If the fleet in settings is empty, or not supported anymore, it will be overridden with the default fleet.
|
||||||
// In that case settings fleet value remain the same, only runtime node configuration is updated.
|
// In that case settings fleet value remain the same, only runtime node configuration is updated.
|
||||||
func (b *GethStatusBackend) updateNodeConfigFleet(config *params.NodeConfig) error {
|
func (b *GethStatusBackend) UpdateNodeConfigFleet(config *params.NodeConfig) error {
|
||||||
|
if config == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
accountSettings, err := b.GetSettings()
|
accountSettings, err := b.GetSettings()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -726,13 +730,6 @@ func (b *GethStatusBackend) startNodeWithAccount(acc multiaccounts.Account, pass
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: This is code duplication from `loginAccount` method
|
|
||||||
// We should stop using this endpoint in desktop: https://github.com/status-im/status-desktop/issues/12977
|
|
||||||
err = b.updateNodeConfigFleet(inputNodeCfg)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = b.loadNodeConfig(inputNodeCfg)
|
err = b.loadNodeConfig(inputNodeCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -231,7 +231,12 @@ func login(accountData, password, configJSON string) error {
|
|||||||
|
|
||||||
api.RunAsync(func() error {
|
api.RunAsync(func() error {
|
||||||
log.Debug("start a node with account", "key-uid", account.KeyUID)
|
log.Debug("start a node with account", "key-uid", account.KeyUID)
|
||||||
err := statusBackend.StartNodeWithAccount(account, password, &conf)
|
err := statusBackend.UpdateNodeConfigFleet(&conf)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = statusBackend.StartNodeWithAccount(account, password, &conf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("failed to start a node", "key-uid", account.KeyUID, "error", err)
|
log.Error("failed to start a node", "key-uid", account.KeyUID, "error", err)
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user