mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-05 09:14:28 +00:00
27b4e32e1c
* WIP * fixing tests * fixing bazel * fixing api client * fixing tests * fixing more tests and bazel * fixing trace and more bazel issues * fixing router path function definitions * fixing more tests and deep source issues * adding delete test * if a route is provided, reregister before the catch all on the middleware. * fixing linting * fixing deepsource complaint * gaz * more deepsource issues * fixing missed err check * changing how routes are registered * radek reviews * Update validator/rpc/handlers_keymanager.go Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com> * Update validator/rpc/handlers_keymanager.go Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com> * fixing unit test after sammy's review * adding radek's comments --------- Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com>
45 lines
1.4 KiB
Go
45 lines
1.4 KiB
Go
package rpc
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/gorilla/mux"
|
|
pb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1/validator-client"
|
|
"github.com/prysmaticlabs/prysm/v4/testing/require"
|
|
)
|
|
|
|
var _ pb.AuthServer = (*Server)(nil)
|
|
|
|
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},
|
|
}
|
|
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)
|
|
}
|