-
Notifications
You must be signed in to change notification settings - Fork 49
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
test(waku-filter): Subscribe tests batch (2/4) #2035
Conversation
You can find the image built from this PR at
Built from 7d23fff |
69f7d66
to
070a72a
Compare
b54e77a
to
e7bca65
Compare
44fef54
to
5063ab4
Compare
5063ab4
to
f4b924f
Compare
4f0326a
to
6605abf
Compare
f4b924f
to
29d4837
Compare
# Given | ||
let | ||
subscribeResponse = await wakuFilterClient.subscribe( | ||
assert subscribeResponse.isOk(), $subscribeResponse.error |
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.
Isn't it be unsubscribeResponse here? Also maybe instead of assert formulize a check?
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.
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 |
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.
Just a little typo here.
# 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 |
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.
# 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 |
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.
# 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 |
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.
# 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 |
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.
# When sending a message to the previously subscribed content topic | |
# When sending a message to the previously unsubscribed content topic |
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 it is all good! Thank you for the great work!
I found only some typos and maybe one missed check.
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.
LGTM!
Its a good idea having that assert like this. I did not know.
6605abf
to
798c7f6
Compare
30c78cf
to
ebf4a50
Compare
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.
LGTM! Thanks for it! 💯
pushHandlerFuture = newPushHandlerFuture() | ||
messagePushHandler = proc( | ||
pubsubTopic: PubsubTopic, message: WakuMessage | ||
): Future[void] {.async, closure, gcsafe.} = |
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.
Small nitpick:
I think is not needed to use Future[void]
. This is done implicitly by the async
pragma.
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.
Good to know, thanks!
serverRemotePeerInfo, pubsubTopic, contentTopicSeq | ||
) | ||
require: | ||
subscribeResponse.isOk() |
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.
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.
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, 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": |
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.
For me to understand better. What does "Void" mean in this context?
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.
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.
798c7f6
to
dc47a6f
Compare
ebf4a50
to
225da69
Compare
dc47a6f
to
76be3d1
Compare
225da69
to
a6ca5be
Compare
76be3d1
to
c0f218b
Compare
a6ca5be
to
f4ea8e3
Compare
* Implement waku filter client subscribe tests. * Remove legacy filter tests. * Fix constant for max criteria per subscription limit.
Description
Implement second batch of subscribe tests for waku filter.
Changes
Dependencies
#2034