From 29a1edd63806455575285bd61267e8d297a439a1 Mon Sep 17 00:00:00 2001 From: Alfreedom <00tango.bromine@icloud.com> Date: Thu, 2 Nov 2023 12:15:13 +0100 Subject: [PATCH] minor changes --- lib/apis/core/relay_client/relay_client.dart | 14 +++----------- .../websocket/i_websocket_handler.dart | 4 +--- test/core_api/relay_client_test.dart | 10 ++-------- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/lib/apis/core/relay_client/relay_client.dart b/lib/apis/core/relay_client/relay_client.dart index d5b0e854..f806f908 100644 --- a/lib/apis/core/relay_client/relay_client.dart +++ b/lib/apis/core/relay_client/relay_client.dart @@ -255,14 +255,10 @@ class RelayClient implements IRelayClient { } core.logger.t('Initializing WebSocket with $url'); - await socketHandler.setup( - url: url, - ); + await socketHandler.setup(url: url); await socketHandler.connect(); - jsonRPC = Peer( - socketHandler.channel!, - ); + jsonRPC = Peer(socketHandler.channel!); jsonRPC!.registerMethod( _buildMethod(JSON_RPC_SUBSCRIPTION), @@ -299,11 +295,7 @@ class RelayClient implements IRelayClient { onRelayClientConnect.broadcast(); } catch (e) { - onRelayClientError.broadcast( - ErrorEvent( - e, - ), - ); + onRelayClientError.broadcast(ErrorEvent(e)); } _connecting = false; } diff --git a/lib/apis/core/relay_client/websocket/i_websocket_handler.dart b/lib/apis/core/relay_client/websocket/i_websocket_handler.dart index 7e836f50..3ba7472e 100644 --- a/lib/apis/core/relay_client/websocket/i_websocket_handler.dart +++ b/lib/apis/core/relay_client/websocket/i_websocket_handler.dart @@ -12,9 +12,7 @@ abstract class IWebSocketHandler { Future get ready; - Future setup({ - required String url, - }); + Future setup({required String url}); Future connect(); diff --git a/test/core_api/relay_client_test.dart b/test/core_api/relay_client_test.dart index 0294a136..666a9386 100644 --- a/test/core_api/relay_client_test.dart +++ b/test/core_api/relay_client_test.dart @@ -77,10 +77,7 @@ void main() { test('when connection parameters are invalid', () async { final http = MockHttpWrapper(); when(http.get(any)).thenAnswer( - (_) async => Response( - '', - WebSocketErrors.PROJECT_ID_NOT_FOUND, - ), + (_) async => Response('', 3000), ); final ICore core = Core( projectId: 'abc', @@ -91,10 +88,7 @@ void main() { Completer completer = Completer(); core.relayClient.onRelayClientError.subscribe((args) { expect(args!.error, isA()); - expect( - args.error.message, - WebSocketErrors.INVALID_PROJECT_ID_OR_JWT, - ); + expect(args.error.code, 3000); completer.complete(); });