Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
quetool committed Nov 2, 2023
1 parent 40995be commit 29a1edd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
14 changes: 3 additions & 11 deletions lib/apis/core/relay_client/relay_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -299,11 +295,7 @@ class RelayClient implements IRelayClient {

onRelayClientConnect.broadcast();
} catch (e) {
onRelayClientError.broadcast(
ErrorEvent(
e,
),
);
onRelayClientError.broadcast(ErrorEvent(e));
}
_connecting = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ abstract class IWebSocketHandler {

Future<void> get ready;

Future<void> setup({
required String url,
});
Future<void> setup({required String url});

Future<void> connect();

Expand Down
10 changes: 2 additions & 8 deletions test/core_api/relay_client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -91,10 +88,7 @@ void main() {
Completer completer = Completer();
core.relayClient.onRelayClientError.subscribe((args) {
expect(args!.error, isA<WalletConnectError>());
expect(
args.error.message,
WebSocketErrors.INVALID_PROJECT_ID_OR_JWT,
);
expect(args.error.code, 3000);
completer.complete();
});

Expand Down

0 comments on commit 29a1edd

Please sign in to comment.