def send_hello(self): """ Send first hello message, that should begin the communication """ self.send(message.MessageHello( client_key_id=self.task_server.get_key_id(), rand_val=self.rand_val, proto_id=TASK_PROTOCOL_ID), send_unverified=True)
def send_hello(self): """ Send first hello message, that should begin the communication """ self.send( message.MessageHello( client_key_id=self.resource_server.get_key_id(), rand_val=self.rand_val ), send_unverified=True )
def __send_hello(self): self.solve_challenge = self.key_id\ and self.p2p_service.should_solve_challenge\ or False challenge_kwargs = {} if self.solve_challenge: challenge = self.p2p_service._get_challenge(self.key_id) self.challenge = challenge_kwargs['challenge'] = challenge difficulty = self.p2p_service._get_difficulty(self.key_id) self.difficulty = challenge_kwargs['difficulty'] = difficulty msg = message.MessageHello( proto_id=P2P_PROTOCOL_ID, port=self.p2p_service.cur_port, node_name=self.p2p_service.node_name, client_key_id=self.p2p_service.keys_auth.get_key_id(), node_info=self.p2p_service.node, rand_val=self.rand_val, metadata=self.p2p_service.metadata_manager.get_metadata(), solve_challenge=self.solve_challenge, **challenge_kwargs) self.send(msg, send_unverified=True)
def test_timestamp_and_timezones(self): epoch_t = 1475238345.0 def set_tz(tz): os.environ['TZ'] = tz try: time.tzset() except AttributeError: raise unittest.SkipTest("tzset required") set_tz('Europe/Warsaw') warsaw_time = time.localtime(epoch_t) m = message.MessageHello(timestamp=epoch_t) db = DataBuffer() m.serialize_to_buffer(db) set_tz('US/Eastern') server = mock.Mock() server.decrypt = lambda x: x msgs = message.Message.decrypt_and_deserialize(db, server) assert len(msgs) == 1 newyork_time = time.localtime(msgs[0].timestamp) assert warsaw_time != newyork_time assert time.gmtime(epoch_t) == time.gmtime(msgs[0].timestamp)
def serialize_messages(_b): for m in [message.MessageHello() for _ in xrange(0, n_messages)]: m.serialize_to_buffer(_b)