-
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 5 commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -662,6 +662,62 @@ suite "GossipSub internal": | |
await allFuturesThrowing(conns.mapIt(it.close())) | ||
await gossipSub.switch.stop() | ||
|
||
# test cases for block 5 gossibsub test plan | ||
# check correctly parsed ihave/iwant/graft/prune/idontwant messages | ||
# check value before & after decoding equal using protoc cmd tool for reference | ||
asyncTest "Check RPCMsg encoding": | ||
let backofftime = 10.uint64 | ||
var id: seq[byte] = @[123] | ||
let rpcMsg = RPCMsg( | ||
control: some( | ||
ControlMessage( | ||
ihave: @[ControlIHave(topicID: "foobar", messageIDs: @[id])], | ||
iwant: @[ControlIWant(messageIDs: @[id])], | ||
graft: @[ControlGraft(topicID: "foobar")], | ||
prune: @[ControlPrune(topicID: "foobar", backoff: backofftime)], | ||
idontwant: @[ControlIWant(messageIDs: @[id])], | ||
) | ||
) | ||
) | ||
let encodedExpected: seq[byte] = | ||
@[ | ||
26, 51, 10, 10, 6, 102, 111, 111, 98, 97, 114, 18, 3, 49, 50, 51, 18, 5, 10, 3, | ||
49, 50, 51, 26, 8, 10, 6, 102, 111, 111, 98, 97, 114, 34, 10, 10, 6, 102, 111, | ||
111, 98, 97, 114, 16, 10, 42, 5, 10, 3, 49, 50, 51, | ||
] #encoded using protoc cmd tool | ||
|
||
|
||
check: | ||
|
||
encodedExpected == encodedMsg | ||
|
||
asyncTest "Check RPCMsg decoding": | ||
let backofftime = 12.uint64 | ||
let id: seq[byte] = @[1] | ||
let originMessage = RPCMsg( | ||
control: some( | ||
ControlMessage( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since you used all message types in the encoding, does it make sense to use all of them in the decoding as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
ihave: @[ControlIHave(topicID: "foobar", messageIDs: @[id])], | ||
iwant: @[ControlIWant(messageIDs: @[id])], | ||
graft: @[ControlGraft(topicID: "topic")], | ||
prune: @[ControlPrune(topicID: "new", backoff: backofftime)], | ||
idontwant: @[ControlIWant(messageIDs: @[id])], | ||
) | ||
) | ||
) | ||
#data encoded using protoc cmd tool | ||
let encodedMsg: seq[byte] = | ||
@[ | ||
26, 41, 10, 11, 10, 6, 102, 111, 111, 98, 97, 114, 18, 1, 49, 18, 3, 10, 1, 49, | ||
26, 7, 10, 5, 116, 111, 112, 105, 99, 34, 7, 10, 3, 110, 101, 119, 16, 12, 42, | ||
3, 10, 1, 49, | ||
] | ||
|
||
|
||
check: | ||
|
||
rpcMsg == originMessage | ||
|
||
asyncTest "handleIHave/Iwant tests": | ||
let gossipSub = TestGossipSub.init(newStandardSwitch()) | ||
|
||
|
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.
I know that TC5.9 was not in the original scope of this task but maybe we should add it here as well if it makes sense
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.
idontwant added in the latest commit