|
6 | 6 | from pathlib import Path
|
7 | 7 | from unittest.mock import AsyncMock, MagicMock, Mock, call, patch
|
8 | 8 |
|
| 9 | +import libtorrent |
9 | 10 | from configobj import ConfigObj
|
10 | 11 | from configobj.validate import Validator, VdtParamError
|
11 | 12 | from ipv8.test.base import TestBase
|
@@ -186,6 +187,28 @@ async def test_start_handle_wait_for_dht(self) -> None:
|
186 | 187 |
|
187 | 188 | self.assertTrue(task.done())
|
188 | 189 |
|
| 190 | + async def test_start_handle_empty_save_path(self) -> None: |
| 191 | + """ |
| 192 | + Test if the "save_path" is always set in the resume_data, otherwise we SEGFAULT on win32! |
| 193 | + """ |
| 194 | + download = Download(TorrentDef.load_from_memory(TORRENT_WITH_DIRS_CONTENT), None, |
| 195 | + checkpoint_disabled=True, config=self.create_mock_download_config()) |
| 196 | + download.handle = Mock(is_valid=Mock(return_value=True)) |
| 197 | + self.manager.get_session = AsyncMock(return_value=Mock(get_torrents=Mock(return_value=[]))) |
| 198 | + self.manager._async_add_torrent = AsyncMock() # noqa: SLF001 |
| 199 | + |
| 200 | + await self.manager.start_handle(download, { |
| 201 | + "save_path": "/test_path/", |
| 202 | + "resume_data": libtorrent.bencode({b"file-format": b"libtorrent resume file", b"file-version": 1}) |
| 203 | + }) # Schedule async_add_torrent |
| 204 | + await sleep(0) # Run async_add_torrent |
| 205 | + |
| 206 | + session, infohash, atp = self.manager._async_add_torrent.call_args[0] # noqa: SLF001 |
| 207 | + |
| 208 | + self.assertIn("resume_data", atp) |
| 209 | + self.assertIn(b"save_path", libtorrent.bdecode(atp["resume_data"])) |
| 210 | + self.assertEqual(b"/test_path/", libtorrent.bdecode(atp["resume_data"])[b"save_path"]) |
| 211 | + |
189 | 212 | async def test_start_download_existing_handle(self) -> None:
|
190 | 213 | """
|
191 | 214 | Test if torrents can be added when there is a pre-existing handle.
|
|
0 commit comments