-
Notifications
You must be signed in to change notification settings - Fork 54
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): Part 1 Test cases covering subscribe and unsubscribe Events #1201
base: master
Are you sure you want to change the base?
Conversation
how about |
# Addition of Designed Test cases for 6. Topic Membership Tests: https://www.notion.so/Gossipsub-651e02d4d7894bb2ac1e4edb55f3192d | ||
|
||
# Simulate the `SUBSCRIBE` event and check proper handling in the mesh and gossipsub structures | ||
asyncTest "handle SUBSCRIBE event": |
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.
This test is very similar to
asyncTest "subscribe/unsubscribeAll": |
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.
Agree on this but little difference is there
Subscription Handler:
Newly added test (handle SUBSCRIBE event):
Uses an anonymous function when subscribing to the topic, and it does not test for the dynamic dispatch mechanism used to handle topic messages.
Existing test (subscribe/unsubscribeAll):
It defines a handler function for handling messages sent to the subscribed topic. This makes the test more practical for simulating message reception and processing. It also uses dynamic dispatch for testing the subscription and unsubscription.
You can keep the newly added test if you want a lightweight, focused check for basic subscription functionality. If not required then will remove it as it was added keeping in mind for light sanity @AlejandroCabeza
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.
Uses an anonymous function when subscribing to the topic, and it does not test for the dynamic dispatch mechanism used to handle topic messages.
This doesn't need to be tested in this test.
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.
But we could replace the existing test with the first two you created. There's a lot of code repetition in testgossipinternal
as pointed out here #1207.
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.
Agree on it. I Will follow this as another task and can move all common lines of code to func to ensure testgossipinternal is clean with no redundant line of code in relevant file as well
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.
Please remove asyncTest "subscribe/unsubscribeAll"
in testgossipinternal.
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.
Please remove
asyncTest "subscribe/unsubscribeAll"
in testgossipinternal.
Removed
We follow conventional commits for the PR title. In this case, it will start with |
I am adding other tests in the same file related to Topic Membership Tests for Join topic, leave topic, and mesh updated on peer subscribing and leaving topic. Earlier suggestion looks fine but else will modify as per your suggestion |
Thanks. Will follow same in upcoming PRs |
added test wrt subscribe and unsubscribe added tests/pubsub/testgossipinternal2 file linters feat: rendezvous refactor (#1183) Hello! This PR aim to refactor rendezvous code so that it is easier to impl. Waku rdv strategy. The hardcoded min and max TTL were out of range with what we needed and specifying which peers to interact with is also needed since Waku deals with peers on multiple separate shards. I tried to keep the changes to a minimum, specifically I did not change the name of any public procs which result in less than descriptive names in some cases. I also wanted to return results instead of raising exceptions but didn't. Would it be acceptable to do so? Please advise on best practices, thank you. --------- Co-authored-by: Ludovic Chenut <ludovic@status.im> refactor and suite name refactor chore(ci): Enable S3 caching for interop (#1193) - Adds our S3 bucket for caching docker images as Protocol Labs shut down their shared one. - Remove the free disk space workaround that prevented the jobs from failing for using too much space for the images. --------- Co-authored-by: diegomrsantos <diego@status.im> PR review comment changes
9230ecd
to
eb2f6bf
Compare
I'm not sure if gossip membership makes sense. |
|
||
check gossipSub.topics.contains(topic) # Check if the topic is in topics | ||
check gossipSub.gossipsub[topic].len() > 0 # Check if topic added to gossipsub | ||
|
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.
The existing text also checks gossipSub.mesh[topic].len() > 0
. Is there a place defining what the tests should ensure?
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.
Test case are designed here: 6. Topic Membership Tests (❌ To Do)
https://www.notion.so/Gossipsub-651e02d4d7894bb2ac1e4edb55f3192d
These are split tests which check individual logic rather than subscribe and unsubscribe together
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.
Only test title is there and based on that we are adding checks to ensure that functionality. We can have details check test if required
# Iterate over the peers and check connection handling | ||
for peer in gossipSub.peers.values: | ||
check peer.sendConn != nil | ||
check not peer.sendConn.closed() |
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 don't think this is necessary.
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.
removed. Done
let (gossipSub, conns) = setupGossipSub(topic, 5) | ||
|
||
# Subscribe to the topic | ||
subscribeToTopics(gossipSub, @[topic].toSeq()) # Pass topic as seq[string] |
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.
.toSeq()
isn't necessary
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.
Thanks done
check topic notin gossipSub.topics # The topic should not be in topics | ||
check topic notin gossipSub.mesh # The topic should be removed from the mesh |
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 think those comments aren't necessary as the code is clear.
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.
removed all unwanted comments
Done
let (gossipSub, conns) = setupGossipSub(topic, 5) | ||
|
||
# Subscribe to the topic first | ||
subscribeToTopics(gossipSub, @[topic]) # Pass topic as seq[string] |
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.
Comment here also isn't necessary.
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.
removed
done
subscribeToTopics(gossipSub, @[topic]) # Pass topic as seq[string] | ||
|
||
# Now unsubscribe from the topic | ||
unsubscribeFromTopics(gossipSub, @[topic]) # Pass topic as seq[string] |
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.
Comment here also isn't necessary.
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.
removed
Done
gossipSub.PubSub.unsubscribeAll(topic) | ||
|
||
# Simulate the `SUBSCRIBE` to the topic and check proper handling in the mesh and gossipsub structures | ||
asyncTest "handle SUBSCRIBE to the topic and verify connection handling": |
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.
"handle SUBSCRIBE to the topic" is enough for the name.
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.
done
check gossipSub.topics.contains(topic) | ||
|
||
# Check if the topic is added to gossipsub and the peers list is not empty | ||
check gossipSub.gossipsub[topic].len() > 0 |
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 we move this line before subscribeToTopics(gossipSub, @[topic])
it's already true, so we aren't testing anything here.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1201 +/- ##
==========================================
+ Coverage 84.54% 84.55% +0.01%
==========================================
Files 93 93
Lines 16650 16681 +31
==========================================
+ Hits 14076 14104 +28
- Misses 2574 2577 +3 |
Test Plan: https://www.notion.so/Gossipsub-651e02d4d7894bb2ac1e4edb55f3192d
Topic Membership Tests:
Test added: (TC6.6: Verify the handling of subscription changes when the underlying pubsub framework sends SUBSCRIBE and UNSUBSCRIBE events.)
SUBSCRIBE
event and check proper handling in the mesh and gossipsub structures