fmt.Sprint/Sprintf
SCC-S1039 71 beaconChainClient: beaconChainClient,
72 }
73
74 req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/v2/validator/beacon/status"), nil) 75 wr := httptest.NewRecorder()
76 wr.Body = &bytes.Buffer{}
77 srv.GetBeaconStatus(wr, req)
29 srv := &Server{
30 beaconNodeClient: nodeClient,
31 }
32 req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/v2/validator/beacon/status"), nil) 33 wr := httptest.NewRecorder()
34 wr.Body = &bytes.Buffer{}
35 srv.GetBeaconStatus(wr, req)
1936 assert.Equal(t, resp.Data.Graffiti, request.Graffiti)
1937 assert.Equal(t, resp.Data.Pubkey, pubkey)
1938
1939 req = httptest.NewRequest(http.MethodDelete, fmt.Sprintf("/eth/v1/validator/{pubkey}/graffiti"), nil)1940 req = mux.SetURLVars(req, map[string]string{"pubkey": pubkey})
1941 w = httptest.NewRecorder()
1942 w.Body = &bytes.Buffer{}
1925 s.SetGraffiti(w, req)
1926 require.Equal(t, http.StatusOK, w.Code)
1927
1928 req = httptest.NewRequest(http.MethodGet, fmt.Sprintf("/eth/v1/validator/{pubkey}/graffiti"), nil)1929 req = mux.SetURLVars(req, map[string]string{"pubkey": pubkey})
1930 w = httptest.NewRecorder()
1931 w.Body = &bytes.Buffer{}
1918 var buf bytes.Buffer
1919 err = json.NewEncoder(&buf).Encode(request)
1920 require.NoError(t, err)
1921 req := httptest.NewRequest(http.MethodPost, fmt.Sprintf("/eth/v1/validator/{pubkey}/graffiti"), &buf)1922 req = mux.SetURLVars(req, map[string]string{"pubkey": pubkey})
1923 w := httptest.NewRecorder()
1924 w.Body = &bytes.Buffer{}
fmt.Sprint
is not needed when there is only one literal string argument to the
function. Similarly, fmt.Sprintf
is not required when the string to be
formatted does not contain any format specifiers.
x := fmt.Sprint("hello")
y := fmt.Sprintf("Say what")
x := "hello"
y := "Say what"