def compare_current_to_old(
        self,
        converted_old_message: AbstractMessage,
        original_old_message: AbstractMessage,
    ):
        """
        This method is run on every message comparison, when comparing
        the current version converted to the older version.

        Override this if a change is made that affects every message.
        """
        self.assertEqual(
            constants.STARTING_SEQUENCE_BYTES,
            converted_old_message.rawbytes()
            [:constants.STARTING_SEQUENCE_BYTES_LEN],
        )
        self.assertEqual(
            # pyre-fixme[16]: `AbstractMessage` has no attribute `msg_type`.
            original_old_message.msg_type(),
            converted_old_message.msg_type(),
        )
        self.assertEqual(
            # pyre-fixme[16]: `AbstractMessage` has no attribute `payload_len`.
            original_old_message.payload_len(),
            converted_old_message.payload_len(),
        )
        self.assertEqual(
            # pyre-fixme[16]: `AbstractMessage` has no attribute `get_control_flags`.
            original_old_message.get_control_flags(),
            converted_old_message.get_control_flags(),
        )
    def enqueue_msg(self, msg: AbstractMessage, prepend: bool = False):
        """
        Enqueues the contents of a Message instance, msg, to our outputbuf and attempts to send it if the underlying
        socket has room in the send buffer.

        :param msg: message
        :param prepend: if the message should be bumped to the front of the outputbuf
        """
        self._log_message(msg.log_level(), "Enqueued message: {}", msg)
        self.enqueue_msg_bytes(msg.rawbytes(), prepend)
    def enqueue_msg(self, msg: AbstractMessage, prepend: bool = False):
        if not self.is_alive():
            return

        self.outputbuf.enqueue_msgbytes(msg.rawbytes())
        self.enqueued_messages.append(msg)
 def gateway_2_receive_message_from_gateway(self, message: AbstractMessage):
     helpers.receive_node_message(self.gateway_2, self.gateway_fileno_2,
                                  message.rawbytes())
 def gateway_1_receive_message_from_blockchain(self,
                                               message: AbstractMessage):
     helpers.receive_node_message(self.gateway_1, self.blockchain_fileno_1,
                                  message.rawbytes())