mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
cbc27e0f2e
* wallet should no longer deal with account passwords * ensure tests are fixed * Merge branch 'master' into corrupted-pass * move mnemonic logic into right place * rem fmts * add fileutil * gazelle * imports * move seed logic to derived * fix tests * imports * gaz * Merge refs/heads/master into corrupted-pass * merge confs * Merge refs/heads/master into corrupted-pass * ivan's feedback * Merge branch 'corrupted-pass' of github.com:prysmaticlabs/prysm into corrupted-pass * gaz * fix shared test * Merge refs/heads/master into corrupted-pass * resolve conflicts * fix test build
55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
package v2
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
v2keymanager "github.com/prysmaticlabs/prysm/validator/keymanager/v2"
|
|
"github.com/prysmaticlabs/prysm/validator/keymanager/v2/derived"
|
|
)
|
|
|
|
func TestCreateAccount_Derived(t *testing.T) {
|
|
walletDir, passwordsDir, passwordFile := setupWalletAndPasswordsDir(t)
|
|
numAccounts := int64(5)
|
|
cliCtx := setupWalletCtx(t, &testWalletConfig{
|
|
walletDir: walletDir,
|
|
passwordsDir: passwordsDir,
|
|
walletPasswordFile: passwordFile,
|
|
accountPasswordFile: passwordFile,
|
|
keymanagerKind: v2keymanager.Derived,
|
|
numAccounts: numAccounts,
|
|
})
|
|
|
|
// We attempt to create the wallet.
|
|
_, err := CreateWallet(cliCtx)
|
|
require.NoError(t, err)
|
|
|
|
// We attempt to open the newly created wallet.
|
|
ctx := context.Background()
|
|
wallet, err := OpenWallet(cliCtx)
|
|
assert.NoError(t, err)
|
|
|
|
// We read the keymanager config for the newly created wallet.
|
|
encoded, err := wallet.ReadKeymanagerConfigFromDisk(ctx)
|
|
assert.NoError(t, err)
|
|
cfg, err := derived.UnmarshalConfigFile(encoded)
|
|
assert.NoError(t, err)
|
|
|
|
// We assert the created configuration was as desired.
|
|
assert.DeepEqual(t, derived.DefaultConfig(), cfg)
|
|
|
|
require.NoError(t, CreateAccount(cliCtx))
|
|
|
|
keymanager, err := wallet.InitializeKeymanager(cliCtx, true)
|
|
require.NoError(t, err)
|
|
km, ok := keymanager.(*derived.Keymanager)
|
|
if !ok {
|
|
t.Fatal("not a derived keymanager")
|
|
}
|
|
names, err := km.ValidatingAccountNames(ctx)
|
|
assert.NoError(t, err)
|
|
require.Equal(t, len(names), int(numAccounts))
|
|
}
|