mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Clean up misc warnings (#10900)
* Clean up misc warnings * Gazelle * Rm state assignments Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
@@ -88,7 +88,6 @@ go_test(
|
||||
"//testing/assert:go_default_library",
|
||||
"//testing/mock:go_default_library",
|
||||
"//testing/require:go_default_library",
|
||||
"//time:go_default_library",
|
||||
"//validator/accounts/iface:go_default_library",
|
||||
"//validator/accounts/petnames:go_default_library",
|
||||
"//validator/accounts/wallet:go_default_library",
|
||||
|
||||
@@ -24,7 +24,7 @@ const (
|
||||
ArchiveFilename = "backup.zip"
|
||||
)
|
||||
|
||||
// BackupAccountsCli allows users to select validator accounts from their wallet
|
||||
// Backup allows users to select validator accounts from their wallet
|
||||
// and export them as a backup.zip file containing the keys as EIP-2335 compliant
|
||||
// keystore.json files, which are compatible with importing in other Ethereum consensus clients.
|
||||
func (acm *AccountsCLIManager) Backup(ctx context.Context) error {
|
||||
|
||||
@@ -74,7 +74,7 @@ type ImportAccountsConfig struct {
|
||||
AccountPassword string
|
||||
}
|
||||
|
||||
// ImportAccountsCli can import external, EIP-2335 compliant keystore.json files as
|
||||
// Import can import external, EIP-2335 compliant keystore.json files as
|
||||
// new accounts into the Prysm validator wallet. This uses the CLI to extract
|
||||
// values necessary to run the function.
|
||||
func (acm *AccountsCLIManager) Import(ctx context.Context) error {
|
||||
|
||||
@@ -2,26 +2,22 @@ package accounts
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/prysmaticlabs/prysm/config/params"
|
||||
"github.com/prysmaticlabs/prysm/crypto/bls"
|
||||
"github.com/prysmaticlabs/prysm/encoding/bytesutil"
|
||||
ethpbservice "github.com/prysmaticlabs/prysm/proto/eth/service"
|
||||
"github.com/prysmaticlabs/prysm/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/testing/require"
|
||||
prysmTime "github.com/prysmaticlabs/prysm/time"
|
||||
"github.com/prysmaticlabs/prysm/validator/accounts/iface"
|
||||
"github.com/prysmaticlabs/prysm/validator/accounts/wallet"
|
||||
"github.com/prysmaticlabs/prysm/validator/keymanager"
|
||||
"github.com/prysmaticlabs/prysm/validator/keymanager/local"
|
||||
keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4"
|
||||
)
|
||||
|
||||
func TestImportAccounts_NoPassword(t *testing.T) {
|
||||
@@ -51,7 +47,7 @@ func TestImportAccounts_NoPassword(t *testing.T) {
|
||||
importer, ok := km.(keymanager.Importer)
|
||||
require.Equal(t, true, ok)
|
||||
resp, err := ImportAccounts(context.Background(), &ImportAccountsConfig{
|
||||
Keystores: []*keymanager.Keystore{&keymanager.Keystore{}},
|
||||
Keystores: []*keymanager.Keystore{{}},
|
||||
Importer: importer,
|
||||
AccountPassword: "",
|
||||
})
|
||||
@@ -179,26 +175,3 @@ func Test_importPrivateKeyAsAccount(t *testing.T) {
|
||||
}
|
||||
|
||||
// Returns the fullPath to the newly created keystore file.
|
||||
func createKeystore(t *testing.T, path string) (*keymanager.Keystore, string) {
|
||||
validatingKey, err := bls.RandKey()
|
||||
require.NoError(t, err)
|
||||
encryptor := keystorev4.New()
|
||||
cryptoFields, err := encryptor.Encrypt(validatingKey.Marshal(), password)
|
||||
require.NoError(t, err)
|
||||
id, err := uuid.NewRandom()
|
||||
require.NoError(t, err)
|
||||
keystoreFile := &keymanager.Keystore{
|
||||
Crypto: cryptoFields,
|
||||
ID: id.String(),
|
||||
Pubkey: fmt.Sprintf("%x", validatingKey.PublicKey().Marshal()),
|
||||
Version: encryptor.Version(),
|
||||
Name: encryptor.Name(),
|
||||
}
|
||||
encoded, err := json.MarshalIndent(keystoreFile, "", "\t")
|
||||
require.NoError(t, err)
|
||||
// Write the encoded keystore to disk with the timestamp appended
|
||||
createdAt := prysmTime.Now().Unix()
|
||||
fullPath := filepath.Join(path, fmt.Sprintf(local.KeystoreFileNameFormat, createdAt))
|
||||
require.NoError(t, os.WriteFile(fullPath, encoded, os.ModePerm))
|
||||
return keystoreFile, fullPath
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user