feat(l1): [1] add jsonrpc client enablers and ws test server - #3878
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a small internal JSON-RPC test server for L1 client/provider tests and slightly enhances the JSON-RPC server package by exporting the response type and making jsonrpc.Error implement the error interface.
Changes:
- Introduce
l1/internal/clienttest.TestServer, supporting both HTTP POST JSON-RPC and WebSocket JSON-RPC on the same endpoint, plus helpers for pushing notifications/raw frames. - Export
jsonrpc.Response(previously unexported) and implementError() stringonjsonrpc.Error. - Minor logging formatting adjustment in
jsonrpc/server.go.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| l1/internal/clienttest/server.go | Adds an internal HTTP+WebSocket JSON-RPC test server with helpers for test-driven behaviors (notifications, malformed frames, ping/pong controls). |
| jsonrpc/server.go | Exposes Response and adds Error.Error() for improved error interoperability/logging. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (4.82%) is below the target coverage (60.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #3878 +/- ##
==========================================
- Coverage 75.43% 75.13% -0.30%
==========================================
Files 442 443 +1
Lines 39862 39974 +112
==========================================
- Hits 30068 30035 -33
- Misses 7713 7855 +142
- Partials 2081 2084 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
7cab580 to
e29ba56
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
l1/internal/clienttest/server.go:253
rawRPCRequestis documented as being duplicated from a clientrpcRequestand able to read malformed frames without client constraints, but there is norpcRequesttype in the repo and the current struct still constrainsidtouint64(string/null IDs will fail unmarshal and be dropped). Consider making the requestidajson.RawMessageand parsing it best-effort forTestRequest.ID, and update the comment accordingly.
// rawRPCRequest is duplicated from the client's rpcRequest so the server can
// read malformed frames without the client package's constraints.
type rawRPCRequest struct {
JSONRPC string `json:"jsonrpc"`
ID uint64 `json:"id"`
|
Claude finished @brbrr's task in 5m 26s —— View job Review summary
No blockers. Important
Nit
One process note: I could not run |
e29ba56 to
a33c2b3
Compare
Review in progress
|
a33c2b3 to
592fb3e
Compare
|
Claude finished @brbrr's task in 4m 57s —— View job Re-review (push
|
592fb3e to
7903a3e
Compare
|
Claude finished @brbrr's task in 4m 8s —— View job Re-review (head
|
7903a3e to
d7e2746
Compare
|
Claude finished @brbrr's task in 6m 12s —— View job Re-review (head
|
There was a problem hiding this comment.
Why do we need to define all this test utility and not make it part of a _test.go file?
There was a problem hiding this comment.
It is explained in the package doc comment, but tl;dr:
It (will be) used in both eth/client and eth_l1_state_provider tests. And from my understanding go won't allow importing from _test.go into another package.

This is a perparation for #3877. Test server will be used in the follow up PR.