Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keymanager api: lowercase statuses #13696

Merged
merged 4 commits into from Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions validator/keymanager/types.go
Expand Up @@ -74,13 +74,13 @@ type KeyStatus struct {
type KeyStatusType string

const (
StatusImported KeyStatusType = "IMPORTED"
StatusError KeyStatusType = "ERROR"
StatusDuplicate KeyStatusType = "DUPLICATE"
StatusUnknown KeyStatusType = "UNKNOWN"
StatusNotFound KeyStatusType = "NOT_FOUND"
StatusDeleted KeyStatusType = "DELETED"
StatusNotActive KeyStatusType = "NOT_ACTIVE"
StatusImported KeyStatusType = "imported"
StatusError KeyStatusType = "error"
StatusDuplicate KeyStatusType = "duplicate"
StatusUnknown KeyStatusType = "unknown"
StatusNotFound KeyStatusType = "not_found"
StatusDeleted KeyStatusType = "deleted"
StatusNotActive KeyStatusType = "not_active"
)

// PublicKeyDeleter allows deleting public keys set in keymanager.
Expand Down
1 change: 1 addition & 0 deletions validator/rpc/BUILD.bazel
Expand Up @@ -30,6 +30,7 @@ go_library(
"//async/event:go_default_library",
"//beacon-chain/rpc/eth/shared:go_default_library",
"//cmd:go_default_library",
"//cmd/validator/flags:go_default_library",
"//config/features:go_default_library",
"//config/fieldparams:go_default_library",
"//config/params:go_default_library",
Expand Down
3 changes: 2 additions & 1 deletion validator/rpc/handlers_keymanager.go
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
"github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/eth/shared"
"github.com/prysmaticlabs/prysm/v5/cmd/validator/flags"
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
"github.com/prysmaticlabs/prysm/v5/config/params"
"github.com/prysmaticlabs/prysm/v5/config/proposer"
Expand Down Expand Up @@ -479,7 +480,7 @@ func (s *Server) ImportRemoteKeys(w http.ResponseWriter, r *http.Request) {
}
}
if isUrlUsed {
log.Warnf("Setting web3signer base url for IMPORTED keys is not supported. Prysm only uses the url from --validators-external-signer-url flag for web3signerKeymanagerKind.")
log.Warnf("Setting the remote signer base url within the request is not supported. The remote signer url can only be set from the --%s flag.", flags.Web3SignerURLFlag.Name)
}

httputil.WriteJson(w, &RemoteKeysResponse{Data: adder.AddPublicKeys(remoteKeys)})
Expand Down
4 changes: 3 additions & 1 deletion validator/rpc/handlers_keymanager_test.go
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -204,7 +205,7 @@ func TestServer_ImportKeystores(t *testing.T) {
resp := &ImportKeystoresResponse{}
require.NoError(t, json.Unmarshal(wr.Body.Bytes(), resp))
require.Equal(t, 2, len(resp.Data))
require.Equal(t, keymanager.StatusError, resp.Data[0].Status)
require.Equal(t, fmt.Sprintf("%v", keymanager.StatusError), strings.ToLower(string(resp.Data[0].Status))) // make sure it's lower case
})
t.Run("200 response even if number of passwords does not match number of keystores", func(t *testing.T) {
request := &ImportKeystoresRequest{
Expand Down Expand Up @@ -1406,6 +1407,7 @@ func TestServer_ImportRemoteKeys(t *testing.T) {
require.NoError(t, json.Unmarshal(w.Body.Bytes(), resp))
for i := 0; i < len(resp.Data); i++ {
require.DeepEqual(t, expectedStatuses[i], resp.Data[i])
require.Equal(t, fmt.Sprintf("%v", expectedStatuses[i].Status), strings.ToLower(string(resp.Data[i].Status)))
}
})
}
Expand Down