reduce entropy on DHT test suite

This commit is contained in:
Victor Shyba 2018-07-27 12:18:14 -03:00 committed by Jack Robison
parent 0601bf3197
commit 31630a84be
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
3 changed files with 4 additions and 2 deletions

View file

@ -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(

View file

@ -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):

View file

@ -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()