mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 11:57:18 +00:00
Return correct root from GetBlockHeader
(#12935)
* Return correct root from `GetBlockHeader` * variable rename
This commit is contained in:
parent
b7cb5c81be
commit
b40729f6c0
@ -861,12 +861,12 @@ func (s *Server) GetBlockHeader(w http.ResponseWriter, r *http.Request) {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
header, err := blk.Header()
|
||||
blockHeader, err := blk.Header()
|
||||
if err != nil {
|
||||
http2.HandleError(w, "Could not get block header: %s"+err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
headerRoot, err := header.HashTreeRoot()
|
||||
headerRoot, err := blockHeader.Header.HashTreeRoot()
|
||||
if err != nil {
|
||||
http2.HandleError(w, "Could not hash block header: %s"+err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
@ -892,8 +892,8 @@ func (s *Server) GetBlockHeader(w http.ResponseWriter, r *http.Request) {
|
||||
Root: hexutil.Encode(headerRoot[:]),
|
||||
Canonical: canonical,
|
||||
Header: &shared.SignedBeaconBlockHeader{
|
||||
Message: shared.BeaconBlockHeaderFromConsensus(header.Header),
|
||||
Signature: hexutil.Encode(header.Signature),
|
||||
Message: shared.BeaconBlockHeaderFromConsensus(blockHeader.Header),
|
||||
Signature: hexutil.Encode(blockHeader.Signature),
|
||||
},
|
||||
},
|
||||
ExecutionOptimistic: isOptimistic,
|
||||
|
@ -1376,7 +1376,7 @@ func TestServer_GetBlockHeader(t *testing.T) {
|
||||
resp := &GetBlockHeaderResponse{}
|
||||
require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp))
|
||||
assert.Equal(t, true, resp.Data.Canonical)
|
||||
assert.Equal(t, "0x725b389a0e5a7623fa7600b9e5cb6248d5c293fc2f5877e42a665b44f40c85f6", resp.Data.Root)
|
||||
assert.Equal(t, "0xd7d92f6206707f2c9c4e7e82320617d5abac2b6461a65ea5bb1a154b5b5ea2fa", resp.Data.Root)
|
||||
assert.Equal(t, "0x736967000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", resp.Data.Header.Signature)
|
||||
assert.Equal(t, "123", resp.Data.Header.Message.Slot)
|
||||
assert.Equal(t, "0x706172656e74726f6f7400000000000000000000000000000000000000000000", resp.Data.Header.Message.ParentRoot)
|
||||
|
Loading…
Reference in New Issue
Block a user