-
Notifications
You must be signed in to change notification settings - Fork 55
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
test(gossipsub): block5 protobuf test cases #1204
Open
AYAHASSAN287
wants to merge
6
commits into
master
Choose a base branch
from
block5Tests-protobuf
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7477059
adding block5 protobuf 1-4 test cases
AYAHASSAN287 4f96d1b
Test cases of block5[1,2,7]
AYAHASSAN287 f545a87
adding test cases [1-4 ,7] for block 5
AYAHASSAN287 96459cc
fixing florin's comments
AYAHASSAN287 1d5baca
fixing review comments
AYAHASSAN287 422c4da
fixing review comments & linters
AYAHASSAN287 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are these tests for? they're effectively testing that nim object initialization works, and nothing beyond that since they don't exercise any actual logic such as encoding to and from protobuf. As such, they add maintenance and code volume without providing any value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if I add the checks of objects parameters to an already existing test case to reduce code volume would it be acceptable ?
the reason of these checks is to verify that message objects are defined with respect to protobuf schema
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to test schema conformance, you need to create encoded byte streams and decode these messages into the nim types that we use. You can create such messages using https://www.tutorialspoint.com/protobuf/protobuf_command_line_usage.htm as long as it's possible to regenerate the tests in a reasonable way - ie the aim of such a test is to ensure that encoding and decoding of the nim types results in the expected protobuf bytes (and that the test remain maintainable, ie if someone comes across the code in 5 months and wants to add a test, this is reasonably simple)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One way to structure such tests can be seen in https://github.com/status-im/nim-eth/blob/master/tests/common/test_common.nim - this tests RLP (a different encoding) but premise is the same - there, you can see how example content is loaded and cross-verified against a "decoded" version of the same message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we create the instances, encode, decode, and check the decoded instance is the same as the original instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's called a roundtrip test, which broadly are less valuable / useful - it tests that the encoder is compatible with the decoder, with the risk that they both share the same bug and therefore remain incompatible with the schema.
When testing conformance to specifications, it's better to work with canonical examples based on the spec that have been generated independently using a reference implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a question then what is the proper max time for the encoding/decoding as I couldn't find it in the specs