-
Notifications
You must be signed in to change notification settings - Fork 12
/
melt_test.go
47 lines (41 loc) · 933 Bytes
/
melt_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
37
38
39
40
41
42
43
44
45
46
47
package melt
import (
"crypto/ed25519"
"crypto/rand"
"testing"
"github.com/matryer/is"
)
func TestToMnemonic(t *testing.T) {
t.Run("invalid", func(t *testing.T) {
is := is.New(t)
w, err := toMnemonic([]byte{})
is.Equal(w, "")
is.True(err != nil)
})
t.Run("valid", func(t *testing.T) {
is := is.New(t)
_, k, err := ed25519.GenerateKey(rand.Reader)
is.NoErr(err)
w, err := ToMnemonic(&k)
is.NoErr(err)
is.True(w != "")
})
}
func TestFromMnemonic(t *testing.T) {
t.Run("invalid", func(t *testing.T) {
is := is.New(t)
key, err := FromMnemonic("nope nope nope")
is.Equal(key, nil)
is.True(err != nil)
})
t.Run("valid", func(t *testing.T) {
is := is.New(t)
key, err := FromMnemonic(`
alter gap broom kitten orient over settle work honey rule
coach system wage effort mask void solid devote divert
quarter quote broccoli jaguar lady
`)
is.NoErr(err)
is.True(key != nil)
})
}