Пример #1
0
            def it_extracts_those_bytes_in_little_endian_order():
                data = b'\x18\x01\x02\x03\x04\x05\x06\x07\x08Q025\x34\x12...'
                parser = Parser(data)

                header = parser.parse_public_header()

                assert_that(header.packet_number, is_(0x1234))
Пример #2
0
        def it_advances_data_offset_to_point_to_byte_after_public_header():
            data = b'\x08\x01\x02\x03\x04\x05\x06\x07\x08Q025\x12...'
            parser = Parser(data)

            parser.parse_public_header()

            assert_that(parser.data_offset, is_(14))
Пример #3
0
            def it_extracts_this_one_byte_as_packet_number():
                data = b'\x08\x01\x02\x03\x04\x05\x06\x07\x08Q025\x12...'
                parser = Parser(data)

                header = parser.parse_public_header()

                assert_that(header.packet_number, is_(0x12))
Пример #4
0
        def it_extracts_protocol_version():
            data = b'\x08\x01\x02\x03\x04\x05\x06\x07\x08Q025...'
            parser = Parser(data)

            header = parser.parse_public_header()

            assert_that(header.protocol_version, is_(b'Q025'))
Пример #5
0
        def it_extracts_connection_id():
            data = b'\x08\x01\x02\x03\x04\x05\x06\x07\x08......'
            parser = Parser(data)

            header = parser.parse_public_header()

            assert_that(header.connection_id, is_(b'\x01\x02\x03\x04\x05\x06\x07\x08'))
Пример #6
0
        def it_extracts_public_flags():
            data = b'\x08\x01\x02\x03\x04\x05\x06\x07\x08......'
            parser = Parser(data)

            header = parser.parse_public_header()

            assert_that(header.public_flags, is_(0x08))
Пример #7
0
            def it_raises_an_exception():
                parser = Parser(b'')

                assert_that(
                    calling(parser.calc_packet_hash),
                    raises(IndexError)
                )
Пример #8
0
 def parser():
     data = b'\x08\x01\x02\x03\x04\x05\x06\x07\x08Q025' \
         b'\x01\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01' \
         b'\xa5\x02\x01..\x14\x05...'
     parser = Parser(data)
     parser.parse_public_header()
     parser.parse_packet_hash()
     return parser
Пример #9
0
        def describe_when_packet_hash_was_parsed():
            parser = Parser(fixture_packet('chlo_q034'))
            parser.parse_public_header()
            parser.parse_packet_hash()

            def it_calculates_12_byte_hash_value():
                packet_hash = parser.calc_packet_hash()

                assert_that(packet_hash, is_(0xda4e6a9c4b3af51927e22fdc))