Skip to content

Commit

Permalink
fix RespondMsg
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris committed Jun 19, 2023
1 parent dd2ff32 commit 89fd66e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion services/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ func (api *RelayAPI) RespondOK(w http.ResponseWriter, response any) {
}

func (api *RelayAPI) RespondMsg(w http.ResponseWriter, code int, msg string) {
api.Respond(w, code, struct{ message string }{message: msg})
api.Respond(w, code, MessageResp{msg})
}

func (api *RelayAPI) Respond(w http.ResponseWriter, code int, response any) {
Expand Down
8 changes: 8 additions & 0 deletions services/api/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@ func TestStatus(t *testing.T) {
require.Equal(t, http.StatusOK, rr.Code)
}

func TestLivez(t *testing.T) {
backend := newTestBackend(t, 1)
path := "/livez"
rr := backend.request(http.MethodGet, path, nil)
require.Equal(t, http.StatusOK, rr.Code)
require.Equal(t, "{\"message\":\"ok\"}\n", rr.Body.String())
}

func TestRegisterValidator(t *testing.T) {
path := "/eth/v1/builder/validators"

Expand Down
9 changes: 6 additions & 3 deletions services/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ var (
ErrMissingSecretKey = errors.New("secret key is nil")
ErrEmptyPayload = errors.New("nil payload")
ErrInvalidTransaction = errors.New("invalid transaction")

NilResponse = struct{}{}
ZeroU256 = boostTypes.IntToU256(0)
)

type HTTPErrorResp struct {
Code int `json:"code"`
Message string `json:"message"`
}

var NilResponse = struct{}{}

var ZeroU256 = boostTypes.IntToU256(0)
type MessageResp struct {
Message string `json:"message"`
}

0 comments on commit 89fd66e

Please sign in to comment.