diff --git a/bfxapi/tests/test_ws_capacity.py b/bfxapi/tests/test_ws_capacity.py index 48cdbf9..77534a1 100644 --- a/bfxapi/tests/test_ws_capacity.py +++ b/bfxapi/tests/test_ws_capacity.py @@ -12,12 +12,12 @@ async def test_ws_creates_new_socket(): await ws_publish_connection_init(client.ws) # create a bunch of websocket subscriptions for symbol in ['tXRPBTC', 'tLTCUSD']: - await client.ws.subscribe('candles', symbol, timeframe='1m') + client.ws.subscribe('candles', symbol, timeframe='1m') assert len(client.ws.sockets) == 1 assert client.ws.get_total_available_capcity() == 3 # subscribe to a few more to force the lib to create a new ws conenction for symbol in ['tETHBTC', 'tBTCUSD', 'tETHUSD', 'tLTCBTC']: - await client.ws.subscribe('candles', symbol, timeframe='1m') + client.ws.subscribe('candles', symbol, timeframe='1m') assert len(client.ws.sockets) == 2 assert client.ws.get_total_available_capcity() == 4 @@ -29,7 +29,7 @@ async def test_ws_uses_authenticated_socket(): await ws_publish_connection_init(client.ws) # create a bunch of websocket subscriptions for symbol in ['tXRPBTC', 'tLTCUSD', 'tETHBTC', 'tBTCUSD', 'tETHUSD', 'tLTCBTC']: - await client.ws.subscribe('candles', symbol, timeframe='1m') + client.ws.subscribe('candles', symbol, timeframe='1m') # publish connection created message on socket (0 by default) await ws_publish_connection_init(client.ws) # send auth accepted (on socket by default) diff --git a/bfxapi/tests/test_ws_orderbook.py b/bfxapi/tests/test_ws_orderbook.py index ebbee52..7b4d2d7 100644 --- a/bfxapi/tests/test_ws_orderbook.py +++ b/bfxapi/tests/test_ws_orderbook.py @@ -10,12 +10,12 @@ async def test_checksum_generation(): # publish checksum flag accepted await ws_publish_conf_accepted(client.ws, 131072) # subscribe to order book - await client.ws.subscribe('book', symbol) + client.ws.subscribe('book', symbol) ## send subscription accepted chanId = 123 - await client.ws.publish({"event":"subscribed","channel":"book","chanId": chanId,"symbol": symbol,"prec":"P0","freq":"F0","len":"25","pair": symbol}) + client.ws.publish({"event":"subscribed","channel":"book","chanId": chanId,"symbol": symbol,"prec":"P0","freq":"F0","len":"25","pair": symbol}) ## send orderbook snapshot - await client.ws.publish("""[123, [[0.0000886,1,1060.55466114],[0.00008859,1,1000],[0.00008858,1,2713.47159343],[0.00008857,1,4276.92870916],[0.00008856,2,6764.75562319], + client.ws.publish("""[123, [[0.0000886,1,1060.55466114],[0.00008859,1,1000],[0.00008858,1,2713.47159343],[0.00008857,1,4276.92870916],[0.00008856,2,6764.75562319], [0.00008854,1,5641.48532401],[0.00008853,1,2255.92632223],[0.0000885,1,2256.69584601],[0.00008848,2,3630.3],[0.00008845,1,28195.70625766], [0.00008844,1,15571.7],[0.00008843,1,2500],[0.00008841,1,64196.16117814],[0.00008838,1,7500],[0.00008837,2,2764.12999012],[0.00008834,2,10886.476298], [0.00008831,1,20000],[0.0000883,1,1000],[0.00008829,2,2517.22175358],[0.00008828,1,450.45],[0.00008827,1,13000],[0.00008824,1,1500],[0.0000882,1,300], @@ -25,9 +25,9 @@ async def test_checksum_generation(): [0.00008894,1,-775.08564697],[0.00008896,1,-150],[0.00008899,3,-11628.02590049],[0.000089,2,-1299.7],[0.00008902,2,-4841.8],[0.00008904,3,-25320.46250083], [0.00008909,1,-14000],[0.00008913,1,-123947.999],[0.00008915,2,-28019.6]]]""", is_json=False) ## send some more price updates - await client.ws.publish("[{},[0.00008915,0,-1]]".format(chanId), is_json=False) - await client.ws.publish("[{},[0.00008837,1,56.54876269]]".format(chanId), is_json=False) - await client.ws.publish("[{},[0.00008873,1,-15699.9]]".format(chanId), is_json=False) + client.ws.publish("[{},[0.00008915,0,-1]]".format(chanId), is_json=False) + client.ws.publish("[{},[0.00008837,1,56.54876269]]".format(chanId), is_json=False) + client.ws.publish("[{},[0.00008873,1,-15699.9]]".format(chanId), is_json=False) ## check checksum is the same as expected expected_checksum = 30026640 actual_checksum = client.ws.orderBooks[symbol].checksum() @@ -42,12 +42,12 @@ async def test_checksum_really_samll_numbers_generation(): # publish checksum flag accepted await ws_publish_conf_accepted(client.ws, 131072) # subscribe to order book - await client.ws.subscribe('book', symbol) + client.ws.subscribe('book', symbol) ## send subscription accepted chanId = 123 - await client.ws.publish({"event":"subscribed","channel":"book","chanId": chanId,"symbol": symbol,"prec":"P0","freq":"F0","len":"25","pair": symbol}) + client.ws.publish({"event":"subscribed","channel":"book","chanId": chanId,"symbol": symbol,"prec":"P0","freq":"F0","len":"25","pair": symbol}) ## send orderbook snapshot - await client.ws.publish("""[123, [[0.00000121,5,249013.0209708],[0.0000012,6,518315.33310128],[0.00000119,4,566200.89],[0.00000118,2,260000],[0.00000117,1,100000], + client.ws.publish("""[123, [[0.00000121,5,249013.0209708],[0.0000012,6,518315.33310128],[0.00000119,4,566200.89],[0.00000118,2,260000],[0.00000117,1,100000], [0.00000116,2,160000],[0.00000114,1,60000],[0.00000113,2,198500],[0.00000112,1,60000],[0.0000011,1,60000],[0.00000106,2,113868.87735849],[0.00000105,2,105000], [0.00000103,1,3000],[0.00000102,2,105000],[0.00000101,2,202970],[0.000001,2,21000],[7e-7,1,10000],[6.6e-7,1,10000],[6e-7,1,100000],[4.9e-7,1,10000],[2.5e-7,1,2000], [6e-8,1,100000],[5e-8,1,200000],[1e-8,4,640000],[0.00000122,7,-312043.19],[0.00000123,6,-415094.8939744],[0.00000124,5,-348181.23],[0.00000125,1,-12000], @@ -56,9 +56,9 @@ async def test_checksum_really_samll_numbers_generation(): [0.00000164,1,-4000],[0.00000166,1,-3831.46784605],[0.00000171,1,-14575.17730379],[0.00000174,1,-3124.81815395],[0.0000018,1,-18000],[0.00000182,1,-16000], [0.00000186,1,-4000],[0.00000189,1,-10000.686624],[0.00000191,1,-14500]]]""", is_json=False) ## send some more price updates - await client.ws.publish("[{},[0.00000121,4,228442.6609708]]".format(chanId), is_json=False) - await client.ws.publish("[{},[0.00000121,6,304023.8109708]]".format(chanId), is_json=False) - # await client.ws.publish("[{},[0.00008873,1,-15699.9]]".format(chanId), is_json=False) + client.ws.publish("[{},[0.00000121,4,228442.6609708]]".format(chanId), is_json=False) + client.ws.publish("[{},[0.00000121,6,304023.8109708]]".format(chanId), is_json=False) + # client.ws.publish("[{},[0.00008873,1,-15699.9]]".format(chanId), is_json=False) ## check checksum is the same as expected expected_checksum = 1770440002 actual_checksum = client.ws.orderBooks[symbol].checksum() diff --git a/bfxapi/tests/test_ws_orders.py b/bfxapi/tests/test_ws_orders.py index be4a400..60e0b6e 100644 --- a/bfxapi/tests/test_ws_orders.py +++ b/bfxapi/tests/test_ws_orders.py @@ -12,7 +12,7 @@ async def test_submit_order(): ## send auth accepted await ws_publish_auth_accepted(client.ws) ## send new order - await client.ws.submit_order('tBTCUSD', 19000, 0.01, 'EXCHANGE MARKET') + client.ws.submit_order('tBTCUSD', 19000, 0.01, 'EXCHANGE MARKET') last_sent = client.ws.get_last_sent_item() sent_order_array = json.loads(last_sent['data']) assert sent_order_array[1] == "on" @@ -30,7 +30,7 @@ async def test_submit_update_order(): ## send auth accepted await ws_publish_auth_accepted(client.ws) ## send new order - await client.ws.update_order(123, price=100, amount=0.01, hidden=True) + client.ws.update_order(123, price=100, amount=0.01, hidden=True) last_sent = client.ws.get_last_sent_item() sent_order_array = json.loads(last_sent['data']) assert sent_order_array[1] == "ou" @@ -49,7 +49,7 @@ async def test_submit_cancel_order(): ## send auth accepted await ws_publish_auth_accepted(client.ws) ## send new order - await client.ws.cancel_order(123) + client.ws.cancel_order(123) last_sent = client.ws.get_last_sent_item() sent_order_array = json.loads(last_sent['data']) assert sent_order_array[1] == "oc" @@ -66,7 +66,7 @@ async def test_events_on_new_order(): ## look for new order confirmation o_new = EventWatcher.watch(client.ws, 'order_new') - await client.ws.publish([0,"on",[1151718504,None,1548262833910,"tBTCUSD",1548262833379,1548262833410,-1,-1,"EXCHANGE LIMIT",None,None,None,0,"ACTIVE",None,None,15980,0,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) + client.ws.publish([0,"on",[1151718504,None,1548262833910,"tBTCUSD",1548262833379,1548262833410,-1,-1,"EXCHANGE LIMIT",None,None,None,0,"ACTIVE",None,None,15980,0,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) new_res = o_new.wait_until_complete() assert new_res.amount_orig == -1 assert new_res.amount_filled == 0 @@ -75,7 +75,7 @@ async def test_events_on_new_order(): ## look for order update confirmation o_update = EventWatcher.watch(client.ws, 'order_update') - await client.ws.publish([0,"ou",[1151718504,None,1548262833910,"tBTCUSD",1548262833379,1548262846964,-0.5,-1,"EXCHANGE LIMIT",None,None,None,0,"PARTIALLY FILLED @ 15980.0(-0.5)",None,None,15980,15980,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) + client.ws.publish([0,"ou",[1151718504,None,1548262833910,"tBTCUSD",1548262833379,1548262846964,-0.5,-1,"EXCHANGE LIMIT",None,None,None,0,"PARTIALLY FILLED @ 15980.0(-0.5)",None,None,15980,15980,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) update_res = o_update.wait_until_complete() assert update_res.amount_orig == -1 assert float(update_res.amount_filled) == -0.5 @@ -84,7 +84,7 @@ async def test_events_on_new_order(): ## look for closed notification o_closed = EventWatcher.watch(client.ws, 'order_closed') - await client.ws.publish([0,"oc",[1151718504,None,1548262833910,"tBTCUSD",1548262833379,1548262888016,0,-1,"EXCHANGE LIMIT",None,None,None,0,"EXECUTED @ 15980.0(-0.5): was PARTIALLY FILLED @ 15980.0(-0.5)",None,None,15980,15980,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) + client.ws.publish([0,"oc",[1151718504,None,1548262833910,"tBTCUSD",1548262833379,1548262888016,0,-1,"EXCHANGE LIMIT",None,None,None,0,"EXECUTED @ 15980.0(-0.5): was PARTIALLY FILLED @ 15980.0(-0.5)",None,None,15980,15980,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) closed_res = o_closed.wait_until_complete() assert new_res.amount_orig == -1 assert new_res.amount_filled == 0 @@ -100,11 +100,11 @@ async def test_events_on_cancel_order(): await ws_publish_auth_accepted(client.ws) ## Create new order - await client.ws.publish([0,"on",[1151718565,None,1548325124885,"tBTCUSD",1548325123435,1548325123460,1,1,"EXCHANGE LIMIT",None,None,None,0,"ACTIVE",None,None,10,0,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) + client.ws.publish([0,"on",[1151718565,None,1548325124885,"tBTCUSD",1548325123435,1548325123460,1,1,"EXCHANGE LIMIT",None,None,None,0,"ACTIVE",None,None,10,0,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) ## look for order closed confirmation o_close = EventWatcher.watch(client.ws, 'order_closed') - await client.ws.publish([0,"oc",[1151718565,None,1548325124885,"tBTCUSD",1548325123435,1548325123548,1,1,"EXCHANGE LIMIT",None,None,None,0,"CANCELED",None,None,10,0,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) + client.ws.publish([0,"oc",[1151718565,None,1548325124885,"tBTCUSD",1548325123435,1548325123548,1,1,"EXCHANGE LIMIT",None,None,None,0,"CANCELED",None,None,10,0,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) close_res = o_close.wait_until_complete() assert close_res.amount_orig == 1 assert float(close_res.amount_filled) == 0 @@ -119,12 +119,12 @@ async def test_closed_callback_on_submit_order_closed(): ## send auth accepted await ws_publish_auth_accepted(client.ws) async def c(order): - await client.ws._emit('c1', order) + client.ws._emit('c1', order) callback_wait = EventWatcher.watch(client.ws, 'c1') # override cid generation client.ws.orderManager._gen_unique_cid = lambda: 123 - await client.ws.submit_order('tBTCUSD', 19000, 0.01, 'EXCHANGE MARKET', onClose=c) - await client.ws.publish([0,"oc",[123,None,1548262833910,"tBTCUSD",1548262833379,1548262888016,0,-1,"EXCHANGE LIMIT",None,None,None,0,"EXECUTED @ 15980.0(-0.5): was PARTIALLY FILLED @ 15980.0(-0.5)",None,None,15980,15980,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) + client.ws.submit_order('tBTCUSD', 19000, 0.01, 'EXCHANGE MARKET', onClose=c) + client.ws.publish([0,"oc",[123,None,1548262833910,"tBTCUSD",1548262833379,1548262888016,0,-1,"EXCHANGE LIMIT",None,None,None,0,"EXECUTED @ 15980.0(-0.5): was PARTIALLY FILLED @ 15980.0(-0.5)",None,None,15980,15980,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) callback_wait.wait_until_complete() @@ -136,12 +136,12 @@ async def test_confirmed_callback_on_submit_order_closed(): ## send auth accepted await ws_publish_auth_accepted(client.ws) async def c(order): - await client.ws._emit('c1', order) + client.ws._emit('c1', order) callback_wait = EventWatcher.watch(client.ws, 'c1') # override cid generation client.ws.orderManager._gen_unique_cid = lambda: 123 - await client.ws.submit_order('tBTCUSD', 19000, 0.01, 'EXCHANGE MARKET', onConfirm=c) - await client.ws.publish([0,"oc",[123,None,1548262833910,"tBTCUSD",1548262833379,1548262888016,0,-1,"EXCHANGE LIMIT",None,None,None,0,"EXECUTED @ 15980.0(-0.5): was PARTIALLY FILLED @ 15980.0(-0.5)",None,None,15980,15980,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) + client.ws.submit_order('tBTCUSD', 19000, 0.01, 'EXCHANGE MARKET', onConfirm=c) + client.ws.publish([0,"oc",[123,None,1548262833910,"tBTCUSD",1548262833379,1548262888016,0,-1,"EXCHANGE LIMIT",None,None,None,0,"EXECUTED @ 15980.0(-0.5): was PARTIALLY FILLED @ 15980.0(-0.5)",None,None,15980,15980,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) callback_wait.wait_until_complete() @pytest.mark.asyncio @@ -152,12 +152,12 @@ async def test_confirmed_callback_on_submit_new_order(): ## send auth accepted await ws_publish_auth_accepted(client.ws) async def c(order): - await client.ws._emit('c1', order) + client.ws._emit('c1', order) callback_wait = EventWatcher.watch(client.ws, 'c1') # override cid generation client.ws.orderManager._gen_unique_cid = lambda: 123 - await client.ws.submit_order('tBTCUSD', 19000, 0.01, 'EXCHANGE MARKET', onConfirm=c) - await client.ws.publish([0,"on",[123,None,1548262833910,"tBTCUSD",1548262833379,1548262833410,-1,-1,"EXCHANGE LIMIT",None,None,None,0,"ACTIVE",None,None,15980,0,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) + client.ws.submit_order('tBTCUSD', 19000, 0.01, 'EXCHANGE MARKET', onConfirm=c) + client.ws.publish([0,"on",[123,None,1548262833910,"tBTCUSD",1548262833379,1548262833410,-1,-1,"EXCHANGE LIMIT",None,None,None,0,"ACTIVE",None,None,15980,0,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) callback_wait.wait_until_complete() @pytest.mark.asyncio @@ -168,12 +168,12 @@ async def test_confirmed_callback_on_submit_order_update(): ## send auth accepted await ws_publish_auth_accepted(client.ws) async def c(order): - await client.ws._emit('c1', order) + client.ws._emit('c1', order) callback_wait = EventWatcher.watch(client.ws, 'c1') # override cid generation client.ws.orderManager._gen_unique_cid = lambda: 123 - await client.ws.update_order(123, price=100, onConfirm=c) - await client.ws.publish([0,"ou",[123,None,1548262833910,"tBTCUSD",1548262833379,1548262846964,-0.5,-1,"EXCHANGE LIMIT",None,None,None,0,"PARTIALLY FILLED @ 15980.0(-0.5)",None,None,15980,15980,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) + client.ws.update_order(123, price=100, onConfirm=c) + client.ws.publish([0,"ou",[123,None,1548262833910,"tBTCUSD",1548262833379,1548262846964,-0.5,-1,"EXCHANGE LIMIT",None,None,None,0,"PARTIALLY FILLED @ 15980.0(-0.5)",None,None,15980,15980,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) callback_wait.wait_until_complete() @pytest.mark.asyncio @@ -184,12 +184,12 @@ async def test_confirmed_callback_on_submit_cancel_order(): ## send auth accepted await ws_publish_auth_accepted(client.ws) async def c(order): - await client.ws._emit('c1', order) + client.ws._emit('c1', order) callback_wait = EventWatcher.watch(client.ws, 'c1') # override cid generation client.ws.orderManager._gen_unique_cid = lambda: 123 - await client.ws.cancel_order(123, onConfirm=c) - await client.ws.publish([0,"oc",[123,None,1548262833910,"tBTCUSD",1548262833379,1548262888016,0,-1,"EXCHANGE LIMIT",None,None,None,0,"EXECUTED @ 15980.0(-0.5): was PARTIALLY FILLED @ 15980.0(-0.5)",None,None,15980,15980,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) + client.ws.cancel_order(123, onConfirm=c) + client.ws.publish([0,"oc",[123,None,1548262833910,"tBTCUSD",1548262833379,1548262888016,0,-1,"EXCHANGE LIMIT",None,None,None,0,"EXECUTED @ 15980.0(-0.5): was PARTIALLY FILLED @ 15980.0(-0.5)",None,None,15980,15980,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) callback_wait.wait_until_complete() @pytest.mark.asyncio @@ -200,10 +200,10 @@ async def test_confirmed_callback_on_submit_cancel_group_order(): ## send auth accepted await ws_publish_auth_accepted(client.ws) async def c(order): - await client.ws._emit('c1', order) + client.ws._emit('c1', order) callback_wait = EventWatcher.watch(client.ws, 'c1') # override cid generation client.ws.orderManager._gen_unique_cid = lambda: 123 - await client.ws.cancel_order_group(123, onConfirm=c) - await client.ws.publish([0,"oc",[1548262833910,123,1548262833910,"tBTCUSD",1548262833379,1548262888016,0,-1,"EXCHANGE LIMIT",None,None,None,0,"EXECUTED @ 15980.0(-0.5): was PARTIALLY FILLED @ 15980.0(-0.5)",None,None,15980,15980,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) + client.ws.cancel_order_group(123, onConfirm=c) + client.ws.publish([0,"oc",[1548262833910,123,1548262833910,"tBTCUSD",1548262833379,1548262888016,0,-1,"EXCHANGE LIMIT",None,None,None,0,"EXECUTED @ 15980.0(-0.5): was PARTIALLY FILLED @ 15980.0(-0.5)",None,None,15980,15980,0,0,None,None,None,0,0,None,None,None,"API>BFX",None,None,None]]) callback_wait.wait_until_complete() diff --git a/bfxapi/tests/test_ws_subscriptions.py b/bfxapi/tests/test_ws_subscriptions.py index 7e1866a..06d69b9 100644 --- a/bfxapi/tests/test_ws_subscriptions.py +++ b/bfxapi/tests/test_ws_subscriptions.py @@ -10,7 +10,7 @@ async def test_submit_subscribe(): await ws_publish_connection_init(client.ws) # Create new subscription to orderbook - await client.ws.subscribe('book', symb) + client.ws.subscribe('book', symb) last_sent = client.ws.get_last_sent_item() sent_sub = json.loads(last_sent['data']) # {'time': 1548327054030, 'data': '{"event": "subscribe", "channel": "book", "symbol": "tXRPBTC"}'} @@ -19,7 +19,7 @@ async def test_submit_subscribe(): assert sent_sub['symbol'] == symb # create new subscription to trades - await client.ws.subscribe('trades', symb) + client.ws.subscribe('trades', symb) last_sent = client.ws.get_last_sent_item() sent_sub = json.loads(last_sent['data']) # {'event': 'subscribe', 'channel': 'trades', 'symbol': 'tBTCUSD'} @@ -28,7 +28,7 @@ async def test_submit_subscribe(): assert sent_sub['symbol'] == symb # create new subscription to candles - await client.ws.subscribe('candles', symb, timeframe='1m') + client.ws.subscribe('candles', symb, timeframe='1m') last_sent = client.ws.get_last_sent_item() sent_sub = json.loads(last_sent['data']) #{'event': 'subscribe', 'channel': 'candles', 'symbol': 'tBTCUSD', 'key': 'trade:1m:tBTCUSD'} @@ -44,10 +44,10 @@ async def test_event_subscribe(): # publish connection created message await ws_publish_connection_init(client.ws) # create a new subscription - await client.ws.subscribe('trades', symb) + client.ws.subscribe('trades', symb) # announce subscription was successful sub_watch = EventWatcher.watch(client.ws, 'subscribed') - await client.ws.publish({"event":"subscribed","channel":"trades","chanId":2,"symbol":symb,"pair":pair}) + client.ws.publish({"event":"subscribed","channel":"trades","chanId":2,"symbol":symb,"pair":pair}) s_res = sub_watch.wait_until_complete() assert s_res.channel_name == 'trades' assert s_res.symbol == symb @@ -62,10 +62,10 @@ async def test_submit_unsubscribe(): # publish connection created message await ws_publish_connection_init(client.ws) # create new subscription to trades - await client.ws.subscribe('trades', symb) + client.ws.subscribe('trades', symb) # announce subscription was successful sub_watch = EventWatcher.watch(client.ws, 'subscribed') - await client.ws.publish({"event":"subscribed","channel":"trades","chanId":2,"symbol":symb,"pair":pair}) + client.ws.publish({"event":"subscribed","channel":"trades","chanId":2,"symbol":symb,"pair":pair}) s_res = sub_watch.wait_until_complete() # unsubscribe from channel await s_res.unsubscribe() @@ -83,10 +83,10 @@ async def test_event_unsubscribe(): # publish connection created message await ws_publish_connection_init(client.ws) # create new subscription to trades - await client.ws.subscribe('trades', symb) + client.ws.subscribe('trades', symb) # announce subscription was successful sub_watch = EventWatcher.watch(client.ws, 'subscribed') - await client.ws.publish({"event":"subscribed","channel":"trades","chanId":2,"symbol":symb,"pair":pair}) + client.ws.publish({"event":"subscribed","channel":"trades","chanId":2,"symbol":symb,"pair":pair}) s_res = sub_watch.wait_until_complete() # unsubscribe from channel await s_res.unsubscribe() @@ -95,7 +95,7 @@ async def test_event_unsubscribe(): # publish confirmation of unsubscribe unsub_watch = EventWatcher.watch(client.ws, 'unsubscribed') - await client.ws.publish({"event":"unsubscribed","status":"OK","chanId":2}) + client.ws.publish({"event":"unsubscribed","status":"OK","chanId":2}) unsub_res = unsub_watch.wait_until_complete() assert s_res.channel_name == 'trades' assert s_res.symbol == symb @@ -110,13 +110,13 @@ async def test_submit_resubscribe(): # publish connection created message await ws_publish_connection_init(client.ws) # request two new subscriptions - await client.ws.subscribe('book', symb) - await client.ws.subscribe('trades', symb) + client.ws.subscribe('book', symb) + client.ws.subscribe('trades', symb) # confirm subscriptions - await client.ws.publish({"event":"subscribed","channel":"trades","chanId":2,"symbol":symb,"pair":pair}) - await client.ws.publish({"event":"subscribed","channel":"book","chanId":3,"symbol":symb,"prec":"P0","freq":"F0","len":"25","pair":pair}) + client.ws.publish({"event":"subscribed","channel":"trades","chanId":2,"symbol":symb,"pair":pair}) + client.ws.publish({"event":"subscribed","channel":"book","chanId":3,"symbol":symb,"prec":"P0","freq":"F0","len":"25","pair":pair}) # call resubscribe all - await client.ws.resubscribe_all() + client.ws.resubscribe_all() ## assert that 2 unsubscribe requests were sent last_sent = client.ws.get_sent_items()[-2:] for i in last_sent: @@ -124,12 +124,12 @@ async def test_submit_resubscribe(): assert data['event'] == 'unsubscribe' assert (data['chanId'] == 2 or data['chanId'] == 3) ## confirm unsubscriptions - await client.ws.publish({"event":"unsubscribed","status":"OK","chanId":2}) - await client.ws.publish({"event":"unsubscribed","status":"OK","chanId":3}) + client.ws.publish({"event":"unsubscribed","status":"OK","chanId":2}) + client.ws.publish({"event":"unsubscribed","status":"OK","chanId":3}) ## confirm subscriptions - # await client.ws.publish({"event":"subscribed","channel":"trades","chanId":2,"symbol":symb,"pair":pair}) - # await client.ws.publish({"event":"subscribed","channel":"book","chanId":3,"symbol":symb,"prec":"P0","freq":"F0","len":"25","pair":pair}) + # client.ws.publish({"event":"subscribed","channel":"trades","chanId":2,"symbol":symb,"pair":pair}) + # client.ws.publish({"event":"subscribed","channel":"book","chanId":3,"symbol":symb,"prec":"P0","freq":"F0","len":"25","pair":pair}) # wait for emit of event n_last_sent = client.ws.get_sent_items()[-2:] for i in n_last_sent: