go-ethereum/rpc
Daniel Liu 5e4c2cb821
rpc: add method to test for subscription support #25942 (#999)
This adds two ways to check for subscription support. First, one can now check
whether the transport method (HTTP/WS/etc.) is capable of subscriptions using
the new Client.SupportsSubscriptions method.

Second, the error returned by Subscribe can now reliably be tested using this
pattern:

    sub, err := client.Subscribe(...)
    if errors.Is(err, rpc.ErrNotificationsUnsupported) {
        // no subscription support
    }

---------

Co-authored-by: zhiqiangxu <652732310@qq.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-04-28 17:46:24 +08:00
..
testdata rpc: add limit for batch request and response size #26681 (#998) 2025-04-28 17:00:30 +08:00
client.go rpc: add method to test for subscription support #25942 (#999) 2025-04-28 17:46:24 +08:00
client_example_test.go upgrade the websocket in xdpos (#349) 2023-11-06 15:37:14 +11:00
client_opt.go rpc: add limit for batch request and response size #26681 (#998) 2025-04-28 17:00:30 +08:00
client_opt_test.go node, rpc: add JWT auth support in client #24911 2025-04-28 10:25:07 +08:00
client_test.go rpc: add limit for batch request and response size #26681 (#998) 2025-04-28 17:00:30 +08:00
constants_unix.go upgrade the websocket in xdpos (#349) 2023-11-06 15:37:14 +11:00
constants_unix_nocgo.go upgrade the websocket in xdpos (#349) 2023-11-06 15:37:14 +11:00
context_headers.go rpc: support injecting HTTP headers through context #26023 (#977) 2025-04-24 19:08:16 +08:00
doc.go upgrade the websocket in xdpos (#349) 2023-11-06 15:37:14 +11:00
endpoints.go console: handle eth.coinbase throws #19374 (#953) 2025-04-24 18:11:48 +08:00
errors.go rpc: add method to test for subscription support #25942 (#999) 2025-04-28 17:46:24 +08:00
handler.go rpc: add method to test for subscription support #25942 (#999) 2025-04-28 17:46:24 +08:00
http.go rpc: add limit for batch request and response size #26681 (#998) 2025-04-28 17:00:30 +08:00
http_test.go rpc: support injecting HTTP headers through context #26023 (#977) 2025-04-24 19:08:16 +08:00
inproc.go rpc: add limit for batch request and response size #26681 (#998) 2025-04-28 17:00:30 +08:00
ipc.go rpc: add limit for batch request and response size #26681 (#998) 2025-04-28 17:00:30 +08:00
ipc_js.go upgrade the websocket in xdpos (#349) 2023-11-06 15:37:14 +11:00
ipc_unix.go rpc: fix off-by-one in ipc endpoint length check #26614 (#985) 2025-04-28 09:10:46 +08:00
ipc_wasip1.go all: add build tags for wasip1 (#31090) 2025-03-19 18:02:46 +08:00
ipc_windows.go console: handle eth.coinbase throws #19374 (#953) 2025-04-24 18:11:48 +08:00
json.go node, rpc: improve HTTP write timeout handling #25457 (#982) 2025-04-25 08:01:44 +08:00
metrics.go rpc: fix ns/µs mismatch in metrics (#28649) 2024-12-13 14:00:13 +08:00
server.go rpc: add limit for batch request and response size #26681 (#998) 2025-04-28 17:00:30 +08:00
server_test.go rpc: add limit for batch request and response size #26681 (#998) 2025-04-28 17:00:30 +08:00
service.go rpc: more accurate checking of handler method signatures #27287 (#990) 2025-04-28 10:45:50 +08:00
stdio.go rpc: add limit for batch request and response size #26681 (#998) 2025-04-28 17:00:30 +08:00
subscription.go rpc: add method to test for subscription support #25942 (#999) 2025-04-28 17:46:24 +08:00
subscription_test.go rpc: check that version is 2.0 in request objects #25570 (#973) 2025-04-24 19:02:33 +08:00
testservice_test.go rpc: improve error codes for internal server errors #25678 (#974) 2025-04-24 19:03:29 +08:00
types.go rpc: change BlockNumber constant values to match ethclient #27219 (#992) 2025-04-28 10:59:34 +08:00
types_test.go rpc: implement JSON marshaling of BlockNumber #23324 (#958) 2025-04-24 18:20:03 +08:00
websocket.go rpc: add limit for batch request and response size #26681 (#998) 2025-04-28 17:00:30 +08:00
websocket_test.go rpc, internal/guide: speed up tests a bit #26193 (#981) 2025-04-24 22:08:58 +08:00