diff --git a/lbrynet/dht/contact.py b/lbrynet/dht/contact.py index e17c8b28b..eb0f5c417 100644 --- a/lbrynet/dht/contact.py +++ b/lbrynet/dht/contact.py @@ -114,7 +114,7 @@ class _Contact: return True def __hash__(self): - return int(hexlify(self.id), 16) if self.id else -1 + return int(hexlify(self.id), 16) if self.id else int(sum(int(x) for x in self.address.split('.')) + self.port) def compact_ip(self): compact_ip = reduce( diff --git a/lbrynet/dht/node.py b/lbrynet/dht/node.py index f24eeae0c..5decbc782 100644 --- a/lbrynet/dht/node.py +++ b/lbrynet/dht/node.py @@ -167,7 +167,7 @@ class Node(MockKademliaHelper): self.__module__, self.__class__.__name__, binascii.hexlify(self.node_id), self.externalIP, self.port) def __hash__(self): - return self.node_id.__hash__() + return int(binascii.hexlify(self.node_id), 16) @defer.inlineCallbacks def stop(self): diff --git a/tests/functional/dht/dht_test_environment.py b/tests/functional/dht/dht_test_environment.py index 6f18c1c57..4451ae770 100644 --- a/tests/functional/dht/dht_test_environment.py +++ b/tests/functional/dht/dht_test_environment.py @@ -108,6 +108,8 @@ class TestKademliaBase(unittest.TestCase): @defer.inlineCallbacks def setUp(self): + import random + random.seed(0) self.nodes = [] self._seeds = [] self.clock = task.Clock()