From 3021962e3d4eb185fd023465b74f3e154c1b17b4 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Fri, 29 Jul 2022 21:56:45 -0300 Subject: [PATCH] tests: add peer directly instead of relying on torrent dht --- tests/integration/datanetwork/test_file_commands.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/integration/datanetwork/test_file_commands.py b/tests/integration/datanetwork/test_file_commands.py index 0e1ac141e..f0185d2b8 100644 --- a/tests/integration/datanetwork/test_file_commands.py +++ b/tests/integration/datanetwork/test_file_commands.py @@ -18,11 +18,17 @@ class FileCommands(CommandTestCase): super().__init__(*a, **kw) self.skip_libtorrent = False + async def add_forever(self): + while True: + for handle in self.client_session._handles.values(): + handle._handle.connect_peer(('127.0.0.1', 4040)) + await asyncio.sleep(.1) + async def initialize_torrent(self, tx_to_update=None): if not hasattr(self, 'seeder_session'): self.seeder_session = TorrentSession(self.loop, None) self.addCleanup(self.seeder_session.stop) - await self.seeder_session.bind(port=4040) + await self.seeder_session.bind('127.0.0.1', port=4040) btih = await self.seeder_session.add_fake_torrent() address = await self.account.receiving.get_or_create_usable_address() if not tx_to_update: @@ -40,8 +46,9 @@ class FileCommands(CommandTestCase): await tx.sign([self.account]) await self.broadcast_and_confirm(tx) self.client_session = self.daemon.file_manager.source_managers['torrent'].torrent_session - self.client_session._session.add_dht_node(('localhost', 4040)) self.client_session.wait_start = False # fixme: this is super slow on tests + task = asyncio.create_task(self.add_forever()) + self.addCleanup(task.cancel) return tx, btih @skipIf(TorrentSession is None, "libtorrent not installed")