forked from iotaledger/iota.go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kerl_test.go
69 lines (57 loc) · 1.93 KB
/
kerl_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package giota
import (
"testing"
)
func TestNewKerl(t *testing.T) {
k := NewKerl()
if k == nil {
t.Error("could not initialize kerl instance")
}
}
func TestKerl(t *testing.T) {
k := NewKerl()
if k == nil {
t.Error("could not initialize kerl instance")
}
tr := Trytes("EMIDYNHBWMBCXVDEFOFWINXTERALUKYYPPHKP9JJFGJEIUY9MUDVNFZHMMWZUYUSWAIOWEVTHNWMHANBH")
err := k.Absorb(tr.Trits())
if err != nil {
t.Errorf("Absorb(%q) failed: %s", tr, err)
}
ts, err := k.Squeeze(HashSize)
if err != nil {
t.Errorf("Squeeze() failed: %s", err)
}
h1Out := Trytes("EJEAOOZYSAWFPZQESYDHZCGYNSTWXUMVJOVDWUNZJXDGWCLUFGIMZRMGCAZGKNPLBRLGUNYWKLJTYEAQX")
if ts.Trytes() != h1Out {
t.Errorf("Expected %q but got %q", h1Out, ts.Trytes())
}
k = NewKerl()
tr = Trytes("9MIDYNHBWMBCXVDEFOFWINXTERALUKYYPPHKP9JJFGJEIUY9MUDVNFZHMMWZUYUSWAIOWEVTHNWMHANBH")
err = k.Absorb(tr.Trits())
if err != nil {
t.Errorf("Absorb(%q) failed: %s", tr, err)
}
ts, err = k.Squeeze(HashSize * 2)
if err != nil {
t.Errorf("Squeeze() failed: %s", err)
}
h2Out := Trytes("G9JYBOMPUXHYHKSNRNMMSSZCSHOFYOYNZRSZMAAYWDYEIMVVOGKPJBVBM9TDPULSFUNMTVXRKFIDOHUXXVYDLFSZYZTWQYTE9SPYYWYTXJYQ9IFGYOLZXWZBKWZN9QOOTBQMWMUBLEWUEEASRHRTNIQWJQNDWRYLCA")
if ts.Trytes() != h2Out {
t.Errorf("Expected %q but got %q", h2Out, ts.Trytes())
}
k = NewKerl()
tr = Trytes("G9JYBOMPUXHYHKSNRNMMSSZCSHOFYOYNZRSZMAAYWDYEIMVVOGKPJBVBM9TDPULSFUNMTVXRKFIDOHUXXVYDLFSZYZTWQYTE9SPYYWYTXJYQ9IFGYOLZXWZBKWZN9QOOTBQMWMUBLEWUEEASRHRTNIQWJQNDWRYLCA")
err = k.Absorb(tr.Trits())
if err != nil {
t.Errorf("Absorb(%q) failed: %s", tr, err)
}
ts, err = k.Squeeze(HashSize * 2)
if err != nil {
t.Errorf("Squeeze() failed: %s", err)
}
h3Out := Trytes("LUCKQVACOGBFYSPPVSSOXJEKNSQQRQKPZC9NXFSMQNRQCGGUL9OHVVKBDSKEQEBKXRNUJSRXYVHJTXBPDWQGNSCDCBAIRHAQCOWZEBSNHIJIGPZQITIBJQ9LNTDIBTCQ9EUWKHFLGFUVGGUWJONK9GBCDUIMAYMMQX")
if ts.Trytes() != h3Out {
t.Errorf("Expected %q but got %q", h3Out, ts.Trytes())
}
}