mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
9d08ba49de
* change default wallet dir path to not be hidden * gaz + pass wallet dir * gaz + move const to flags * move to flags * move to flags * use filepath join in order to create a valid dir name * add wallet dir * return err no wallet found issues * fix up edit remote * all tests passing * fix test * create or open wallet * ivan feedback * enter password for account with pubkey * Update validator/accounts/v2/accounts_create.go Co-authored-by: Ivan Martinez <ivanthegreatdev@gmail.com> * works * preston feedback * nothing to export * fmt * test for create or open * gaz Co-authored-by: shayzluf <thezluf@gmail.com> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> Co-authored-by: Ivan Martinez <ivanthegreatdev@gmail.com>
70 lines
2.5 KiB
Go
70 lines
2.5 KiB
Go
package v2
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
"github.com/prysmaticlabs/prysm/validator/flags"
|
|
v2keymanager "github.com/prysmaticlabs/prysm/validator/keymanager/v2"
|
|
"github.com/prysmaticlabs/prysm/validator/keymanager/v2/remote"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
func TestEditWalletConfiguration(t *testing.T) {
|
|
walletDir, _, _ := setupWalletAndPasswordsDir(t)
|
|
cliCtx := setupWalletCtx(t, &testWalletConfig{
|
|
walletDir: walletDir,
|
|
keymanagerKind: v2keymanager.Remote,
|
|
})
|
|
wallet, err := NewWallet(cliCtx, v2keymanager.Remote)
|
|
require.NoError(t, err)
|
|
require.NoError(t, wallet.SaveWallet())
|
|
ctx := context.Background()
|
|
|
|
originalCfg := &remote.Config{
|
|
RemoteCertificate: &remote.CertificateConfig{
|
|
ClientCertPath: "/tmp/a.crt",
|
|
ClientKeyPath: "/tmp/b.key",
|
|
CACertPath: "/tmp/c.crt",
|
|
},
|
|
RemoteAddr: "my.server.com:4000",
|
|
}
|
|
encodedCfg, err := remote.MarshalConfigFile(ctx, originalCfg)
|
|
assert.NoError(t, err)
|
|
assert.NoError(t, wallet.WriteKeymanagerConfigToDisk(ctx, encodedCfg))
|
|
|
|
wantCfg := &remote.Config{
|
|
RemoteCertificate: &remote.CertificateConfig{
|
|
ClientCertPath: "/tmp/client.crt",
|
|
ClientKeyPath: "/tmp/client.key",
|
|
CACertPath: "/tmp/ca.crt",
|
|
},
|
|
RemoteAddr: "host.example.com:4000",
|
|
}
|
|
app := cli.App{}
|
|
set := flag.NewFlagSet("test", 0)
|
|
set.String(flags.WalletDirFlag.Name, walletDir, "")
|
|
set.String(flags.GrpcRemoteAddressFlag.Name, wantCfg.RemoteAddr, "")
|
|
set.String(flags.RemoteSignerCertPathFlag.Name, wantCfg.RemoteCertificate.ClientCertPath, "")
|
|
set.String(flags.RemoteSignerKeyPathFlag.Name, wantCfg.RemoteCertificate.ClientKeyPath, "")
|
|
set.String(flags.RemoteSignerCACertPathFlag.Name, wantCfg.RemoteCertificate.CACertPath, "")
|
|
assert.NoError(t, set.Set(flags.WalletDirFlag.Name, walletDir))
|
|
assert.NoError(t, set.Set(flags.GrpcRemoteAddressFlag.Name, wantCfg.RemoteAddr))
|
|
assert.NoError(t, set.Set(flags.RemoteSignerCertPathFlag.Name, wantCfg.RemoteCertificate.ClientCertPath))
|
|
assert.NoError(t, set.Set(flags.RemoteSignerKeyPathFlag.Name, wantCfg.RemoteCertificate.ClientKeyPath))
|
|
assert.NoError(t, set.Set(flags.RemoteSignerCACertPathFlag.Name, wantCfg.RemoteCertificate.CACertPath))
|
|
cliCtx = cli.NewContext(&app, set, nil)
|
|
|
|
err = EditWalletConfiguration(cliCtx)
|
|
require.NoError(t, err)
|
|
encoded, err := wallet.ReadKeymanagerConfigFromDisk(ctx)
|
|
require.NoError(t, err)
|
|
|
|
cfg, err := remote.UnmarshalConfigFile(encoded)
|
|
assert.NoError(t, err)
|
|
assert.DeepEqual(t, wantCfg, cfg)
|
|
}
|