@@ -9,13 +9,13 @@ import (
9
9
"testing"
10
10
"time"
11
11
12
- jsoniter "github.com/json-iterator/go"
13
- "github.com/stretchr/testify/assert"
14
12
"github.com/CreatureDev/xrpl-go/client"
15
13
jsonrpcmodels "github.com/CreatureDev/xrpl-go/client/jsonrpc/models"
16
14
"github.com/CreatureDev/xrpl-go/model/client/account"
17
15
"github.com/CreatureDev/xrpl-go/model/client/common"
18
16
"github.com/CreatureDev/xrpl-go/model/client/utility"
17
+ jsoniter "github.com/json-iterator/go"
18
+ "github.com/stretchr/testify/assert"
19
19
)
20
20
21
21
func TestJsonRpcClientCreation (t * testing.T ) {
@@ -78,26 +78,26 @@ func TestCheckForError(t *testing.T) {
78
78
t .Run ("No error Response" , func (t * testing.T ) {
79
79
80
80
json := `{
81
- "result": {
82
- "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
83
- "channels": [
84
- {
85
- "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
86
- "amount": "1000",
87
- "balance": "0",
88
- "channel_id": "C7F634794B79DB40E87179A9D1BF05D05797AE7E92DF8E93FD6656E8C4BE3AE7",
89
- "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
90
- "public_key": "aBR7mdD75Ycs8DRhMgQ4EMUEmBArF8SEh1hfjrT2V9DQTLNbJVqw",
91
- "public_key_hex": "03CFD18E689434F032A4E84C63E2A3A6472D684EAF4FD52CA67742F3E24BAE81B2",
92
- "settle_delay": 60
93
- }
94
- ],
95
- "ledger_hash": "27F530E5C93ED5C13994812787C1ED073C822BAEC7597964608F2C049C2ACD2D",
96
- "ledger_index": 71766343,
97
- "status": "success",
98
- "validated": true
81
+ "result": {
82
+ "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
83
+ "channels": [
84
+ {
85
+ "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
86
+ "amount": "1000",
87
+ "balance": "0",
88
+ "channel_id": "C7F634794B79DB40E87179A9D1BF05D05797AE7E92DF8E93FD6656E8C4BE3AE7",
89
+ "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
90
+ "public_key": "aBR7mdD75Ycs8DRhMgQ4EMUEmBArF8SEh1hfjrT2V9DQTLNbJVqw",
91
+ "public_key_hex": "03CFD18E689434F032A4E84C63E2A3A6472D684EAF4FD52CA67742F3E24BAE81B2",
92
+ "settle_delay": 60
99
93
}
100
- }`
94
+ ],
95
+ "ledger_hash": "27F530E5C93ED5C13994812787C1ED073C822BAEC7597964608F2C049C2ACD2D",
96
+ "ledger_index": 71766343,
97
+ "status": "success",
98
+ "validated": true
99
+ }
100
+ }`
101
101
102
102
b := io .NopCloser (bytes .NewReader ([]byte (json )))
103
103
res := & http.Response {
@@ -210,31 +210,31 @@ func TestSendRequest(t *testing.T) {
210
210
}
211
211
212
212
response := `{
213
- "result": {
214
- "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
215
- "channels": [
216
- {
217
- "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
218
- "amount": "1000",
219
- "balance": "0",
220
- "channel_id": "C7F634794B79DB40E87179A9D1BF05D05797AE7E92DF8E93FD6656E8C4BE3AE7",
221
- "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
222
- "public_key": "aBR7mdD75Ycs8DRhMgQ4EMUEmBArF8SEh1hfjrT2V9DQTLNbJVqw",
223
- "public_key_hex": "03CFD18E689434F032A4E84C63E2A3A6472D684EAF4FD52CA67742F3E24BAE81B2",
224
- "settle_delay": 60
225
- }
226
- ],
227
- "ledger_hash": "1EDBBA3C793863366DF5B31C2174B6B5E6DF6DB89A7212B86838489148E2A581",
228
- "ledger_index": 71766314,
229
- "validated": true
230
- },
231
- "warning": "none",
232
- "warnings":
233
- [{
234
- "id": 1,
235
- "message": "message"
236
- }]
237
- }`
213
+ "result": {
214
+ "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
215
+ "channels": [
216
+ {
217
+ "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
218
+ "amount": "1000",
219
+ "balance": "0",
220
+ "channel_id": "C7F634794B79DB40E87179A9D1BF05D05797AE7E92DF8E93FD6656E8C4BE3AE7",
221
+ "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
222
+ "public_key": "aBR7mdD75Ycs8DRhMgQ4EMUEmBArF8SEh1hfjrT2V9DQTLNbJVqw",
223
+ "public_key_hex": "03CFD18E689434F032A4E84C63E2A3A6472D684EAF4FD52CA67742F3E24BAE81B2",
224
+ "settle_delay": 60
225
+ }
226
+ ],
227
+ "ledger_hash": "1EDBBA3C793863366DF5B31C2174B6B5E6DF6DB89A7212B86838489148E2A581",
228
+ "ledger_index": 71766314,
229
+ "validated": true
230
+ },
231
+ "warning": "none",
232
+ "warnings":
233
+ [{
234
+ "id": 1,
235
+ "message": "message"
236
+ }]
237
+ }`
238
238
239
239
mc := & mockClient {}
240
240
mc .DoFunc = mockResponse (response , 200 , mc )
@@ -247,24 +247,24 @@ func TestSendRequest(t *testing.T) {
247
247
xrplResponse , err := jsonRpcClient .SendRequest (req )
248
248
249
249
expectedXrplResponse := & jsonrpcmodels.JsonRpcResponse {
250
- Result : jsonrpcmodels.AnyJson {
250
+ Result : json .RawMessage (`{
251
+ "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
252
+ "channels": [
253
+ {
251
254
"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
252
- "channels" : []any {
253
- map [string ]any {
254
- "account" : "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn" ,
255
- "amount" : "1000" ,
256
- "balance" : "0" ,
257
- "channel_id" : "C7F634794B79DB40E87179A9D1BF05D05797AE7E92DF8E93FD6656E8C4BE3AE7" ,
258
- "destination_account" : "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX" ,
259
- "public_key" : "aBR7mdD75Ycs8DRhMgQ4EMUEmBArF8SEh1hfjrT2V9DQTLNbJVqw" ,
260
- "public_key_hex" : "03CFD18E689434F032A4E84C63E2A3A6472D684EAF4FD52CA67742F3E24BAE81B2" ,
261
- "settle_delay" : json .Number ("60" ),
262
- },
263
- },
264
- "ledger_hash" : "1EDBBA3C793863366DF5B31C2174B6B5E6DF6DB89A7212B86838489148E2A581" ,
265
- "ledger_index" : json .Number ("71766314" ),
266
- "validated" : true ,
267
- },
255
+ "amount": "1000",
256
+ "balance": "0",
257
+ "channel_id": "C7F634794B79DB40E87179A9D1BF05D05797AE7E92DF8E93FD6656E8C4BE3AE7",
258
+ "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
259
+ "public_key": "aBR7mdD75Ycs8DRhMgQ4EMUEmBArF8SEh1hfjrT2V9DQTLNbJVqw",
260
+ "public_key_hex": "03CFD18E689434F032A4E84C63E2A3A6472D684EAF4FD52CA67742F3E24BAE81B2",
261
+ "settle_delay": 60
262
+ }
263
+ ],
264
+ "ledger_hash": "1EDBBA3C793863366DF5B31C2174B6B5E6DF6DB89A7212B86838489148E2A581",
265
+ "ledger_index": 71766314,
266
+ "validated": true
267
+ }` ),
268
268
Warning : "none" ,
269
269
Warnings : []client.XRPLResponseWarning {{
270
270
Id : 1 ,
@@ -284,6 +284,8 @@ func TestSendRequest(t *testing.T) {
284
284
285
285
assert .NoError (t , err )
286
286
287
+ res := xrplResponse .(* jsonrpcmodels.JsonRpcResponse )
288
+ assert .Equal (t , string (expectedXrplResponse .Result ), string (res .Result ))
287
289
assert .Equal (t , expectedXrplResponse , xrplResponse )
288
290
289
291
assert .Equal (t , expected .Account , channelsResponse .Account )
@@ -297,17 +299,17 @@ func TestSendRequest(t *testing.T) {
297
299
Account : "rLHmBn4fT92w4F6ViyYbjoizLTo83tHTHu" ,
298
300
}
299
301
response := `{
300
- "result": {
301
- "error": "ledgerIndexMalformed",
302
- "request": {
303
- "account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
304
- "command": "account_info",
305
- "ledger_index": "-",
306
- "strict": true
307
- },
308
- "status": "error"
309
- }
310
- }`
302
+ "result": {
303
+ "error": "ledgerIndexMalformed",
304
+ "request": {
305
+ "account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
306
+ "command": "account_info",
307
+ "ledger_index": "-",
308
+ "strict": true
309
+ },
310
+ "status": "error"
311
+ }
312
+ }`
311
313
312
314
mc := & mockClient {}
313
315
mc .DoFunc = mockResponse (response , 200 , mc )
0 commit comments