mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-16 23:08:45 +00:00
60558b7970
* keymanagers no longer use cli ctx * rename important values to keymanageropts * further refactor accounts methods to reduce cli dependency * separating cli vs non cli methods for various accounts functions * recover wallet cli vs non-cli mode * ensure half of tests build * accounts v2 package now builds * full revamp wallet creation or opening wallets * everything builds * tests pass finally * Merge branch 'master' into no-cli-keymanagers * ensure commands work as expected * Merge branch 'no-cli-keymanagers' of github.com:prysmaticlabs/prysm into no-cli-keymanagers * further fix build * account creation comments * fix imports and comments * fix up failing test * fix build * Update derived.go * Update direct.go * Update remote.go * Fixed variable * fix up red tests * use Cli instead of CLI, fix tests, and address Radek's feedback * Merge refs/heads/master into no-cli-keymanagers * Merge refs/heads/master into no-cli-keymanagers * Merge refs/heads/master into no-cli-keymanagers * Merge refs/heads/master into no-cli-keymanagers * Merge refs/heads/master into no-cli-keymanagers * Merge refs/heads/master into no-cli-keymanagers * Merge refs/heads/master into no-cli-keymanagers * Merge refs/heads/master into no-cli-keymanagers
57 lines
1.7 KiB
Go
57 lines
1.7 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 := CreateAndSaveWalletCli(cliCtx)
|
|
require.NoError(t, err)
|
|
|
|
// We attempt to open the newly created wallet.
|
|
ctx := context.Background()
|
|
wallet, err := OpenWallet(cliCtx.Context, &WalletConfig{
|
|
WalletDir: walletDir,
|
|
})
|
|
assert.NoError(t, err)
|
|
|
|
// We read the keymanager config for the newly created wallet.
|
|
encoded, err := wallet.ReadKeymanagerConfigFromDisk(ctx)
|
|
assert.NoError(t, err)
|
|
opts, err := derived.UnmarshalOptionsFile(encoded)
|
|
assert.NoError(t, err)
|
|
|
|
// We assert the created configuration was as desired.
|
|
assert.DeepEqual(t, derived.DefaultKeymanagerOpts(), opts)
|
|
|
|
require.NoError(t, CreateAccountCli(cliCtx))
|
|
|
|
keymanager, err := wallet.InitializeKeymanager(cliCtx.Context, 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))
|
|
}
|