forked from trustwallet/ens-coincodec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
elrond_test.go
99 lines (93 loc) · 2.7 KB
/
elrond_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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package coincodec
import (
"testing"
"github.com/pkg/errors"
"github.com/wealdtech/go-slip44"
)
func TestElrondEncodeToBytes(t *testing.T) {
tests := []TestcaseEncode{
{
name: "Alice",
input: "erd1l453hd0gt5gzdp7czpuall8ggt2dcv5zwmfdf3sd3lguxseux2fsmsgldz",
output: "fd691bb5e85d102687d81079dffce842d4dc328276d2d4c60d8fd1c3433c3293",
},
{
name: "Bob",
input: "erd1cux02zersde0l7hhklzhywcxk4u9n4py5tdxyx7vrvhnza2r4gmq4vw35r",
output: "c70cf50b238372fffaf7b7c5723b06b57859d424a2da621bcc1b2f317543aa36",
},
{
name: "Carol",
input: "erd19nu5t7hszckwah5nlcadmk5rlchtugzplznskffpwecygcu0520s9tnyy0",
output: "2cf945faf0162ceede93fe3addda83fe2ebe2041f8a70b2521767044638fa29f",
},
{
name: "ensdomains",
input: "erd1qdzvfpa7gqjsnfhdxhvcp2mlysc80uz60yjhxre3lwl00q0jd4nqgauy9q",
output: "0344c487be402509a6ed35d980ab7f243077f05a7925730f31fbbef781f26d66",
},
// invalid
{
name: "Empty",
input: "",
err: errors.New("decoding bech32 failed"),
},
{
name: "Invalid",
input: "foo",
err: errors.New("decoding bech32 failed"),
},
{
name: "Invalid 2",
input: "10z9xdugayn528ksaesdwlhf006fw5sg2qmmm0h52fvxczwgesyvq5pwemr",
err: errors.New("decoding bech32 failed"),
},
{
name: "Invalid 3",
input: "xerd10z9xdugayn528ksaesdwlhf006fw5sg2qmmm0h52fvxczwgesyvq5pwemr",
err: errors.New("decoding bech32 failed"),
},
{
name: "Invalid 4",
input: "foo10z9xdugayn528ksaesdwlhf006fw5sg2qmmm0h52fvxczwgesyvq5pwemr",
err: errors.New("decoding bech32 failed"),
},
{
name: "Invalid Hex",
input: "fd691bb5e85d102687d81079dffce842d4dc328276d2d4c60d8fd1c3433c3293",
err: errors.New("decoding bech32 failed"),
},
}
RunTestsEncode(t, slip44.ELROND, tests)
}
func TestElrondDecodeToString(t *testing.T) {
tests := []TestcaseDecode{
{
name: "Alice",
input: "fd691bb5e85d102687d81079dffce842d4dc328276d2d4c60d8fd1c3433c3293",
output: "erd1l453hd0gt5gzdp7czpuall8ggt2dcv5zwmfdf3sd3lguxseux2fsmsgldz",
},
{
name: "Bob",
input: "c70cf50b238372fffaf7b7c5723b06b57859d424a2da621bcc1b2f317543aa36",
output: "erd1cux02zersde0l7hhklzhywcxk4u9n4py5tdxyx7vrvhnza2r4gmq4vw35r",
},
{
name: "Carol",
input: "2cf945faf0162ceede93fe3addda83fe2ebe2041f8a70b2521767044638fa29f",
output: "erd19nu5t7hszckwah5nlcadmk5rlchtugzplznskffpwecygcu0520s9tnyy0",
},
// invalid
{
name: "Empty",
input: "",
err: errors.New("A Bech32 address key hash must be 20 bytes"),
},
{
name: "Too short",
input: "fd691bb5e85d102687d81079dffce842d4dc328276d2d4c60d8fd1c3433c32",
err: errors.New("A Bech32 address key hash must be 20 bytes"),
},
}
RunTestsDecode(t, slip44.ELROND, tests)
}