-
Notifications
You must be signed in to change notification settings - Fork 1
/
cache_test.go
75 lines (73 loc) · 1.94 KB
/
cache_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
package request
import (
"net/url"
"testing"
)
func TestRequest_generateKey(t *testing.T) {
type args struct {
baseURL string
path string
query url.Values
body interface{}
}
tests := []struct {
name string
args args
want string
}{
{
name: "test cosmos key without params",
args: args{
baseURL: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/cosmos",
path: "validators/list.json",
},
want: "ukpgy7t9m_vLHvyQL82smBoTov4=",
},
{
name: "test cosmos key with params",
args: args{
baseURL: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/cosmos",
path: "validators/list.json",
query: url.Values{"address": {"TQZskDJJRGAHifeKoQ7wLey42iGvwp3"}, "visible": {"false"}},
},
want: "jkkaXhzkelj5l3WE_B57Q1IY0Qo=",
},
{name: "test tron key without params ",
args: args{
baseURL: "https://api.trongrid.io",
path: "wallet/getaccount",
},
want: "PIoOx2azFYta4KMAtt0lttrqquM=",
},
{name: "test tron key with params 1",
args: args{
baseURL: "https://api.trongrid.io",
path: "wallet/getaccount",
body: struct {
Address string `json:"address"`
Visible bool `json:"visible"`
}{Address: "TQZskDJJRGAHifeKoQ7wLC4QDyB2iGvwp2", Visible: true},
},
want: "h0noiR5a4M_RGQBH7805sgGl_HE=",
},
{name: "test tron key with params 2",
args: args{
baseURL: "https://api.trongrid.io",
path: "wallet/getaccount",
body: struct {
Address string `json:"address"`
Visible bool `json:"visible"`
}{Address: "TQZskDJJRGAHifeKoQ7wLey42iGvwp3", Visible: false},
},
want: "Admv3wAXHkirPi4SaIXimDgLbow=",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := &Request{BaseURL: tt.args.baseURL}
if got := r.generateKey(tt.args.path, tt.args.query, tt.args.body); got != tt.want {
t.Errorf("generateKey() = %v, want %v", got, tt.want)
}
})
}
}