-
Notifications
You must be signed in to change notification settings - Fork 13
/
ontology_test.go
112 lines (106 loc) · 2.64 KB
/
ontology_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
100
101
102
103
104
105
106
107
108
109
110
111
112
package coincodec
import (
"testing"
"github.com/pkg/errors"
"github.com/wealdtech/go-slip44"
)
func TestOntologyEncodeToBytes(t *testing.T) {
tests := []TestcaseEncode{
{
name: "Normal",
input: "ANDfjwrUroaVtvBguDtrWKRMyxFwvVwnZD",
output: "1746b1a18af6b7c9f8a4602f9f73eeb3030f0c29b7",
},
{
name: "Normal2",
input: "AeicEjZyiXKgUeSBbYQHxsU1X3V5Buori5",
output: "17fbacc8214765d457c8e3f2b5a1d3c4981a2e9d2a",
},
{
name: "Normal3",
input: "AYTxeseHT5khTWhtWX1pFFP1mbQrd4q1zz",
output: "17b716d488862fedd488a4616cfc0068bb6a6c849f",
},
{
name: "Invalid Base58",
input: "ANDfjwrUroaVtvBg+DtrWKRMyxFwvVwnZD",
err: errors.New("Bad Base58 string"),
},
{
name: "Too short",
input: "ANDfjwrUroaVtvBguDtrWKRMyxFwvVwn",
err: errors.New("Bad Base58 checksum"),
},
{
name: "Invalid Base58",
input: "0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed",
err: errors.New("Bad Base58 string"),
},
{
name: "Too short",
input: "ANDfjwrUroaVtvBguDtrWKRMy",
err: errors.New("Bad Base58 checksum"),
},
{
name: "Correct length, but bad checksum",
input: "ANDfjwrUroaVtvBguDtrWKRMyxFwvVwnZE",
err: errors.New("Bad Base58 checksum"),
},
{
name: "Valid version, too short",
input: "ANDfjwrUroaVtvBguDtrWKRMyxFwvV",
err: errors.New("Bad Base58 checksum"),
},
{
name: "Valid base 58 and checksum, but version is bad",
input: "GyscQcQtoyAiYSwGuELv1FjbqfXwwQPQ8Z",
err: errors.New("Invalid prefix"),
},
{
name: "Bad checksum",
input: "AATxeseHT5khTWhtWX1pFFP1mbQrd4q1zz",
err: errors.New("Bad Base58 checksum"),
},
}
RunTestsEncode(t, slip44.ONTOLOGY, tests)
}
func TestOntologyDecodeToString(t *testing.T) {
tests := []TestcaseDecode{
{
name: "Empty",
input: "",
err: errors.New("Invalid decoded length"),
},
{
name: "Empty",
input: "06a1a1a7f2ff4762",
err: errors.New("Invalid decoded length"),
},
{
name: "Good",
input: "1746b1a18af6b7c9f8a4602f9f73eeb3030f0c29b7",
output: "ANDfjwrUroaVtvBguDtrWKRMyxFwvVwnZD",
},
{
name: "Good2",
input: "17fbacc8214765d457c8e3f2b5a1d3c4981a2e9d2a",
output: "AeicEjZyiXKgUeSBbYQHxsU1X3V5Buori5",
},
{
name: "Good3",
input: "17b716d488862fedd488a4616cfc0068bb6a6c849f",
output: "AYTxeseHT5khTWhtWX1pFFP1mbQrd4q1zz",
},
{
name: "Invalid Prefix",
input: "415cd0fb0ab3ce40f3051414c604b27756e69e43db",
err: errors.New("Invalid prefix"),
},
{
name: "Invalid Prefix2",
input: "4151b5659b685047f35498f763dce619c4720d2aa7",
err: errors.New("Invalid prefix"),
},
}
RunTestsDecode(t, slip44.ONTOLOGY, tests)
}