2022-06-02 14:35:42 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2022-12-01 08:15:01 +00:00
|
|
|
"context"
|
2022-06-02 14:35:42 +00:00
|
|
|
"testing"
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
2022-06-02 14:35:42 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/gointerfaces"
|
|
|
|
"github.com/ledgerwatch/erigon-lib/gointerfaces/remote"
|
|
|
|
"github.com/stretchr/testify/assert"
|
2022-12-01 08:15:01 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2022-06-02 14:35:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Test case for https://github.com/ethereum/execution-apis/pull/217 responses
|
|
|
|
func TestZeroLatestValidHash(t *testing.T) {
|
2023-01-13 18:12:18 +00:00
|
|
|
payloadStatus := remote.EnginePayloadStatus{Status: remote.EngineStatus_INVALID, LatestValidHash: gointerfaces.ConvertHashToH256(libcommon.Hash{})}
|
2022-12-01 08:15:01 +00:00
|
|
|
json, err := convertPayloadStatus(context.TODO(), nil, &payloadStatus)
|
|
|
|
require.NoError(t, err)
|
2022-06-02 14:35:42 +00:00
|
|
|
assert.Equal(t, "INVALID", json["status"])
|
2023-01-13 18:12:18 +00:00
|
|
|
assert.Equal(t, libcommon.Hash{}, json["latestValidHash"])
|
2022-06-02 14:35:42 +00:00
|
|
|
}
|