Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement roundtrip encoding property test for Messages from random bytes #2448

Closed
Tracked by #3247
jvff opened this issue Jul 6, 2021 · 0 comments
Closed
Tracked by #3247
Labels
A-network Area: Network protocol updates or fixes A-rust Area: Updates to Rust code C-enhancement Category: This is an improvement

Comments

@jvff
Copy link
Contributor

jvff commented Jul 6, 2021

Motivation

It's important to ensure that incoming random bytes from the network do not cause Zebra to misbehave or crash. Having a test that tries to decode a Message from a random byte array is one step in that direction.

The idea would be to write a proptest that:

  1. Given as input a random vector of bytes, with a size that varies between 0..=MAX_PROTOCOL_MESSAGE_LEN;
  2. Creates Codec instance that is used to try to decode a Message from those random bytes;
  3. Based on parts of the input bytes, asserts that the proper Message variant was decoded, or that the appropriate error was returned;
  4. Re-encodes the decoded Message (if available) and checks that the resulting bytes are the same as those in the input

This test could also become some sort of fuzzing test.

Related Work

There is a similar test for serialization of InventoryHash that was implemented in #2446.

@jvff jvff added C-enhancement Category: This is an improvement S-needs-triage Status: A bug report needs triage labels Jul 6, 2021
@teor2345 teor2345 added A-network Area: Network protocol updates or fixes A-rust Area: Updates to Rust code P-Low labels Jul 7, 2021
@jvff jvff closed this as completed Mar 18, 2022
@mpguerra mpguerra removed the S-needs-triage Status: A bug report needs triage label Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-network Area: Network protocol updates or fixes A-rust Area: Updates to Rust code C-enhancement Category: This is an improvement
Projects
None yet
Development

No branches or pull requests

3 participants