2019-11-21 16:19:22 +00:00
|
|
|
package protocol
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-01-02 09:10:19 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2019-11-23 17:57:05 +00:00
|
|
|
"github.com/status-im/status-go/eth-node/crypto"
|
|
|
|
"github.com/status-im/status-go/eth-node/types"
|
2019-11-21 16:19:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMessageID(t *testing.T) {
|
|
|
|
key, err := crypto.GenerateKey()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
keyBytes := crypto.FromECDSAPub(&key.PublicKey)
|
|
|
|
|
|
|
|
data := []byte("test")
|
2019-11-23 17:57:05 +00:00
|
|
|
expectedID := types.HexBytes(crypto.Keccak256(append(keyBytes, data...)))
|
2019-11-21 16:19:22 +00:00
|
|
|
require.Equal(t, expectedID, MessageID(&key.PublicKey, data))
|
|
|
|
}
|