forked from cerc-io/plugeth
rpc: add method to test for subscription support (#25942)
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: Felix Lange <fjl@twurst.com>
This commit is contained in:
co-authored by
Felix Lange
parent
8bbaf882a6
commit
6f08c2f3f1
+1
-4
@@ -530,10 +530,7 @@ func (h *handler) handleCall(cp *callProc, msg *jsonrpcMessage) *jsonrpcMessage
|
||||
// handleSubscribe processes *_subscribe method calls.
|
||||
func (h *handler) handleSubscribe(cp *callProc, msg *jsonrpcMessage) *jsonrpcMessage {
|
||||
if !h.allowSubscribe {
|
||||
return msg.errorResponse(&internalServerError{
|
||||
code: errcodeNotificationsUnsupported,
|
||||
message: ErrNotificationsUnsupported.Error(),
|
||||
})
|
||||
return msg.errorResponse(ErrNotificationsUnsupported)
|
||||
}
|
||||
|
||||
// Subscription method name is first argument.
|
||||
|
||||
Reference in New Issue
Block a user