def test_no_verification_sequence_nested_messages( sequence_message_package: Package, message_sequence_value: MessageValue) -> None: sequence_message_one = sequence_message_package.new_message( "Sequence_Element") sequence_message_one.set("Byte", 5) sequence_message_two = sequence_message_package.new_message( "Sequence_Element") sequence_message_two.set("Byte", 6) sequence: List[TypeValue] = [sequence_message_one, sequence_message_two] message_sequence_value.set("Length", 2) message_sequence_value.set("Sequence_Field", sequence) assert message_sequence_value.valid_message pyrflx_ = PyRFLX.from_specs( [SPEC_DIR / "sequence_message.rflx"], skip_model_verification=True, skip_message_verification=True, ) sequence_message_package_unv = pyrflx_.package("Sequence_Message") sequence_message_unv = sequence_message_package_unv.new_message( "Message_Sequence") sequence_element_one_unv = sequence_message_package_unv.new_message( "Sequence_Element") sequence_element_one_unv.set("Byte", 5) sequence_element_two_unv = sequence_message_package_unv.new_message( "Sequence_Element") sequence_element_two_unv.set("Byte", 6) sequence_unv: List[TypeValue] = [ sequence_element_one_unv, sequence_element_two_unv ] sequence_message_unv.set("Length", 2) sequence_message_unv.set("Sequence_Field", sequence_unv) assert sequence_message_unv.valid_message assert sequence_message_unv.bytestring == message_sequence_value.bytestring
def test_sequence_message_serialization( sequence_message_package: Package, message_sequence_value: MessageValue) -> None: sequence_message_one = sequence_message_package.new_message( "Sequence_Element") sequence_message_one.set("Byte", 5) sequence_message_two = sequence_message_package.new_message( "Sequence_Element") sequence_message_two.set("Byte", 6) sequence: List[TypeValue] = [sequence_message_one, sequence_message_two] message_sequence_value.set("Length", 2) message_sequence_value.set("Sequence_Field", sequence) assert message_sequence_value.valid_message assert message_sequence_value.as_json() == { "Length": { "first": 0, "last": 7, "value": 2 }, "Sequence_Field": { "first": 8, "last": 23, "value": [ { "Byte": { "first": 0, "last": 7, "value": 5 } }, { "Byte": { "first": 0, "last": 7, "value": 6 } }, ], }, }
def fixture_icmp_message(icmp_package: pyrflx.Package) -> model.Message: # pylint: disable = protected-access return icmp_package.new_message("Message")._type
def fixture_icmp_message_value(icmp_package: pyrflx.Package) -> pyrflx.MessageValue: return icmp_package.new_message("Message")
def fixture_ethernet_frame_value(ethernet_package: pyrflx.Package) -> pyrflx.MessageValue: return ethernet_package.new_message("Frame")
def fixture_always_valid_aspect_value( always_valid_aspect_package: pyrflx.Package, ) -> pyrflx.MessageValue: return always_valid_aspect_package.new_message("Message")
def fixture_message_type_size_value( message_type_size_package: pyrflx.Package, ) -> pyrflx.MessageValue: return message_type_size_package.new_message("Message")
def fixture_sequence_message_refinement_value( sequence_message_package: pyrflx.Package, ) -> pyrflx.MessageValue: return sequence_message_package.new_message("Message_Sequence_And_Refinement")
def fixture_sequence_message_value(sequence_message_package: pyrflx.Package) -> pyrflx.MessageValue: return sequence_message_package.new_message("Message_Sequence")
def fixture_tlv_message_value(tlv_package: pyrflx.Package) -> pyrflx.MessageValue: return tlv_package.new_message("Message")
def fixture_udp_datagram_value(udp_package: pyrflx.Package) -> pyrflx.MessageValue: return udp_package.new_message("Datagram")
def fixture_tls_alert_value(tls_alert_package: pyrflx.Package) -> pyrflx.MessageValue: return tls_alert_package.new_message("Alert")
def fixture_tls_record_value(tls_record_package: pyrflx.Package) -> pyrflx.MessageValue: return tls_record_package.new_message("TLS_Record")
def fixture_ipv4_option_value(ipv4_package: pyrflx.Package) -> pyrflx.MessageValue: return ipv4_package.new_message("Option")
def fixture_ipv4_packet_value(ipv4_package: pyrflx.Package) -> pyrflx.MessageValue: return ipv4_package.new_message("Packet")
def test_package_name() -> None: p = Package("Test") assert p.name == "Test"