-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_test.go
206 lines (174 loc) · 5.39 KB
/
client_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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
package alego
import (
"github.com/AdamSLevy/jsonrpc2/v14"
"github.com/stretchr/testify/assert"
"testing"
)
func TestGetNodeInfo(t *testing.T) {
var client = client()
data, err := client.GetNodeInfo()
if err != nil {
client.logger.Errorf("Error on TestGetNodeInfo: %v", err.Error())
}
if _, ok := err.(jsonrpc2.Error); ok {
client.logger.Errorf("Error on TestGetNodeInfo: %v", err.Error())
}
assert.False(t, data.IsMiner)
}
func TestGetNodeStats(t *testing.T) {
var client = client()
_, err := client.GetNodeStats()
if err != nil {
client.logger.Errorf("Error on TestGetNodeStats: %v", err.Error())
}
if _, ok := err.(jsonrpc2.Error); ok {
client.logger.Errorf("Error on TestGetNodeStats: %v", err.Error())
}
assert.Empty(t, err)
}
func TestGetNodePeers(t *testing.T) {
var client = client()
_, err := client.GetNodeStats()
if err != nil {
client.logger.Errorf("Error on TestGetNodePeers: %v", err.Error())
}
if _, ok := err.(jsonrpc2.Error); ok {
client.logger.Errorf("Error on TestGetNodePeers: %v", err.Error())
}
assert.Empty(t, err)
}
func TestGetBlock(t *testing.T) {
var client = client()
_, err := client.GetBlock("de24fc1ddb8f55a46277aee00e5e13e283337a006491ca9c01c22a5d764ea8f8")
if err != nil {
client.logger.Errorf("Error on TestGetBlock: %v", err.Error())
}
if _, ok := err.(jsonrpc2.Error); ok {
client.logger.Errorf("Error on TestGetBlock: %v", err.Error())
}
assert.Error(t, err)
}
func TestDecodeRawTransaction(t *testing.T) {
var client = client()
_, err := client.DecodeRawTransaction("de24fc1ddb8f55a46277aee00e5e13e283337a006491ca9c01c22a5d764ea8f8")
if err != nil {
client.logger.Errorf("Error on DecodeRawTransaction: %v", err.Error())
}
if _, ok := err.(jsonrpc2.Error); ok {
client.logger.Errorf("Error on DecodeRawTransaction: %v", err.Error())
}
assert.Error(t, err)
}
func TestGetRawTransaction(t *testing.T) {
var client = client()
_, err := client.GetRawTransaction("de24fc1ddb8f55a46277aee00e5e13e283337a006491ca9c01c22a5d764ea8f8")
if err != nil {
client.logger.Errorf("Error on GetRawTransaction: %v", err.Error())
}
if _, ok := err.(jsonrpc2.Error); ok {
client.logger.Errorf("Error on GetRawTransaction: %v", err.Error())
}
assert.Error(t, err)
}
func TestGetTransactionInfo(t *testing.T) {
var client = client()
_, err := client.GetTransactionInfo("de24fc1ddb8f55a46277aee00e5e13e283337a006491ca9c01c22a5d764ea8f8")
if err != nil {
client.logger.Errorf("Error on GetTransactionInfo: %v", err.Error())
}
if _, ok := err.(jsonrpc2.Error); ok {
client.logger.Errorf("Error on GetTransactionInfo: %v", err.Error())
}
assert.Error(t, err)
}
func TestSendTransaction(t *testing.T) {
var client = client()
_, err := client.SendTransaction("de24fc1ddb8f55a46277aee00e5e13e283337a006491ca9c01c22a5d764ea8f8")
if err != nil {
client.logger.Errorf("Error on SendTransaction: %v", err.Error())
}
if _, ok := err.(jsonrpc2.Error); ok {
client.logger.Errorf("Error on SendTransaction: %v", err.Error())
}
assert.Error(t, err)
}
func TestValidateRawTransaction(t *testing.T) {
var client = client()
_, err := client.ValidateRawTransaction("de24fc1ddb8f55a46277aee00e5e13e283337a006491ca9c01c22a5d764ea8f8")
if err != nil {
client.logger.Errorf("Error on ValidateRawTransaction: %v", err.Error())
}
if _, ok := err.(jsonrpc2.Error); ok {
client.logger.Errorf("Error on ValidateRawTransaction: %v", err.Error())
}
assert.Error(t, err)
}
func TestGetBlockTemplate(t *testing.T) {
var client = client()
_, err := client.GetBlockTemplate()
if err != nil {
client.logger.Errorf("Error on GetBlockTemplate: %v", err.Error())
}
if _, ok := err.(jsonrpc2.Error); ok {
client.logger.Errorf("Error on GetBlockTemplate: %v", err.Error())
}
assert.NoError(t, err)
}
func TestGetBlockHash(t *testing.T) {
var client = client()
_, err := client.GetBlockHash("10000")
if err != nil {
client.logger.Errorf("Error on GetBlockHash: %v", err.Error())
}
if _, ok := err.(jsonrpc2.Error); ok {
client.logger.Errorf("Error on GetBlockHash: %v", err.Error())
}
assert.Error(t, err)
}
func TestGetBlockCount(t *testing.T) {
var client = client()
_, err := client.GetBlockCount()
if err != nil {
client.logger.Errorf("Error on GetBlockCount: %v", err.Error())
}
if _, ok := err.(jsonrpc2.Error); ok {
client.logger.Errorf("Error on GetBlockCount: %v", err.Error())
}
assert.Error(t, err)
}
func TestGetBestBlockHash(t *testing.T) {
var client = client()
_, err := client.GetBestBlockHash()
if err != nil {
client.logger.Errorf("Error on GetBestBlockHash: %v", err.Error())
}
if _, ok := err.(jsonrpc2.Error); ok {
client.logger.Errorf("Error on GetBestBlockHash: %v", err.Error())
}
assert.Error(t, err)
}
func TestGetNetworkGraph(t *testing.T) {
var client = client()
_, err := client.GetNetworkGraph()
if err != nil {
client.logger.Errorf("Error on GetNetworkGraph: %v", err.Error())
}
if _, ok := err.(jsonrpc2.Error); ok {
client.logger.Errorf("Error on GetNetworkGraph: %v", err.Error())
}
assert.Error(t, err)
}
func TestGetConnectionCount(t *testing.T) {
var client = client()
_, err := client.GetConnectionCount()
if err != nil {
client.logger.Errorf("Error on GetConnectionCount: %v", err.Error())
}
if _, ok := err.(jsonrpc2.Error); ok {
client.logger.Errorf("Error on GetConnectionCount: %v", err.Error())
}
assert.Error(t, err)
}
func client() *Client {
return NewClient("alex", "842655", "52.8.172.237:443")
}