From c7b647b1ebd42e9787de0394fec1e841ed05b511 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Wed, 17 Oct 2018 14:32:45 -0300 Subject: [PATCH] fix test_reconnect --- tests/integration/test_reconnect.py | 8 +++++--- torba/basenetwork.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/integration/test_reconnect.py b/tests/integration/test_reconnect.py index 18b41e868..b7a3b9d81 100644 --- a/tests/integration/test_reconnect.py +++ b/tests/integration/test_reconnect.py @@ -1,3 +1,5 @@ +from asyncio import CancelledError + from orchstr8.testcase import IntegrationTestCase from torba.constants import COIN @@ -8,7 +10,7 @@ class ReconnectTests(IntegrationTestCase): async def test_connection_drop_still_receives_events_after_reconnected(self): address1 = await self.account.receiving.get_or_create_usable_address() - self.ledger.network.client.connectionLost() + self.ledger.network.client.connection_lost(Exception()) sendtxid = await self.blockchain.send_to_address(address1, 1.1337) await self.on_transaction_id(sendtxid) # mempool await self.blockchain.generate(1) @@ -18,8 +20,8 @@ class ReconnectTests(IntegrationTestCase): # is it real? are we rich!? let me see this tx... d = self.ledger.network.get_transaction(sendtxid) # what's that smoke on my ethernet cable? oh no! - self.ledger.network.client.connectionLost() - with self.assertRaisesRegex(TimeoutError, 'Connection dropped'): + self.ledger.network.client.connection_lost(Exception()) + with self.assertRaises(CancelledError): await d # rich but offline? no way, no water, let's retry with self.assertRaisesRegex(ConnectionError, 'connection is not available'): diff --git a/torba/basenetwork.py b/torba/basenetwork.py index 1fdd1a55c..50727ea92 100644 --- a/torba/basenetwork.py +++ b/torba/basenetwork.py @@ -1,8 +1,8 @@ import logging from itertools import cycle +from asyncio import CancelledError from aiorpcx import ClientSession as BaseClientSession -from asyncio import CancelledError from torba import __version__ from torba.stream import StreamController