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()
|
||||
password := "some-password"
|
||||
tmpdir := t.TempDir()
|
||||
nameserver := "8.8.8.8"
|
||||
|
||||
b := NewGethStatusBackend()
|
||||
createAccountRequest := &requests.CreateAccount{
|
||||
|
@ -832,15 +833,28 @@ func TestLoginAccount(t *testing.T) {
|
|||
BackupDisabledDataDir: tmpdir,
|
||||
NetworkID: 1,
|
||||
LogFilePath: tmpdir + "/log",
|
||||
WakuV2Nameserver: &nameserver,
|
||||
}
|
||||
c := make(chan interface{}, 10)
|
||||
signal.SetMobileSignalHandler(func(data []byte) {
|
||||
if strings.Contains(string(data), "node.login") {
|
||||
if strings.Contains(string(data), signal.EventLoggedIn) {
|
||||
c <- struct{}{}
|
||||
}
|
||||
})
|
||||
waitForLogin := func(chan interface{}) {
|
||||
select {
|
||||
case <-c:
|
||||
break
|
||||
case <-time.After(5 * time.Second):
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
_, err := b.CreateAccountAndLogin(createAccountRequest)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, nameserver, b.config.WakuV2Config.Nameserver)
|
||||
|
||||
waitForLogin(c)
|
||||
require.NoError(t, b.Logout())
|
||||
require.NoError(t, b.StopNode())
|
||||
|
||||
|
@ -851,14 +865,13 @@ func TestLoginAccount(t *testing.T) {
|
|||
loginAccountRequest := &requests.Login{
|
||||
KeyUID: accounts[0].KeyUID,
|
||||
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) {
|
||||
|
|
|
@ -624,7 +624,7 @@ func (b *GethStatusBackend) loginAccount(request *requests.Login) error {
|
|||
|
||||
defaultCfg.WalletConfig = buildWalletConfig(&request.WalletSecretsConfig)
|
||||
|
||||
err = b.updateNodeConfigFleet(defaultCfg)
|
||||
err = b.UpdateNodeConfigFleet(defaultCfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -694,10 +694,14 @@ func (b *GethStatusBackend) loginAccount(request *requests.Login) error {
|
|||
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.
|
||||
// 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()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -726,13 +730,6 @@ func (b *GethStatusBackend) startNodeWithAccount(acc multiaccounts.Account, pass
|
|||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -231,7 +231,12 @@ func login(accountData, password, configJSON string) error {
|
|||
|
||||
api.RunAsync(func() error {
|
||||
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 {
|
||||
log.Error("failed to start a node", "key-uid", account.KeyUID, "error", err)
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue