From e4c201acca2626c3992ed6eaf9528b4000dae49e Mon Sep 17 00:00:00 2001 From: Sterling Long Date: Tue, 27 Jun 2023 08:53:15 -0600 Subject: [PATCH] Fixed relay url regression and added tests --- CHANGELOG.md | 4 ++++ .../websocket/websocket_handler.dart | 1 - lib/apis/utils/constants.dart | 4 ++-- pubspec.yaml | 2 +- test/core_api/relay_client_test.dart | 18 ++++++++++----- test/sign_api/web3wallet_sign_test.dart | 23 ++++++++----------- 6 files changed, 28 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2168c0c..4b7ce7a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.12 + +- Fixed regression with default relay URL, added tests to ensure it doesn't happen again + ## 2.0.11 - Updated relay client's error messages to be accurate and descriptive. diff --git a/lib/apis/core/relay_client/websocket/websocket_handler.dart b/lib/apis/core/relay_client/websocket/websocket_handler.dart index 713643c7..793e306a 100644 --- a/lib/apis/core/relay_client/websocket/websocket_handler.dart +++ b/lib/apis/core/relay_client/websocket/websocket_handler.dart @@ -3,7 +3,6 @@ import 'dart:async'; import 'package:stream_channel/stream_channel.dart'; import 'package:walletconnect_flutter_v2/apis/core/relay_client/websocket/i_http_client.dart'; import 'package:walletconnect_flutter_v2/apis/core/relay_client/websocket/i_websocket_handler.dart'; -import 'package:walletconnect_flutter_v2/apis/models/basic_models.dart'; import 'package:web_socket_channel/web_socket_channel.dart'; class WebSocketHandler implements IWebSocketHandler { diff --git a/lib/apis/utils/constants.dart b/lib/apis/utils/constants.dart index 2ec37a18..25d46f6d 100644 --- a/lib/apis/utils/constants.dart +++ b/lib/apis/utils/constants.dart @@ -1,11 +1,11 @@ class WalletConnectConstants { - static const SDK_VERSION = '2.0.11'; + static const SDK_VERSION = '2.0.12'; static const CORE_PROTOCOL = 'wc'; static const CORE_VERSION = 2; static const CORE_CONTEXT = 'core'; - static const DEFAULT_RELAY_URL = 'wss://relay.walletconnect.org'; + static const DEFAULT_RELAY_URL = 'wss://relay.walletconnect.com'; static const CORE_STORAGE_PREFIX = '$CORE_PROTOCOL@$CORE_VERSION:$CORE_CONTEXT:'; diff --git a/pubspec.yaml b/pubspec.yaml index c2873ef9..1978dd2e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: walletconnect_flutter_v2 description: WalletConnect v2 client made in dart for flutter. -version: 2.0.11 +version: 2.0.12 repository: https://github.com/WalletConnect/WalletConnectFlutterV2 environment: diff --git a/test/core_api/relay_client_test.dart b/test/core_api/relay_client_test.dart index 8e4936b1..ca6bdb0d 100644 --- a/test/core_api/relay_client_test.dart +++ b/test/core_api/relay_client_test.dart @@ -3,13 +3,8 @@ import 'dart:async'; import 'package:flutter_test/flutter_test.dart'; import 'package:http/http.dart'; import 'package:mockito/mockito.dart'; -import 'package:walletconnect_flutter_v2/apis/core/core.dart'; -import 'package:walletconnect_flutter_v2/apis/core/i_core.dart'; -import 'package:walletconnect_flutter_v2/apis/core/pairing/utils/pairing_models.dart'; import 'package:walletconnect_flutter_v2/apis/core/relay_client/relay_client.dart'; -import 'package:walletconnect_flutter_v2/apis/core/relay_client/relay_client_models.dart'; -import 'package:walletconnect_flutter_v2/apis/models/basic_models.dart'; -import 'package:walletconnect_flutter_v2/apis/utils/errors.dart'; +import 'package:walletconnect_flutter_v2/walletconnect_flutter_v2.dart'; import '../shared/shared_test_values.dart'; import '../shared/shared_test_utils.dart'; @@ -21,6 +16,17 @@ void main() { const TEST_TOPIC = 'abc123'; const TEST_MESSAGE = 'swagmasterss'; + test('relays are correct', () { + expect( + WalletConnectConstants.DEFAULT_RELAY_URL, + 'wss://relay.walletconnect.com', + ); + expect( + WalletConnectConstants.DEFAULT_PUSH_URL, + 'https://echo.walletconnect.com', + ); + }); + group('Relay throws errors', () { test('when connection parameters are invalid', () async { final http = MockHttpWrapper(); diff --git a/test/sign_api/web3wallet_sign_test.dart b/test/sign_api/web3wallet_sign_test.dart index 5df10103..cd67cbbe 100644 --- a/test/sign_api/web3wallet_sign_test.dart +++ b/test/sign_api/web3wallet_sign_test.dart @@ -11,20 +11,15 @@ void main() { signEngineTests( context: 'Web3App/Wallet', - clientACreator: (PairingMetadata metadata) async { - final app = Web3App( - core: Core( - projectId: TEST_PROJECT_ID, - relayUrl: TEST_RELAY_URL, - memoryStore: true, - logLevel: Level.info, - httpClient: getHttpWrapper(), - ), - metadata: metadata, - ); - await app.init(); - return app; - }, + clientACreator: (PairingMetadata metadata) async => + await Web3App.createInstance( + projectId: TEST_PROJECT_ID, + relayUrl: TEST_RELAY_URL, + metadata: metadata, + memoryStore: true, + logLevel: Level.info, + httpClient: getHttpWrapper(), + ), clientBCreator: (PairingMetadata metadata) async => await Web3Wallet.createInstance( projectId: TEST_PROJECT_ID,