8
8
from pyethapp .jsonrpc import address_encoder , address_decoder
9
9
10
10
from raiden .api .v1 .encoding import HexAddressConverter
11
- from raiden .tests .utils .apitestcontext import decode_response
12
11
from raiden .utils import channel_to_api_dict
13
12
from raiden .tests .utils .transfer import channel
14
13
from raiden .transfer .state import (
@@ -91,12 +90,12 @@ def test_api_query_channels(
91
90
)
92
91
response = request .send ().response
93
92
assert_proper_response (response )
94
- assert decode_response ( response ) == api_test_context .expect_channels ()
93
+ assert response . json ( ) == api_test_context .expect_channels ()
95
94
96
95
api_test_context .make_channel_and_add ()
97
96
response = request .send ().response
98
97
assert_proper_response (response )
99
- assert decode_response ( response ) == api_test_context .expect_channels ()
98
+ assert response . json ( ) == api_test_context .expect_channels ()
100
99
101
100
102
101
def test_api_open_and_deposit_channel (
@@ -119,7 +118,7 @@ def test_api_open_and_deposit_channel(
119
118
response = request .send ().response
120
119
121
120
assert_proper_response (response )
122
- response = decode_response ( response )
121
+ response = response . json ( )
123
122
expected_response = channel_data_obj
124
123
expected_response ['balance' ] = 0
125
124
expected_response ['state' ] = CHANNEL_STATE_OPENED
@@ -145,7 +144,7 @@ def test_api_open_and_deposit_channel(
145
144
response = request .send ().response
146
145
147
146
assert_proper_response (response )
148
- response = decode_response ( response )
147
+ response = response . json ( )
149
148
expected_response = channel_data_obj
150
149
expected_response ['balance' ] = balance
151
150
expected_response ['state' ] = CHANNEL_STATE_OPENED
@@ -166,7 +165,7 @@ def test_api_open_and_deposit_channel(
166
165
)
167
166
response = request .send ().response
168
167
assert_proper_response (response )
169
- response = decode_response ( response )
168
+ response = response . json ( )
170
169
expected_response = {
171
170
'channel_address' : first_channel_address ,
172
171
'partner_address' : first_partner_address ,
@@ -188,7 +187,7 @@ def test_api_open_and_deposit_channel(
188
187
189
188
response = request .send ().response
190
189
assert_proper_response (response )
191
- response = decode_response ( response )
190
+ response = response . json ( )
192
191
expected_response = {
193
192
'channel_address' : second_channel_address ,
194
193
'partner_address' : second_partner_address ,
@@ -221,7 +220,7 @@ def test_api_open_close_and_settle_channel(
221
220
222
221
balance = 0
223
222
assert_proper_response (response )
224
- response = decode_response ( response )
223
+ response = response . json ( )
225
224
expected_response = channel_data_obj
226
225
expected_response ['balance' ] = balance
227
226
expected_response ['state' ] = CHANNEL_STATE_OPENED
@@ -242,7 +241,6 @@ def test_api_open_close_and_settle_channel(
242
241
)
243
242
response = request .send ().response
244
243
assert_proper_response (response )
245
- response = decode_response (response )
246
244
expected_response = {
247
245
'channel_address' : channel_address ,
248
246
'partner_address' : partner_address ,
@@ -251,7 +249,7 @@ def test_api_open_close_and_settle_channel(
251
249
'state' : CHANNEL_STATE_CLOSED ,
252
250
'balance' : balance
253
251
}
254
- assert response == expected_response
252
+ assert response . json () == expected_response
255
253
256
254
# let's settle the channel
257
255
request = grequests .patch (
@@ -264,7 +262,6 @@ def test_api_open_close_and_settle_channel(
264
262
)
265
263
response = request .send ().response
266
264
assert_proper_response (response )
267
- response = decode_response (response )
268
265
expected_response = {
269
266
'channel_address' : channel_address ,
270
267
'partner_address' : partner_address ,
@@ -273,7 +270,7 @@ def test_api_open_close_and_settle_channel(
273
270
'state' : CHANNEL_STATE_SETTLED ,
274
271
'balance' : balance
275
272
}
276
- assert response == expected_response
273
+ assert response . json () == expected_response
277
274
278
275
279
276
def test_api_channel_state_change_errors (
@@ -295,7 +292,7 @@ def test_api_channel_state_change_errors(
295
292
)
296
293
response = request .send ().response
297
294
assert_proper_response (response )
298
- response = decode_response ( response )
295
+ response = response . json ( )
299
296
channel_address = response ['channel_address' ]
300
297
301
298
# let's try to settle the channel (we are bad!)
@@ -430,7 +427,7 @@ def test_api_tokens(
430
427
)
431
428
response = request .send ().response
432
429
assert_proper_response (response )
433
- response = decode_response ( response )
430
+ response = response . json ( )
434
431
expected_response = [
435
432
{'address' : '0x61c808d82a3ac53231750dadc13c777b59310bd9' },
436
433
{'address' : '0xea674fdde714fd979de3edf0f56aa9716b898ec8' },
@@ -458,7 +455,7 @@ def test_query_partners_by_token(
458
455
)
459
456
response = request .send ().response
460
457
assert_proper_response (response )
461
- response = decode_response ( response )
458
+ response = response . json ( )
462
459
first_channel_address = response ['channel_address' ]
463
460
464
461
channel_data_obj ['partner_address' ] = second_partner_address
@@ -468,7 +465,7 @@ def test_query_partners_by_token(
468
465
)
469
466
response = request .send ().response
470
467
assert_proper_response (response )
471
- response = decode_response ( response )
468
+ response = response . json ( )
472
469
second_channel_address = response ['channel_address' ]
473
470
474
471
# and a channel for another token
@@ -491,7 +488,7 @@ def test_query_partners_by_token(
491
488
)
492
489
response = request .send ().response
493
490
assert_proper_response (response )
494
- response = decode_response ( response )
491
+ response = response . json ( )
495
492
expected_response = [
496
493
{
497
494
'partner_address' : first_partner_address ,
@@ -775,7 +772,7 @@ def test_api_transfers(
775
772
)
776
773
response = request .send ().response
777
774
assert_proper_response (response )
778
- response = decode_response ( response )
775
+ response = response . json ( )
779
776
assert response == transfer
780
777
781
778
@@ -790,9 +787,9 @@ def test_connect_and_leave_token_network(
790
787
)
791
788
response = request .send ().response
792
789
assert_proper_response (response )
793
- channels = decode_response ( response )
794
- assert len ( channels ) == 0
795
- assert decode_response ( response ) == api_test_context .expect_channels ()
790
+ channels = response . json ( )
791
+ assert not channels
792
+ assert response . json ( ) == api_test_context .expect_channels ()
796
793
797
794
funds = 100
798
795
initial_channel_target = DEFAULT_INITIAL_CHANNEL_TARGET
@@ -814,10 +811,10 @@ def test_connect_and_leave_token_network(
814
811
)
815
812
response = request .send ().response
816
813
assert_proper_response (response )
817
- channels = decode_response ( response )
814
+ channels = response . json ( )
818
815
# There should be three channels according to the default initial_channel_target
819
816
assert len (channels ) == DEFAULT_INITIAL_CHANNEL_TARGET
820
- assert decode_response ( response ) == api_test_context .expect_channels ()
817
+ assert response . json ( ) == api_test_context .expect_channels ()
821
818
822
819
expected_balance = int ((funds * joinable_funds_target ) / initial_channel_target )
823
820
assert channels [0 ]['balance' ] == expected_balance
@@ -841,7 +838,7 @@ def test_connect_and_leave_token_network(
841
838
response = request .send ().response
842
839
assert_proper_response (response )
843
840
844
- channels = decode_response ( response )
841
+ channels = response . json ( )
845
842
assert channels [0 ]['state' ] == CHANNEL_STATE_SETTLED
846
843
assert channels [1 ]['state' ] == CHANNEL_STATE_SETTLED
847
844
assert channels [2 ]['state' ] == CHANNEL_STATE_SETTLED
0 commit comments