Improve validator import logs (#12429)

* adding small ux improvement

* gaz

* rolling back dir test changes

* Update validator/accounts/accounts_import.go

* adding review suggestion

* missed else part of statement

---------

Co-authored-by: Radosław Kapka <rkapka@wp.pl>
This commit is contained in:
james-prysm
2023-05-23 15:41:41 -05:00
committed by GitHub
parent cfa64ae013
commit 666188dfea
3 changed files with 32 additions and 12 deletions

View File

@@ -71,6 +71,7 @@ go_test(
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
"@com_github_google_uuid//:go_default_library",
"@com_github_sirupsen_logrus//hooks/test:go_default_library",
"@com_github_urfave_cli_v2//:go_default_library",
"@com_github_wealdtech_go_eth2_wallet_encryptor_keystorev4//:go_default_library",
"@org_golang_google_protobuf//types/known/timestamppb:go_default_library",

View File

@@ -2,6 +2,7 @@ package accounts
import (
"flag"
"fmt"
"os"
"path/filepath"
"testing"
@@ -9,15 +10,18 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/prysmaticlabs/prysm/v4/cmd/validator/flags"
"github.com/prysmaticlabs/prysm/v4/testing/assert"
"github.com/prysmaticlabs/prysm/v4/testing/require"
"github.com/prysmaticlabs/prysm/v4/validator/accounts"
"github.com/prysmaticlabs/prysm/v4/validator/keymanager"
"github.com/prysmaticlabs/prysm/v4/validator/keymanager/local"
"github.com/prysmaticlabs/prysm/v4/validator/node"
"github.com/sirupsen/logrus/hooks/test"
"github.com/urfave/cli/v2"
)
func TestWalletWithKeymanager(t *testing.T) {
logHook := test.NewGlobal()
walletDir, passwordsDir, passwordFilePath := setupWalletAndPasswordsDir(t)
keysDir := filepath.Join(t.TempDir(), "keysDir")
require.NoError(t, os.MkdirAll(keysDir, os.ModePerm))
@@ -66,6 +70,9 @@ func TestWalletWithKeymanager(t *testing.T) {
require.NoError(t, err)
require.Equal(t, len(keys), 2)
require.Equal(t, w.KeymanagerKind(), keymanager.Local)
hexKeys := []string{hexutil.Encode(keys[0][:])[2:], hexutil.Encode(keys[1][:])[2:]} // imported keystores don't include the 0x in name
assert.LogsContain(t, logHook, fmt.Sprintf("Imported accounts %v,", hexKeys))
}
func TestWalletWithKeymanager_web3signer(t *testing.T) {