prysm-pulse/validator/rpc/server_test.go
james-prysm 7f931bf65b
Keymanager APIs - get,post,delete graffiti (#13474)
* wip

* adding set and delete graffiti

* fixing mock

* fixing mock linting and putting in scaffolds for unit tests

* adding some tests

* gaz

* adding tests

* updating missing unit test

* fixing unit test

* Update validator/rpc/handlers_keymanager.go

Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com>

* Update validator/client/propose.go

Co-authored-by: Radosław Kapka <rkapka@wp.pl>

* Update validator/rpc/handlers_keymanager.go

Co-authored-by: Radosław Kapka <rkapka@wp.pl>

* Update validator/client/propose.go

Co-authored-by: Radosław Kapka <rkapka@wp.pl>

* radek's feedback

* fixing tests

* using wrapper for graffiti

* fixing linting

* wip

* fixing setting proposer settings

* more partial fixes to tests

* gaz

* fixing tests and setting logic

* changing keymanager

* fixing tests and making graffiti optional in the proposer file

* remove unneeded lines

* reverting unintended changes

* Update validator/client/propose.go

Co-authored-by: Manu NALEPA <enalepa@offchainlabs.com>

* addressing feedback

* removing uneeded line

* fixing bad merge resolution

* gofmt

* gaz

---------

Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com>
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
Co-authored-by: Manu NALEPA <enalepa@offchainlabs.com>
2024-03-18 15:03:08 +00:00

61 lines
2.5 KiB
Go

package rpc
import (
"net/http"
"testing"
"github.com/gorilla/mux"
"github.com/prysmaticlabs/prysm/v5/testing/require"
)
func TestServer_InitializeRoutes(t *testing.T) {
s := Server{
router: mux.NewRouter(),
}
err := s.InitializeRoutes()
require.NoError(t, err)
wantRouteList := map[string][]string{
"/eth/v1/keystores": {http.MethodGet, http.MethodPost, http.MethodDelete},
"/eth/v1/remotekeys": {http.MethodGet, http.MethodPost, http.MethodDelete},
"/eth/v1/validator/{pubkey}/gas_limit": {http.MethodGet, http.MethodPost, http.MethodDelete},
"/eth/v1/validator/{pubkey}/feerecipient": {http.MethodGet, http.MethodPost, http.MethodDelete},
"/eth/v1/validator/{pubkey}/voluntary_exit": {http.MethodPost},
"/eth/v1/validator/{pubkey}/graffiti": {http.MethodGet, http.MethodPost, http.MethodDelete},
"/v2/validator/health/version": {http.MethodGet},
"/v2/validator/health/logs/validator/stream": {http.MethodGet},
"/v2/validator/health/logs/beacon/stream": {http.MethodGet},
"/v2/validator/wallet": {http.MethodGet},
"/v2/validator/wallet/create": {http.MethodPost},
"/v2/validator/wallet/keystores/validate": {http.MethodPost},
"/v2/validator/wallet/recover": {http.MethodPost},
"/v2/validator/slashing-protection/export": {http.MethodGet},
"/v2/validator/slashing-protection/import": {http.MethodPost},
"/v2/validator/accounts": {http.MethodGet},
"/v2/validator/accounts/backup": {http.MethodPost},
"/v2/validator/accounts/voluntary-exit": {http.MethodPost},
"/v2/validator/beacon/balances": {http.MethodGet},
"/v2/validator/beacon/peers": {http.MethodGet},
"/v2/validator/beacon/status": {http.MethodGet},
"/v2/validator/beacon/summary": {http.MethodGet},
"/v2/validator/beacon/validators": {http.MethodGet},
"/v2/validator/initialize": {http.MethodGet},
}
gotRouteList := make(map[string][]string)
err = s.router.Walk(func(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error {
tpl, err1 := route.GetPathTemplate()
require.NoError(t, err1)
met, err2 := route.GetMethods()
require.NoError(t, err2)
methods, ok := gotRouteList[tpl]
if !ok {
gotRouteList[tpl] = []string{met[0]}
} else {
gotRouteList[tpl] = append(methods, met[0])
}
return nil
})
require.NoError(t, err)
require.DeepEqual(t, wantRouteList, gotRouteList)
}