Skip to content
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(waku-filter): Subscribe tests batch (2/4) #2035

Merged

Conversation

AlejandroCabeza
Copy link
Contributor

@AlejandroCabeza AlejandroCabeza commented Sep 14, 2023

Description

Implement second batch of subscribe tests for waku filter.

Changes

  • Implement subscribe tests.

Dependencies

#2034

@AlejandroCabeza AlejandroCabeza self-assigned this Sep 14, 2023
@AlejandroCabeza AlejandroCabeza changed the base branch from master to test-waku-filter-subscribe September 14, 2023 11:02
@github-actions
Copy link

github-actions bot commented Sep 14, 2023

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:2035

Built from 7d23fff

@AlejandroCabeza AlejandroCabeza changed the title test(waku-filter): Subscribe tests batch 2 test(waku-filter): Subscribe tests batch (2/3) Sep 19, 2023
@AlejandroCabeza AlejandroCabeza changed the title test(waku-filter): Subscribe tests batch (2/3) test(waku-filter): Subscribe tests batch (3/3) Sep 19, 2023
@AlejandroCabeza AlejandroCabeza changed the title test(waku-filter): Subscribe tests batch (3/3) test(waku-filter): Subscribe tests batch (2/3) Sep 19, 2023
@AlejandroCabeza AlejandroCabeza force-pushed the test-waku-filter-subscribe-2 branch 2 times, most recently from 44fef54 to 5063ab4 Compare September 20, 2023 17:34
@AlejandroCabeza AlejandroCabeza changed the title test(waku-filter): Subscribe tests batch (2/3) test(waku-filter): Subscribe tests batch (2/4) Sep 20, 2023
@AlejandroCabeza AlejandroCabeza marked this pull request as ready for review September 25, 2023 13:01
# Given
let
subscribeResponse = await wakuFilterClient.subscribe(
assert subscribeResponse.isOk(), $subscribeResponse.error
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it be unsubscribeResponse here? Also maybe instead of assert formulize a check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed it is. Fixed, along the other typos you mentioned.

The assert is a suggestion from @Ivansete-status. What this does is, if the check fails it prints the value on the right, namely $subscribeResponse.error, which is useful for debugging.

unsubscribeResponse.isOk()
wakuFilter.subscriptions.len == 0

# When sending a message to the previously subscribed content topic
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a little typo here.

Suggested change
# When sending a message to the previously subscribed content topic
# When sending a message to the previously unsubscribed content topic

unsubscribeResponse.isOk()
wakuFilter.subscriptions.len == 0

# When sending a message to the previously subscribed content topic
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# When sending a message to the previously subscribed content topic
# When sending a message to the previously unsubscribed content topic

check:
not await pushHandlerFuture.withTimeout(FUTURE_TIMEOUT)

# When sending a message to the other previously subscribed content topic
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# When sending a message to the other previously subscribed content topic
# When sending a message to the other previously unsubscribed content topic

wakuFilter.subscriptions.hasKey(clientPeerId)
wakuFilter.getSubscribedContentTopics(clientPeerId) == otherContentTopicSeq

# When sending a message to the previously subscribed content topic
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# When sending a message to the previously subscribed content topic
# When sending a message to the previously unsubscribed content topic

unsubscribeResponse2.isOk()
wakuFilter.subscriptions.len == 0

# When sending a message to the previously subscribed content topic
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# When sending a message to the previously subscribed content topic
# When sending a message to the previously unsubscribed content topic

Copy link
Contributor

@NagyZoltanPeter NagyZoltanPeter left a comment

Choose a reason for hiding this comment

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

I think it is all good! Thank you for the great work!
I found only some typos and maybe one missed check.

Copy link
Contributor

@NagyZoltanPeter NagyZoltanPeter left a comment

Choose a reason for hiding this comment

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

LGTM!
Its a good idea having that assert like this. I did not know.

Copy link
Collaborator

@Ivansete-status Ivansete-status left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for it! 💯

pushHandlerFuture = newPushHandlerFuture()
messagePushHandler = proc(
pubsubTopic: PubsubTopic, message: WakuMessage
): Future[void] {.async, closure, gcsafe.} =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Small nitpick:
I think is not needed to use Future[void]. This is done implicitly by the async pragma.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good to know, thanks!

serverRemotePeerInfo, pubsubTopic, contentTopicSeq
)
require:
subscribeResponse.isOk()
Copy link
Collaborator

Choose a reason for hiding this comment

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

For that kind of validation, I think it is better to do the next so that we have a better detail in case of failure:
assert subscribeResponse.isOk(), $subscribeResponse.error

That applies elsewhere a Result is being checked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, must've slipped by when changing.
I'm actually moving away from require, as if a require doesn't work, it makes the whole test suite fail, so I'd rather use checks or asserts.

# Given
let
subscribeResponse = await wakuFilterClient.subscribe(
suite "MessagePushHandler - Void":
Copy link
Collaborator

Choose a reason for hiding this comment

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

For me to understand better. What does "Void" mean in this context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just a (poor) naming I used to differentiate the two different push handlers I used: One containing future (as a way to confirm a message arrived), and the other also adding the messages to a list.

I'm planning to remove this classification because the cost of making it understandable is not worth the time improvement it provides. Better to have a single push handler that does both things (have a future, and add to list), even if the list is not used in some tests.

* Implement waku filter client subscribe tests.
* Remove legacy filter tests.
* Fix constant for max criteria per subscription limit.
@AlejandroCabeza AlejandroCabeza merged commit e1f470d into test-waku-filter-subscribe Oct 12, 2023
2 checks passed
@AlejandroCabeza AlejandroCabeza deleted the test-waku-filter-subscribe-2 branch October 12, 2023 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants