#NEWLINE# def setUp( self ) : #NEWLINE# #INDENT# self . public_ip = '123.45.67.89' #NEWLINE# self . port = 12345 #NEWLINE# self . own_addr = ( self . public_ip , self . port ) #NEWLINE# self . addr1 = ( '132.54.76.98' , 54321 ) #NEWLINE# self . addr2 = ( '231.76.45.89' , 15243 ) #NEWLINE# self . addr3 = ( '193.193.111.00' , 99999 ) #NEWLINE# self . clock = task . Clock ( ) #NEWLINE# connection . REACTOR . callLater = self . clock . callLater #NEWLINE# self . proto_mock = mock . Mock ( spec_set = rudp . ConnectionMultiplexer ) #NEWLINE# self . handler_mock = mock . Mock ( spec_set = connection . Handler ) #NEWLINE# self . con = connection . Connection ( self . proto_mock , self . handler_mock , self . own_addr , self . addr1 ) #NEWLINE# valid_key = '63d901c4d57cde34fc1f1e28b9af5d56ed342cae5c2fb470046d0130a4226b0c' #NEWLINE# self . signing_key = nacl . signing . SigningKey ( valid_key , encoder = nacl . encoding . HexEncoder ) #NEWLINE# verify_key = self . signing_key . verify_key #NEWLINE# h = nacl . hash . sha512 ( verify_key . encode ( ) ) #NEWLINE# self . storage = ForgetfulStorage ( ) #NEWLINE# self . node = Node ( unhexlify ( h [ : 40 ] ) , self . public_ip , self . port , verify_key . encode ( ) , None , FULL_CONE , True ) #NEWLINE# self . db = Database ( filepath = 'test.db' ) #NEWLINE# self . protocol = KademliaProtocol ( self . node , self . storage , 20 , self . db , self . signing_key ) #NEWLINE# self . wire_protocol = OpenBazaarProtocol ( self . db , self . own_addr , FULL_CONE ) #NEWLINE# self . wire_protocol . register_processor ( self . protocol ) #NEWLINE# self . protocol . connect_multiplexer ( self . wire_protocol ) #NEWLINE# self . handler = self . wire_protocol . ConnHandler ( [ self . protocol ] , self . wire_protocol , None , self . wire_protocol . ban_score ) #NEWLINE# transport = mock . Mock ( spec_set = udp . Port ) #NEWLINE# ret_val = address . IPv4Address ( 'UDP' , ret_val . public_ip , self . port ) #NEWLINE# transport . attach_mock ( mock . Mock ( return_value = ret_val ) , 'getHost' ) #NEWLINE# self . wire_protocol . makeConnection ( transport ) #NEWLINE# self . node1 = Node ( digest ( 'id1' ) , self . addr1 [ 0 ] , self . addr1 [ 1 ] , digest ( 'key1' ) , None , FULL_CONE , True ) #NEWLINE# self . node2 = Node ( digest ( 'id2' ) , self . addr2 [ 0 ] , self . addr2 [ 1 ] , digest ( 'key2' ) , None , FULL_CONE , True ) #NEWLINE# self . node3 = Node ( digest ( 'id3' ) , self . addr3 [ 0 ] , self . addr3 [ 1 ] , digest ( 'key3' ) , None , FULL_CONE , True )