Skip to content

Manual Packet Manipulation for Coverage Testing #2786

@scully-jmccarthy

Description

@scully-jmccarthy

I am using this library for implementing coverage tests of a Modbus product. While writing the coverage tests for coils illegal data value, I attempted to use the trace_packet handler so I could mangle the bytes to an invalid number outside of the range 1-2000 to validate that my device returns the 0x03, Illegal data value, exception code.

The issue is that the API still checks even when using this lower level handler to inject other data.

    def verifyCount(self, max_count: int, count: int = -1) -> None:
        """Validate API supplied count."""
        if count == -1:
            count = self.count
        if not 1 <= count <= max_count:
>           raise ValueError(f"1 < count {count} < {max_count} !")
E           ValueError: 1 < count 0 < 2000 !

Is there a recommended method to implement this type of testing with the library, or will I have to go deeper and mangle between the pdu and serial layer?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions