mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-09 11:11:20 +00:00
fac5e19a17
* Add promptutil to shared/promptutil * fixes * comment * Implement promptutil into accounts-v2 * gaz * Merge branch 'master' of github.com:prysmaticlabs/prysm into implement-promptutil * Apply suggestions from code review * gofmt and fix all scanned input * Merge refs/heads/master into implement-promptutil
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(ctx, 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))
|
|
}
|