mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-21 19:20:38 +00:00
adding headers to post endpoint (#13753)
This commit is contained in:
parent
58b8c31c93
commit
2de21eb22f
@ -304,6 +304,8 @@ func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlyS
|
|||||||
}
|
}
|
||||||
versionOpt := func(r *http.Request) {
|
versionOpt := func(r *http.Request) {
|
||||||
r.Header.Add("Eth-Consensus-Version", version.String(version.Bellatrix))
|
r.Header.Add("Eth-Consensus-Version", version.String(version.Bellatrix))
|
||||||
|
r.Header.Set("Content-Type", "application/json")
|
||||||
|
r.Header.Set("Accept", "application/json")
|
||||||
}
|
}
|
||||||
rb, err := c.do(ctx, http.MethodPost, postBlindedBeaconBlockPath, bytes.NewBuffer(body), versionOpt)
|
rb, err := c.do(ctx, http.MethodPost, postBlindedBeaconBlockPath, bytes.NewBuffer(body), versionOpt)
|
||||||
|
|
||||||
@ -341,6 +343,8 @@ func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlyS
|
|||||||
}
|
}
|
||||||
versionOpt := func(r *http.Request) {
|
versionOpt := func(r *http.Request) {
|
||||||
r.Header.Add("Eth-Consensus-Version", version.String(version.Capella))
|
r.Header.Add("Eth-Consensus-Version", version.String(version.Capella))
|
||||||
|
r.Header.Set("Content-Type", "application/json")
|
||||||
|
r.Header.Set("Accept", "application/json")
|
||||||
}
|
}
|
||||||
rb, err := c.do(ctx, http.MethodPost, postBlindedBeaconBlockPath, bytes.NewBuffer(body), versionOpt)
|
rb, err := c.do(ctx, http.MethodPost, postBlindedBeaconBlockPath, bytes.NewBuffer(body), versionOpt)
|
||||||
|
|
||||||
@ -379,6 +383,8 @@ func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlyS
|
|||||||
|
|
||||||
versionOpt := func(r *http.Request) {
|
versionOpt := func(r *http.Request) {
|
||||||
r.Header.Add("Eth-Consensus-Version", version.String(version.Deneb))
|
r.Header.Add("Eth-Consensus-Version", version.String(version.Deneb))
|
||||||
|
r.Header.Set("Content-Type", "application/json")
|
||||||
|
r.Header.Set("Accept", "application/json")
|
||||||
}
|
}
|
||||||
rb, err := c.do(ctx, http.MethodPost, postBlindedBeaconBlockPath, bytes.NewBuffer(body), versionOpt)
|
rb, err := c.do(ctx, http.MethodPost, postBlindedBeaconBlockPath, bytes.NewBuffer(body), versionOpt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -321,6 +321,8 @@ func TestSubmitBlindedBlock(t *testing.T) {
|
|||||||
Transport: roundtrip(func(r *http.Request) (*http.Response, error) {
|
Transport: roundtrip(func(r *http.Request) (*http.Response, error) {
|
||||||
require.Equal(t, postBlindedBeaconBlockPath, r.URL.Path)
|
require.Equal(t, postBlindedBeaconBlockPath, r.URL.Path)
|
||||||
require.Equal(t, "bellatrix", r.Header.Get("Eth-Consensus-Version"))
|
require.Equal(t, "bellatrix", r.Header.Get("Eth-Consensus-Version"))
|
||||||
|
require.Equal(t, "application/json", r.Header.Get("Content-Type"))
|
||||||
|
require.Equal(t, "application/json", r.Header.Get("Accept"))
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: http.StatusOK,
|
StatusCode: http.StatusOK,
|
||||||
Body: io.NopCloser(bytes.NewBufferString(testExampleExecutionPayload)),
|
Body: io.NopCloser(bytes.NewBufferString(testExampleExecutionPayload)),
|
||||||
@ -347,6 +349,8 @@ func TestSubmitBlindedBlock(t *testing.T) {
|
|||||||
Transport: roundtrip(func(r *http.Request) (*http.Response, error) {
|
Transport: roundtrip(func(r *http.Request) (*http.Response, error) {
|
||||||
require.Equal(t, postBlindedBeaconBlockPath, r.URL.Path)
|
require.Equal(t, postBlindedBeaconBlockPath, r.URL.Path)
|
||||||
require.Equal(t, "capella", r.Header.Get("Eth-Consensus-Version"))
|
require.Equal(t, "capella", r.Header.Get("Eth-Consensus-Version"))
|
||||||
|
require.Equal(t, "application/json", r.Header.Get("Content-Type"))
|
||||||
|
require.Equal(t, "application/json", r.Header.Get("Accept"))
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: http.StatusOK,
|
StatusCode: http.StatusOK,
|
||||||
Body: io.NopCloser(bytes.NewBufferString(testExampleExecutionPayloadCapella)),
|
Body: io.NopCloser(bytes.NewBufferString(testExampleExecutionPayloadCapella)),
|
||||||
@ -376,6 +380,8 @@ func TestSubmitBlindedBlock(t *testing.T) {
|
|||||||
Transport: roundtrip(func(r *http.Request) (*http.Response, error) {
|
Transport: roundtrip(func(r *http.Request) (*http.Response, error) {
|
||||||
require.Equal(t, postBlindedBeaconBlockPath, r.URL.Path)
|
require.Equal(t, postBlindedBeaconBlockPath, r.URL.Path)
|
||||||
require.Equal(t, "deneb", r.Header.Get("Eth-Consensus-Version"))
|
require.Equal(t, "deneb", r.Header.Get("Eth-Consensus-Version"))
|
||||||
|
require.Equal(t, "application/json", r.Header.Get("Content-Type"))
|
||||||
|
require.Equal(t, "application/json", r.Header.Get("Accept"))
|
||||||
var req structs.SignedBlindedBeaconBlockDeneb
|
var req structs.SignedBlindedBeaconBlockDeneb
|
||||||
err := json.NewDecoder(r.Body).Decode(&req)
|
err := json.NewDecoder(r.Body).Decode(&req)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user