[Feature] Allow setting TestNetworksEnabled in Create/Restore Account (#4971)
This commit adds the ability to set the "TestNetworksEnabled" flag while creating an account. Function affected: "generateOrImportAccount" This helps Dev/E2E/PR builds to enable Test Networks by default and disable them on release/nightly builds. Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
This commit is contained in:
parent
2aa306ef4c
commit
1886dc3360
|
@ -1572,3 +1572,53 @@ func TestWalletConfigOnLoginAccount(t *testing.T) {
|
||||||
|
|
||||||
require.NoError(t, b.Logout())
|
require.NoError(t, b.Logout())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTestnetEnabledSettingOnCreateAccount(t *testing.T) {
|
||||||
|
utils.Init()
|
||||||
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
|
b := NewGethStatusBackend()
|
||||||
|
|
||||||
|
// Creating an account with test networks enabled
|
||||||
|
createAccountRequest1 := &requests.CreateAccount{
|
||||||
|
DisplayName: "User-1",
|
||||||
|
CustomizationColor: "#ffffff",
|
||||||
|
Emoji: "some",
|
||||||
|
Password: "password123",
|
||||||
|
BackupDisabledDataDir: tmpdir,
|
||||||
|
NetworkID: 1,
|
||||||
|
LogFilePath: tmpdir + "/log",
|
||||||
|
TestNetworksEnabled: true,
|
||||||
|
}
|
||||||
|
_, err := b.CreateAccountAndLogin(createAccountRequest1)
|
||||||
|
require.NoError(t, err)
|
||||||
|
statusNode := b.statusNode
|
||||||
|
require.NotNil(t, statusNode)
|
||||||
|
|
||||||
|
settings, err := b.GetSettings()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.True(t, settings.TestNetworksEnabled)
|
||||||
|
|
||||||
|
require.NoError(t, b.Logout())
|
||||||
|
|
||||||
|
// Creating an account with test networks disabled
|
||||||
|
createAccountRequest2 := &requests.CreateAccount{
|
||||||
|
DisplayName: "User-2",
|
||||||
|
CustomizationColor: "#ffffff",
|
||||||
|
Emoji: "some",
|
||||||
|
Password: "password",
|
||||||
|
BackupDisabledDataDir: tmpdir,
|
||||||
|
NetworkID: 1,
|
||||||
|
LogFilePath: tmpdir + "/log",
|
||||||
|
}
|
||||||
|
_, err = b.CreateAccountAndLogin(createAccountRequest2)
|
||||||
|
require.NoError(t, err)
|
||||||
|
statusNode = b.statusNode
|
||||||
|
require.NotNil(t, statusNode)
|
||||||
|
|
||||||
|
settings, err = b.GetSettings()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.False(t, settings.TestNetworksEnabled)
|
||||||
|
|
||||||
|
require.NoError(t, b.Logout())
|
||||||
|
}
|
||||||
|
|
|
@ -94,6 +94,8 @@ func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derive
|
||||||
s.ShowCommunityAssetWhenSendingTokens = true
|
s.ShowCommunityAssetWhenSendingTokens = true
|
||||||
s.DisplayAssetsBelowBalance = false
|
s.DisplayAssetsBelowBalance = false
|
||||||
|
|
||||||
|
s.TestNetworksEnabled = false
|
||||||
|
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1372,6 +1372,7 @@ func (b *GethStatusBackend) generateOrImportAccount(mnemonic string, customizati
|
||||||
settings.DisplayName = request.DisplayName
|
settings.DisplayName = request.DisplayName
|
||||||
settings.PreviewPrivacy = request.PreviewPrivacy
|
settings.PreviewPrivacy = request.PreviewPrivacy
|
||||||
settings.CurrentNetwork = request.CurrentNetwork
|
settings.CurrentNetwork = request.CurrentNetwork
|
||||||
|
settings.TestNetworksEnabled = request.TestNetworksEnabled
|
||||||
|
|
||||||
// If restoring an account, we don't set the mnemonic
|
// If restoring an account, we don't set the mnemonic
|
||||||
if mnemonic == "" {
|
if mnemonic == "" {
|
||||||
|
|
|
@ -315,6 +315,8 @@ func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derive
|
||||||
defaultSettings.ProfilePicturesVisibility = settings.ProfilePicturesVisibilityEveryone
|
defaultSettings.ProfilePicturesVisibility = settings.ProfilePicturesVisibilityEveryone
|
||||||
defaultSettings.LinkPreviewRequestEnabled = true
|
defaultSettings.LinkPreviewRequestEnabled = true
|
||||||
|
|
||||||
|
defaultSettings.TestNetworksEnabled = false
|
||||||
|
|
||||||
visibleTokens := make(map[string][]string)
|
visibleTokens := make(map[string][]string)
|
||||||
visibleTokens["mainnet"] = []string{"SNT"}
|
visibleTokens["mainnet"] = []string{"SNT"}
|
||||||
visibleTokensJSON, err := json.Marshal(visibleTokens)
|
visibleTokensJSON, err := json.Marshal(visibleTokens)
|
||||||
|
|
|
@ -363,6 +363,8 @@ func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derive
|
||||||
defaultSettings.ProfilePicturesVisibility = settings.ProfilePicturesVisibilityEveryone
|
defaultSettings.ProfilePicturesVisibility = settings.ProfilePicturesVisibilityEveryone
|
||||||
defaultSettings.LinkPreviewRequestEnabled = true
|
defaultSettings.LinkPreviewRequestEnabled = true
|
||||||
|
|
||||||
|
defaultSettings.TestNetworksEnabled = false
|
||||||
|
|
||||||
visibleTokens := make(map[string][]string)
|
visibleTokens := make(map[string][]string)
|
||||||
visibleTokens["mainnet"] = []string{"SNT"}
|
visibleTokens["mainnet"] = []string{"SNT"}
|
||||||
visibleTokensJSON, err := json.Marshal(visibleTokens)
|
visibleTokensJSON, err := json.Marshal(visibleTokens)
|
||||||
|
|
|
@ -240,6 +240,8 @@ func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derive
|
||||||
defaultSettings.ProfilePicturesVisibility = settings.ProfilePicturesVisibilityEveryone
|
defaultSettings.ProfilePicturesVisibility = settings.ProfilePicturesVisibilityEveryone
|
||||||
defaultSettings.LinkPreviewRequestEnabled = true
|
defaultSettings.LinkPreviewRequestEnabled = true
|
||||||
|
|
||||||
|
defaultSettings.TestNetworksEnabled = false
|
||||||
|
|
||||||
visibleTokens := make(map[string][]string)
|
visibleTokens := make(map[string][]string)
|
||||||
visibleTokens["mainnet"] = []string{"SNT"}
|
visibleTokens["mainnet"] = []string{"SNT"}
|
||||||
visibleTokensJSON, err := json.Marshal(visibleTokens)
|
visibleTokensJSON, err := json.Marshal(visibleTokens)
|
||||||
|
|
|
@ -146,10 +146,11 @@ INSERT INTO settings (
|
||||||
mnemonic_was_not_shown,
|
mnemonic_was_not_shown,
|
||||||
wallet_token_preferences_group_by_community,
|
wallet_token_preferences_group_by_community,
|
||||||
wallet_collectible_preferences_group_by_collection,
|
wallet_collectible_preferences_group_by_collection,
|
||||||
wallet_collectible_preferences_group_by_community
|
wallet_collectible_preferences_group_by_community,
|
||||||
|
test_networks_enabled
|
||||||
) VALUES (
|
) VALUES (
|
||||||
?,?,?,?,?,?,?,?,?,?,?,?,?,?,
|
?,?,?,?,?,?,?,?,?,?,?,?,?,?,
|
||||||
?,?,?,?,?,?,?,?,?,'id',?,?,?,?,?,?,?,?,?)`,
|
?,?,?,?,?,?,?,?,?,'id',?,?,?,?,?,?,?,?,?,?)`,
|
||||||
s.Address,
|
s.Address,
|
||||||
s.Currency,
|
s.Currency,
|
||||||
s.CurrentNetwork,
|
s.CurrentNetwork,
|
||||||
|
@ -182,6 +183,7 @@ INSERT INTO settings (
|
||||||
s.TokenGroupByCommunity,
|
s.TokenGroupByCommunity,
|
||||||
s.CollectibleGroupByCollection,
|
s.CollectibleGroupByCollection,
|
||||||
s.CollectibleGroupByCommunity,
|
s.CollectibleGroupByCommunity,
|
||||||
|
s.TestNetworksEnabled,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -40,6 +40,8 @@ type CreateAccount struct {
|
||||||
CurrentNetwork string `json:"currentNetwork"`
|
CurrentNetwork string `json:"currentNetwork"`
|
||||||
NetworkID uint64 `json:"networkId"`
|
NetworkID uint64 `json:"networkId"`
|
||||||
|
|
||||||
|
TestNetworksEnabled bool `json:"testNetworksEnabled"`
|
||||||
|
|
||||||
WalletSecretsConfig
|
WalletSecretsConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue