status-go/protocol/v1/message_test.go

22 lines
490 B
Go
Raw Permalink Normal View History

package protocol
import (
"testing"
2020-01-02 09:10:19 +00:00
"github.com/stretchr/testify/require"
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
)
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))
}