status-go/protocol/v1/message_test.go

21 lines
489 B
Go

package protocol
import (
"testing"
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
"github.com/stretchr/testify/require"
)
func TestMessageID(t *testing.T) {
key, err := crypto.GenerateKey()
require.NoError(t, err)
keyBytes := crypto.FromECDSAPub(&key.PublicKey)
data := []byte("test")
expectedID := types.HexBytes(crypto.Keccak256(append(keyBytes, data...)))
require.Equal(t, expectedID, MessageID(&key.PublicKey, data))
}