summaryrefslogtreecommitdiffstats
path: root/deluge/tests/test_torrent.py
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2020-04-25 12:44:04 +0100
committerCalum Lind <calumlind+deluge@gmail.com>2020-04-25 13:16:04 +0100
commit62d8749e7404f247494fd091f8a17a1c58735606 (patch)
treee435e68a7355fac7ac96ed3186ea6214d3ca714d /deluge/tests/test_torrent.py
parent76f0bf2e04b1b6b58008fb65fa64c8c434aece95 (diff)
downloaddeluge-62d8749e7404f247494fd091f8a17a1c58735606.tar.gz
deluge-62d8749e7404f247494fd091f8a17a1c58735606.tar.bz2
deluge-62d8749e7404f247494fd091f8a17a1c58735606.zip
[#3348] Fix TypeError adding peers to torrents
Python3 has stricter type checking and passing a port as string results in libtorrent raising a TypeError. Fixed by casting port to int, along with refactoring to ensure ipv6 is correctly parsing and a useful error is output to user with invalid ip or port details. https://dev.deluge-torrent.org/ticket/3348
Diffstat (limited to 'deluge/tests/test_torrent.py')
-rw-r--r--deluge/tests/test_torrent.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/deluge/tests/test_torrent.py b/deluge/tests/test_torrent.py
index 70fec4771..3d47a8ae3 100644
--- a/deluge/tests/test_torrent.py
+++ b/deluge/tests/test_torrent.py
@@ -345,3 +345,11 @@ class TorrentTestCase(BaseTestCase):
result = self.torrent.rename_files([[0, 'new_рбачёв']])
self.assertIsNone(result)
+
+ def test_connect_peer_port(self):
+ """Test to ensure port is int for libtorrent"""
+ atp = self.get_torrent_atp('test_torrent.file.torrent')
+ handle = self.session.add_torrent(atp)
+ self.torrent = Torrent(handle, {})
+ self.assertFalse(self.torrent.connect_peer('127.0.0.1', 'text'))
+ self.assertTrue(self.torrent.connect_peer('127.0.0.1', '1234'))