good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 45cf6ee9 authored by Andrew Ashikhmin's avatar Andrew Ashikhmin Committed by GitHub
Browse files

Fix LatestValidHash nil pointer (#4338)

parent f2be5a74
No related branches found
No related tags found
No related merge requests found
package commands
import (
"testing"
"github.com/ledgerwatch/erigon-lib/gointerfaces"
"github.com/ledgerwatch/erigon-lib/gointerfaces/remote"
"github.com/ledgerwatch/erigon/common"
"github.com/stretchr/testify/assert"
)
// Test case for https://github.com/ethereum/execution-apis/pull/217 responses
func TestZeroLatestValidHash(t *testing.T) {
payloadStatus := remote.EnginePayloadStatus{Status: remote.EngineStatus_INVALID, LatestValidHash: gointerfaces.ConvertHashToH256(common.Hash{})}
json := convertPayloadStatus(&payloadStatus)
assert.Equal(t, "INVALID", json["status"])
assert.Equal(t, common.Hash{}, json["latestValidHash"])
}
......@@ -336,7 +336,7 @@ func (s *EthBackendServer) EngineNewPayloadV1(ctx context.Context, req *types2.E
}
if parentTd != nil && parentTd.Cmp(s.config.TerminalTotalDifficulty) < 0 {
log.Warn("[NewPayload] TTD not reached yet", "height", header.Number, "hash", common.Hash(blockHash))
return &remote.EnginePayloadStatus{Status: remote.EngineStatus_INVALID, LatestValidHash: &types2.H256{}}, nil
return &remote.EnginePayloadStatus{Status: remote.EngineStatus_INVALID, LatestValidHash: gointerfaces.ConvertHashToH256(common.Hash{})}, nil
}
tx.Rollback()
......@@ -456,7 +456,7 @@ func (s *EthBackendServer) EngineForkChoiceUpdatedV1(ctx context.Context, req *r
if td != nil && td.Cmp(s.config.TerminalTotalDifficulty) < 0 {
log.Warn("[ForkChoiceUpdated] TTD not reached yet", "forkChoice", forkChoice)
return &remote.EngineForkChoiceUpdatedReply{
PayloadStatus: &remote.EnginePayloadStatus{Status: remote.EngineStatus_INVALID, LatestValidHash: &types2.H256{}},
PayloadStatus: &remote.EnginePayloadStatus{Status: remote.EngineStatus_INVALID, LatestValidHash: gointerfaces.ConvertHashToH256(common.Hash{})},
}, nil
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment