github.com/status-im/status-go@v1.1.0/protocol/v1/message_test.go (about)

     1  package protocol
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  
     8  	"github.com/status-im/status-go/eth-node/crypto"
     9  	"github.com/status-im/status-go/eth-node/types"
    10  )
    11  
    12  func TestMessageID(t *testing.T) {
    13  	key, err := crypto.GenerateKey()
    14  	require.NoError(t, err)
    15  
    16  	keyBytes := crypto.FromECDSAPub(&key.PublicKey)
    17  
    18  	data := []byte("test")
    19  	expectedID := types.HexBytes(crypto.Keccak256(append(keyBytes, data...)))
    20  	require.Equal(t, expectedID, MessageID(&key.PublicKey, data))
    21  }