fix test_reconnect

This commit is contained in:
Victor Shyba 2018-10-17 14:32:45 -03:00 committed by Lex Berezhny
parent 63563c412c
commit c7b647b1eb
2 changed files with 6 additions and 4 deletions

View file

@ -1,3 +1,5 @@
from asyncio import CancelledError
from orchstr8.testcase import IntegrationTestCase from orchstr8.testcase import IntegrationTestCase
from torba.constants import COIN from torba.constants import COIN
@ -8,7 +10,7 @@ class ReconnectTests(IntegrationTestCase):
async def test_connection_drop_still_receives_events_after_reconnected(self): async def test_connection_drop_still_receives_events_after_reconnected(self):
address1 = await self.account.receiving.get_or_create_usable_address() 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) sendtxid = await self.blockchain.send_to_address(address1, 1.1337)
await self.on_transaction_id(sendtxid) # mempool await self.on_transaction_id(sendtxid) # mempool
await self.blockchain.generate(1) await self.blockchain.generate(1)
@ -18,8 +20,8 @@ class ReconnectTests(IntegrationTestCase):
# is it real? are we rich!? let me see this tx... # is it real? are we rich!? let me see this tx...
d = self.ledger.network.get_transaction(sendtxid) d = self.ledger.network.get_transaction(sendtxid)
# what's that smoke on my ethernet cable? oh no! # what's that smoke on my ethernet cable? oh no!
self.ledger.network.client.connectionLost() self.ledger.network.client.connection_lost(Exception())
with self.assertRaisesRegex(TimeoutError, 'Connection dropped'): with self.assertRaises(CancelledError):
await d await d
# rich but offline? no way, no water, let's retry # rich but offline? no way, no water, let's retry
with self.assertRaisesRegex(ConnectionError, 'connection is not available'): with self.assertRaisesRegex(ConnectionError, 'connection is not available'):

View file

@ -1,8 +1,8 @@
import logging import logging
from itertools import cycle from itertools import cycle
from asyncio import CancelledError
from aiorpcx import ClientSession as BaseClientSession from aiorpcx import ClientSession as BaseClientSession
from asyncio import CancelledError
from torba import __version__ from torba import __version__
from torba.stream import StreamController from torba.stream import StreamController