Skip to content

Conversation

@rlve
Copy link
Contributor

@rlve rlve commented Jul 3, 2025

Changes:

  • add unit tests for GossipSub behaviour:
    • "handleIHave - do not handle IHave when message already in cache"
    • "handleIWant - message not handled without sent IHave"
    • "handleIWant - message not handled when not in cache"
    • "handleIWant - stops processing after 21 invalid requests"
    • "handlePrune - peer is pruned and backoff is set"
    • "handleGraft - peer joins mesh for subscribed topic"
    • "handleGraft - do not graft if peer already in mesh"
    • "handleGraft - reject peer when mesh at dHigh threshold"
    • "handleGraft - accept outbound peer when mesh at dHigh but below dOut threshold"
    • "handleGraft - reject outbound peer when mesh at dHigh and dOut threshold met"

@rlve rlve marked this pull request as ready for review July 3, 2025 13:50
@rlve rlve requested a review from a team as a code owner July 3, 2025 13:50
@rlve rlve changed the title test(gossipsub): more unit tests test(gossipsub): behavior unit tests 1 Jul 4, 2025

# Then IWant is ignored
check:
messages.len == 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: why does this mean that iwant was ignored and not handled? I assume that after iwant is handled the messages queue would be empty again, no?

Copy link
Contributor Author

@rlve rlve Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleIWant processes IWANT requests from peers and returns the actual messages they're asking for. It takes a list of message IDs and returns a sequence of Message objects.

The function only adds messages to the result if both conditions are met:
We previously sent an IHAVE for that message ID to the peer and the message still exists in the cache.

In this test: sentIHaves doesn't contain the message id and therefore the message is not returned.

@github-project-automation github-project-automation bot moved this from new to In Progress in nim-libp2p Jul 7, 2025
@rlve rlve enabled auto-merge (squash) July 7, 2025 18:25
@rlve rlve merged commit 773fc67 into master Jul 7, 2025
23 checks passed
@rlve rlve deleted the test-gossipsub-unit-tests branch July 7, 2025 18:45
@github-project-automation github-project-automation bot moved this from In Progress to done in nim-libp2p Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants