Esempio n. 1
0
def test_from():
    # Check that ``from_`` and ``from`` can be used interchangeably.
    msg = MultiplexerMessage()
    msg.from_ = 10
    assert getattr(msg, 'from') == 10
    setattr(msg, 'from', 20)
    assert msg.from_ == 20

    # Check that the value assigned via ``from_`` is properly serialized.
    msg = MultiplexerMessage()
    msg.from_ = 15
    assert msg.SerializePartialToString() == '\x10\x0f'

    # Check hat the deserialized ``from`` can be read via ``from_``.
    assert parse_message(MultiplexerMessage, '\x10\x0f', partial=True).from_ == 15
Esempio n. 2
0
def create_connections_manager(multiplexer_password=None):
    welcome = WelcomeMessage()
    welcome.id = 547
    welcome.type = 115
    if multiplexer_password is not None:
        welcome.multiplexer_password = multiplexer_password
    welcome_message = MultiplexerMessage()
    welcome_message.from_ = 547
    welcome_message.message = welcome.SerializeToString()
    welcome_message.type = MessageTypes.CONNECTION_WELCOME
    return ConnectionsManager(welcome_message=welcome_message, multiplexer_password=multiplexer_password)