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(api): Test coverage for WebSocket server #525

Merged
merged 18 commits into from
Nov 29, 2023

Conversation

slowli
Copy link
Contributor

@slowli slowli commented Nov 20, 2023

What ❔

Cover basic WS-specific JSON-RPC functionality (subscriptions, getFilterChanges) with tests.

Why ❔

Will allow to set the expectations the current server behavior, so that it could be evolved in the future w/o unexpected / breaking changes (e.g., when implementing jsonrpsee-based subscriptions).

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Code has been formatted via zk fmt and zk lint.

@slowli slowli marked this pull request as ready for review November 22, 2023 08:05
@slowli slowli requested a review from a team as a code owner November 22, 2023 08:05
@slowli
Copy link
Contributor Author

slowli commented Nov 22, 2023

@montekki I haven't managed to find a way to reproduce duplicating or dropping event notifications so far. The notification logic, while not always straightforward, seems correct. If you have an idea how to reproduce the bug, please share.

@slowli slowli force-pushed the aov-pla-659-test-coverage-for-websocket-server branch from 7a4ab58 to b401387 Compare November 23, 2023 12:40
Copy link
Collaborator

@RomanBrodetski RomanBrodetski left a comment

Choose a reason for hiding this comment

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

Was only able to have a quick look and it looks good. @slowli please let me know if you want me to have a close look at any particular part!

@slowli
Copy link
Contributor Author

slowli commented Nov 27, 2023

@RomanBrodetski Please take a look at FIXMEs in tests. They are related to the getFilterChanges implementation, which (as we've briefly discussed elsewhere) may return the same updates multiple times. (Since the method it uses is modifying the filter cursor, and the HTTP / WS transport cannot be assumed to be reliable, we have neither "at most once" nor "at least once" semantics for update delivery.)

@montekki
Copy link
Contributor

@slowli Why again are getFilterChanges tests in the websocket testing? I believe that these methods are not websocket-specific and should instead go into main http endpoint testing. Only eth_subscribe is websocket-specific. If you agree I propose to move these tests into #546 and try to trigger all the corner cases there?

@slowli
Copy link
Contributor Author

slowli commented Nov 28, 2023

@montekki

I believe that these methods are not websocket-specific and should instead go into main http endpoint testing

They are indeed not WS-specific, although in practice it's impossible to use getFilterChanges HTTP endpoint for our testnet / mainnet deployments because of K8s load balancing (subsequent queries may arrive at different pods that don't have the referenced filter installed).

As for your proposal: Could it make sense to move tests within this PR (just make them test the HTTP server)? If this PR is merged before #546, then that PR could update the tests to reflect corrected server behavior.

@montekki
Copy link
Contributor

As for your proposal: Could it make sense to move tests within this PR (just make them test the HTTP server)? If this PR is merged before #546, then that PR could update the tests to reflect corrected server behavior.

Yeah good we could do two things I think

  1. either just move the abovementioned fix PR in here and expand the tests a bit
  2. or merge this one with referencing the fix PR in the FIXMEs

Whatever you prefer

montekki
montekki previously approved these changes Nov 28, 2023
@montekki montekki added this pull request to the merge queue Nov 29, 2023
Merged via the queue into main with commit 8b34ab9 Nov 29, 2023
21 checks passed
@montekki montekki deleted the aov-pla-659-test-coverage-for-websocket-server branch November 29, 2023 18:17
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.

3 participants