You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A more descriptive name should be given to this file. In addition, there is noticeable repetition in the test cases, particularly around the setup and teardown of GossipSub instances and the repeated creation of Connection objects across various test cases. These redundant steps are affecting the maintainability and readability of the code.
Details
Most test cases include similar patterns:
GossipSub Initialization: Each test initializes a GossipSub instance with a set of topic parameters, mesh, fanout, and gossipsub fields.
Connection Setup: Every test manually creates and configures Connection objects, assigns PeerId values, and links them with PubSubPeer instances.
Teardown Process: Each test includes logic for stopping the switch and closing all connections, which is similarly repeated.
This repetition can be avoided by:
Extracting common initialization logic for GossipSub and Connection into a helper function.
Extracting common teardown steps into a shared teardown function.
Using these helper functions across all tests to reduce the repetitive code.
Possible Fix
Introduce helper functions for setting up GossipSub with default topic and peer configurations. Example:
proc setupGossipSubWithPeers(numPeers: int): (GossipSub, seq[Connection]) could handle the creation of the GossipSub instance and its associated connections.
Teardown Helper: Refactor the connection teardown into proc teardownGossipSub(gossipSub: GossipSub, conns: seq[Connection]) to avoid redundant cleanup logic.
The text was updated successfully, but these errors were encountered:
Summary
A more descriptive name should be given to this file. In addition, there is noticeable repetition in the test cases, particularly around the setup and teardown of GossipSub instances and the repeated creation of Connection objects across various test cases. These redundant steps are affecting the maintainability and readability of the code.
Details
Most test cases include similar patterns:
This repetition can be avoided by:
Possible Fix
setupGossipSubWithPeers(numPeers: int): (GossipSub, seq[Connection])
could handle the creation of the GossipSub instance and its associated connections.proc teardownGossipSub(gossipSub: GossipSub, conns: seq[Connection])
to avoid redundant cleanup logic.The text was updated successfully, but these errors were encountered: