chore: test that login still works with 0.97.3 (#2661)

This commit is contained in:
Richard Ramos 2022-05-04 18:46:49 +04:00 committed by GitHub
parent 07c6808385
commit c71ccdb4e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 91 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import (
"io/ioutil" "io/ioutil"
"math/rand" "math/rand"
"os" "os"
"path"
"path/filepath" "path/filepath"
"sync" "sync"
"testing" "testing"
@ -678,3 +679,86 @@ func TestConvertAccount(t *testing.T) {
err = backend.ensureAppDBOpened(keycardAccount, keycardPassword) err = backend.ensureAppDBOpened(keycardAccount, keycardPassword)
require.NoError(t, err) require.NoError(t, err)
} }
func copyFile(srcFolder string, dstFolder string, fileName string, t *testing.T) {
data, err := ioutil.ReadFile(path.Join(srcFolder, fileName))
if err != nil {
t.Fail()
}
err = ioutil.WriteFile(path.Join(dstFolder, fileName), data, 0600)
if err != nil {
t.Fail()
}
}
func copyDir(srcFolder string, dstFolder string, t *testing.T) {
files, err := ioutil.ReadDir(srcFolder)
require.NoError(t, err)
for _, file := range files {
if !file.IsDir() {
copyFile(srcFolder, dstFolder, file.Name(), t)
} else {
childFolder := path.Join(srcFolder, file.Name())
newFolder := path.Join(dstFolder, file.Name())
err = os.MkdirAll(newFolder, os.ModePerm)
require.NoError(t, err)
copyDir(childFolder, newFolder, t)
}
}
}
func login(t *testing.T, conf *params.NodeConfig) {
// The following passwords and DB used in this test unit are only
// used to determine if login process works correctly after a migration
// Expected account data:
keyUID := "0x7c46c8f6f059ab72d524f2a6d356904db30bb0392636172ab3929a6bd2220f84" // #nosec G101
username := "TestUser"
passwd := "0xC888C9CE9E098D5864D3DED6EBCC140A12142263BACE3A23A36F9905F12BD64A" // #nosec G101
b := NewGethStatusBackend()
require.NoError(t, b.AccountManager().InitKeystore(conf.KeyStoreDir))
b.UpdateRootDataDir(conf.DataDir)
require.NoError(t, b.OpenAccounts())
accounts, err := b.GetAccounts()
require.NoError(t, err)
require.Len(t, accounts, 1)
require.Equal(t, username, accounts[0].Name)
require.Equal(t, keyUID, accounts[0].KeyUID)
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
defer wg.Done()
err := b.StartNodeWithAccount(accounts[0], passwd, conf)
require.NoError(t, err)
}()
wg.Wait()
require.NoError(t, b.Logout())
require.NoError(t, b.StopNode())
}
func TestLoginAndMigrationsStillWorkWithExistingUsers(t *testing.T) {
utils.Init()
srcFolder := "../static/test-0.97.3-account/"
tmpdir, err := ioutil.TempDir("", "login-and-migrations-with-existing-users")
require.NoError(t, err)
defer os.Remove(tmpdir)
copyDir(srcFolder, tmpdir, t)
conf, err := params.NewNodeConfig(tmpdir, 1777)
require.NoError(t, err)
login(t, conf)
login(t, conf) // Login twice to catch weird errors that only appear after logout
}

View File

@ -0,0 +1,3 @@
Test account data
===
Only used for determining if we can login with older status-go accounts in the latest version of status-go

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
{"address":"5bf1edc27ef25cea0cb93c576c341a1da8b50570","crypto":{"cipher":"aes-128-ctr","ciphertext":"69c9ecfab192dc4df2599d56f7c426f56bce434069c77f8f9704bd7687fecf43","cipherparams":{"iv":"8509b04497397a5597983161e5fad83a"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"a00f6bbc468a0195bf22d1aaf8202eb2cd76e89effe027649c37af00bfb4323a"},"mac":"73976623b70d2f326ca7f24a4132649f99810b58a50298647a9b11eb84201443"},"id":"9b1161eb-5376-42ca-b800-e5a729cdc552","version":3,"extendedkey":{"cipher":"aes-128-ctr","ciphertext":"8879b98e4784e523477e3daec14b8ef39a537171254f583d0d1cae6a69098cb190438d7edb77a9cece39893d91539208ae3e02a64a5b6ef787d6a81a32a68211c2ac466a3d1936cd89e6bedbecb52390bd56f0d8adcbc4ab5467e685d0d2fec30de8488176062e7369d6dc01c3d618","cipherparams":{"iv":"56e81ac6946cf9bd2cc60b1aaeddc3a4"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"28c894c2629ce42e1a62a223b84fc95578e6783087d2143699fc4d60734a9445"},"mac":"e388a222830d5b7521b64fb33cf8551b8df9f28dc0eb0184d4553c8269707c0a"},"subaccountindex":0}

