-
Notifications
You must be signed in to change notification settings - Fork 0
/
base58_test.go
68 lines (64 loc) · 1.57 KB
/
base58_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
package encoding
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
)
func TestDecodeBase58(t *testing.T) {
type args struct {
in string
}
tests := []struct {
name string
args args
want []byte
wantErr bool
}{
{
"success",
args{
"5CLmNK8f16nagFeF2h3iNeeChaxPiAsJu7piNYJgdPpmaRzPD",
},
[]byte{0x9, 0x86, 0xc6, 0x71, 0x43, 0xad, 0x96, 0x6f, 0xa5, 0x79, 0xc9, 0x1b, 0x30, 0xc6, 0x7f, 0x95, 0xe7, 0x4b, 0xcc, 0xe3, 0xc5, 0xec, 0xb9, 0x5c, 0x96, 0xbf, 0xb5, 0x82, 0x87, 0x65, 0x64, 0xe4, 0x9c, 0x8, 0x3f, 0x1c},
false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := DecodeBase58(tt.args.in)
if (err != nil) != tt.wantErr {
t.Errorf("DecodeBase58() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("DecodeBase58() = %v, want %v", got, tt.want)
}
})
}
}
func TestEncodeBase58(t *testing.T) {
type args struct {
in []byte
}
tests := []struct {
name string
args args
want string
}{
{
"success",
args{
[]byte{0x9, 0x86, 0xc6, 0x71, 0x43, 0xad, 0x96, 0x6f, 0xa5, 0x79, 0xc9, 0x1b, 0x30, 0xc6, 0x7f, 0x95, 0xe7, 0x4b, 0xcc, 0xe3, 0xc5, 0xec, 0xb9, 0x5c, 0x96, 0xbf, 0xb5, 0x82, 0x87, 0x65, 0x64, 0xe4, 0x9c, 0x8, 0x3f, 0x1c},
},
"5CLmNK8f16nagFeF2h3iNeeChaxPiAsJu7piNYJgdPpmaRzPD",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := EncodeBase58(tt.args.in)
if !assert.Equal(t, tt.want, got) {
t.Errorf("EncodeBase58() = %v, want %v", got, tt.want)
}
})
}
}