forked from berty/berty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
group_test.go
36 lines (27 loc) · 880 Bytes
/
group_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package bertyprotocol
import (
crand "crypto/rand"
"testing"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/stretchr/testify/require"
"berty.tech/berty/v2/go/internal/cryptoutil"
"berty.tech/berty/v2/go/pkg/protocoltypes"
)
func TestGetGroupForContact(t *testing.T) {
sk, _, err := crypto.GenerateEd25519Key(crand.Reader)
require.NoError(t, err)
g, err := cryptoutil.GetGroupForContact(sk)
require.NoError(t, err)
require.Equal(t, g.GroupType, protocoltypes.GroupTypeContact)
require.Equal(t, len(g.PublicKey), 32)
require.Equal(t, len(g.Secret), 32)
}
func TestGetKeysForGroupOfContact(t *testing.T) {
sk, _, err := crypto.GenerateEd25519Key(crand.Reader)
require.NoError(t, err)
sk1, sk2, err := cryptoutil.GetKeysForGroupOfContact(sk)
require.NoError(t, err)
require.NotNil(t, sk1)
require.NotNil(t, sk2)
require.False(t, sk1.Equals(sk2))
}