View File

@ -0,0 +1 @@
{"address":"063073cf50e5a8d85f521ccc90661eb87a6ea58a","crypto":{"cipher":"aes-128-ctr","ciphertext":"ad8d489c2620fc242f38cfda0e13c4a24b298264f83a07564fa5ac845e1349e4","cipherparams":{"iv":"846f19e45c5517bcbcadca30799e9a2c"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"6fedaed114574d1e5b6e782a65cc9c97c7554d8c4c32bd4b1de38b186e82ead6"},"mac":"f7b17259991a40b768d6bfb512f94d78f5a177269e255df724bfe7474f43564e"},"id":"bfec9d07-2e21-4ade-90f9-fe05af36e107","version":3,"extendedkey":{"cipher":"aes-128-ctr","ciphertext":"4b2a69f8140d40661276f03035b30436ad00e33499e7e2ab8b69dff30aca7bde05e8b3ad09af9b702ab8ec337d945cf0a9a5c06567ec7e7db714bb89b5943f920a078295cee7e23f86391e00ef615469742005440b8a3850c97d713042d42ff3e2e529023e0c32ba85e3f119032620","cipherparams":{"iv":"d628819d9186ff78e61558fad0683337"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"b5a9ce0b5193af4a47739a9268aa3856495274384f879cacd2ffca253a59f068"},"mac":"44dac9d54b59587842db00577dac361af987560dcc7b742638143634217bf3c8"},"subaccountindex":0}

View File

@ -0,0 +1 @@
{"address":"18ccbd1a68ba5450be6269e0d5d19fe2c0dcf96c","crypto":{"cipher":"aes-128-ctr","ciphertext":"b7e8fe2057505abc4036e04e5558d0b168f4b402a89ed809a4cef203f4714fb5","cipherparams":{"iv":"5a719567a2a8267b31d2a2d4036aea71"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"82a162471524686cd8f83e48fc6bf19df5df703ef73e58901d2f6f80ff75d973"},"mac":"cf564a6f39ddefe86b4683eafc5d16be67ceb3d373e3f7439292f82ff73c06ae"},"id":"66dd21c0-71fd-4909-89cf-f180c31e7496","version":3,"extendedkey":{"cipher":"aes-128-ctr","ciphertext":"676b15e77d5bc4e822c697300ed687ff8556a0aaa5ecffcb4f23cf137b56204372f78ec7f5e54602ecff288696391f1e27ac4bdc54ab27212ba56b238934f86369b2a5207494c24a864cea6caee5761604d8f9d4aaac6e595a0c86e6e2bb1bc1d18bdc86306ab3459e066ac14f5dd9","cipherparams":{"iv":"c6feb4c715eaa743bf245bdb35ad2c7c"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"815f7bb5003c5c444281751b86a13212ddcfbef63064695dafff913244301ea5"},"mac":"acb8895cbc759230abc0077c86fc730ce71ce9ecf74730bf0dafd8d5bf58210e"},"subaccountindex":0}

View File

@ -0,0 +1 @@
{"address":"843e5334e6f4516640808676f992b827b03e8887","crypto":{"cipher":"aes-128-ctr","ciphertext":"1fa10361d2a28852203ddbab0b71093403a7b59c8d5adeb55796d08d4016b137","cipherparams":{"iv":"9d239e515afa14734046254fb2798ad6"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"8e6ded9f6cfe96adc261a36f35c530ca6c1ca53bf9f66cbd7c14619c7088d955"},"mac":"270403da5717564b279d46d66f6cd87e60ff5386bca7affd5f3b205c71c3abc5"},"id":"31be5eec-9866-4feb-85a8-c40cffa47723","version":3,"extendedkey":{"cipher":"aes-128-ctr","ciphertext":"4ae1b1b42a32c56028938c63bfe0dd7ff7a3e01089fe62ce73505b286789a49e4bf0917e664161d8c6061fe2d43de215d665e92b3af0de2e50d465a27248909d3b662afe7a833e48a95fa1bc406b5f274229edb102eaac62cffc73ea76725fd79adec77dd7729adc5a1112ce8c75f7","cipherparams":{"iv":"a6d5e9a78bec96739f5151851cc33e81"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"bb57bef12ff5d694122e3966d07c0fd426ef3e8d2e22e69dd8d66e0fad9d8ce3"},"mac":"741bf73b2649bfc3a8551174ef61fe0e10bca2a4f79b15b390d1437a5e647d66"},"subaccountindex":0}