From dbbcac13ed358884f83a9ab373adeda0c6e7fdd1 Mon Sep 17 00:00:00 2001 From: Artur Guseinov Date: Wed, 22 Jun 2022 17:11:18 +0500 Subject: [PATCH 1/9] WebSocketConnecting protocol injection --- Example/DApp/SceneDelegate.swift | 11 +++++++- Example/ExampleApp.xcodeproj/project.pbxproj | 25 +++++++++++++++++++ Package.swift | 6 ++--- Sources/WalletConnectRelay/Dispatching.swift | 5 ++-- Sources/WalletConnectRelay/RelayClient.swift | 5 ++-- .../ManualSocketConnectionHandler.swift | 1 - .../SocketConnectionHandler.swift | 2 +- .../WebSocketConnecting.swift | 12 ++++++--- .../WebSocketProtocol.swift | 11 -------- Sources/WalletConnectSign/Sign/Sign.swift | 21 +++++++++++++--- .../WalletConnectSign/Sign/SignClient.swift | 8 +++--- .../WalletConnectSign/Sign/SignConfig.swift | 9 ++++++- .../RelayClientEndToEndTests.swift | 1 - 13 files changed, 81 insertions(+), 36 deletions(-) delete mode 100644 Sources/WalletConnectRelay/SocketConnectionHandler/WebSocketProtocol.swift diff --git a/Example/DApp/SceneDelegate.swift b/Example/DApp/SceneDelegate.swift index cb602f2aa..f32efeaa7 100644 --- a/Example/DApp/SceneDelegate.swift +++ b/Example/DApp/SceneDelegate.swift @@ -1,6 +1,14 @@ import UIKit import WalletConnectSign +import WalletConnectRelay import Combine +import Starscream + +extension WebSocket: WebSocketConnecting { + public static func instance(with url: URL) -> WebSocketConnecting { + return WebSocket(url: url) + } +} class SceneDelegate: UIResponder, UIWindowSceneDelegate { @@ -18,7 +26,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { description: "a description", url: "wallet.connect", icons: ["https://avatars.githubusercontent.com/u/37784886"]) - Sign.configure(Sign.Config(metadata: metadata, projectId: "8ba9ee138960775e5231b70cc5ef1c3a")) + + Sign.configure(metadata: metadata, projectId: "8ba9ee138960775e5231b70cc5ef1c3a", socketImplementation: WebSocket.self) if CommandLine.arguments.contains("-cleanInstall") { try? Sign.instance.cleanup() diff --git a/Example/ExampleApp.xcodeproj/project.pbxproj b/Example/ExampleApp.xcodeproj/project.pbxproj index f128b6c84..7dcbb6218 100644 --- a/Example/ExampleApp.xcodeproj/project.pbxproj +++ b/Example/ExampleApp.xcodeproj/project.pbxproj @@ -53,6 +53,8 @@ A5A4FC5C283D1F6700BBEC1E /* SessionDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A4FC5B283D1F6700BBEC1E /* SessionDetailViewController.swift */; }; A5A4FC5E283D23CA00BBEC1E /* Array.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A4FC5D283D23CA00BBEC1E /* Array.swift */; }; A5A4FC772840C12C00BBEC1E /* RegressionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A4FC762840C12C00BBEC1E /* RegressionTests.swift */; }; + A5D85226286333D500DAF5C3 /* Starscream in Frameworks */ = {isa = PBXBuildFile; productRef = A5D85225286333D500DAF5C3 /* Starscream */; }; + A5D85228286333E300DAF5C3 /* Starscream in Frameworks */ = {isa = PBXBuildFile; productRef = A5D85227286333E300DAF5C3 /* Starscream */; }; A5E22D1A2840C62A00E36487 /* Engine.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E22D192840C62A00E36487 /* Engine.swift */; }; A5E22D1C2840C85D00E36487 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E22D1B2840C85D00E36487 /* App.swift */; }; A5E22D1E2840C8BF00E36487 /* RoutingEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E22D1D2840C8BF00E36487 /* RoutingEngine.swift */; }; @@ -170,6 +172,7 @@ files = ( 764E1D5826F8DBAB00A1FB15 /* WalletConnect in Frameworks */, 844943A1278EC49700CC26BB /* Web3 in Frameworks */, + A5D85226286333D500DAF5C3 /* Starscream in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -179,6 +182,7 @@ files = ( 8448F1D427E4726F0000B866 /* WalletConnect in Frameworks */, 84CE64392798228D00142511 /* Web3 in Frameworks */, + A5D85228286333E300DAF5C3 /* Starscream in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -443,6 +447,7 @@ packageProductDependencies = ( 764E1D5726F8DBAB00A1FB15 /* WalletConnect */, 844943A0278EC49700CC26BB /* Web3 */, + A5D85225286333D500DAF5C3 /* Starscream */, ); productName = ExampleApp; productReference = 764E1D3C26F8D3FC00A1FB15 /* WalletConnect Wallet.app */; @@ -464,6 +469,7 @@ packageProductDependencies = ( 84CE64382798228D00142511 /* Web3 */, 8448F1D327E4726F0000B866 /* WalletConnect */, + A5D85227286333E300DAF5C3 /* Starscream */, ); productName = DApp; productReference = 84CE641C27981DED00142511 /* DApp.app */; @@ -564,6 +570,7 @@ mainGroup = 764E1D3326F8D3FC00A1FB15; packageReferences = ( 8449439F278EC49700CC26BB /* XCRemoteSwiftPackageReference "Web3" */, + A5D85224286333D500DAF5C3 /* XCRemoteSwiftPackageReference "Starscream" */, ); productRefGroup = 764E1D3D26F8D3FC00A1FB15 /* Products */; projectDirPath = ""; @@ -1171,6 +1178,14 @@ minimumVersion = 0.5.3; }; }; + A5D85224286333D500DAF5C3 /* XCRemoteSwiftPackageReference "Starscream" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/daltoniam/Starscream"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 3.0.0; + }; + }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ @@ -1192,6 +1207,16 @@ package = 8449439F278EC49700CC26BB /* XCRemoteSwiftPackageReference "Web3" */; productName = Web3; }; + A5D85225286333D500DAF5C3 /* Starscream */ = { + isa = XCSwiftPackageProductDependency; + package = A5D85224286333D500DAF5C3 /* XCRemoteSwiftPackageReference "Starscream" */; + productName = Starscream; + }; + A5D85227286333E300DAF5C3 /* Starscream */ = { + isa = XCSwiftPackageProductDependency; + package = A5D85224286333D500DAF5C3 /* XCRemoteSwiftPackageReference "Starscream" */; + productName = Starscream; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = 764E1D3426F8D3FC00A1FB15 /* Project object */; diff --git a/Package.swift b/Package.swift index 81ab4860d..4f7f98d12 100644 --- a/Package.swift +++ b/Package.swift @@ -14,9 +14,7 @@ let package = Package( name: "WalletConnect", targets: ["WalletConnectSign"]) ], - dependencies: [ - .package(url: "https://github.com/daltoniam/Starscream.git", .upToNextMajor(from: "3.0.0")) - ], + dependencies: [], targets: [ .target( name: "WalletConnectSign", @@ -28,7 +26,7 @@ let package = Package( path: "Sources/Chat"), .target( name: "WalletConnectRelay", - dependencies: ["WalletConnectUtils", "Starscream", "WalletConnectKMS"], + dependencies: ["WalletConnectUtils", "WalletConnectKMS"], path: "Sources/WalletConnectRelay"), .target( name: "WalletConnectKMS", diff --git a/Sources/WalletConnectRelay/Dispatching.swift b/Sources/WalletConnectRelay/Dispatching.swift index 51b72cdef..e053051ee 100644 --- a/Sources/WalletConnectRelay/Dispatching.swift +++ b/Sources/WalletConnectRelay/Dispatching.swift @@ -1,6 +1,5 @@ import Foundation import WalletConnectUtils -import Starscream protocol Dispatching { var onConnect: (() -> Void)? {get set} @@ -18,10 +17,10 @@ final class Dispatcher: NSObject, Dispatching { var onMessage: ((String) -> Void)? private var textFramesQueue = Queue() private let logger: ConsoleLogging - var socket: WebSocketProtocol + var socket: WebSocketConnecting var socketConnectionHandler: SocketConnectionHandler - init(socket: WebSocketProtocol, + init(socket: WebSocketConnecting, socketConnectionHandler: SocketConnectionHandler, logger: ConsoleLogging) { self.socket = socket diff --git a/Sources/WalletConnectRelay/RelayClient.swift b/Sources/WalletConnectRelay/RelayClient.swift index ce8d255ba..e52d16155 100644 --- a/Sources/WalletConnectRelay/RelayClient.swift +++ b/Sources/WalletConnectRelay/RelayClient.swift @@ -1,7 +1,7 @@ import Foundation import Combine import WalletConnectUtils -import Starscream + public enum SocketConnectionStatus { case connected case disconnected @@ -59,11 +59,12 @@ public final class RelayClient { projectId: String, keyValueStorage: KeyValueStorage = UserDefaults.standard, uniqueIdentifier: String? = nil, + socketImplementation: WebSocketConnecting.Type, socketConnectionType: SocketConnectionType = .automatic, logger: ConsoleLogging = ConsoleLogger(loggingLevel: .off)) { let url = Self.makeRelayUrl(host: relayHost, projectId: projectId) var socketConnectionHandler: SocketConnectionHandler - let socket = WebSocket(url: url) + let socket = socketImplementation.instance(with: url) switch socketConnectionType { case .automatic: socketConnectionHandler = AutomaticSocketConnectionHandler(socket: socket) diff --git a/Sources/WalletConnectRelay/SocketConnectionHandler/ManualSocketConnectionHandler.swift b/Sources/WalletConnectRelay/SocketConnectionHandler/ManualSocketConnectionHandler.swift index ccd3978b4..25f293d05 100644 --- a/Sources/WalletConnectRelay/SocketConnectionHandler/ManualSocketConnectionHandler.swift +++ b/Sources/WalletConnectRelay/SocketConnectionHandler/ManualSocketConnectionHandler.swift @@ -1,4 +1,3 @@ -import Starscream import Foundation class ManualSocketConnectionHandler: SocketConnectionHandler { diff --git a/Sources/WalletConnectRelay/SocketConnectionHandler/SocketConnectionHandler.swift b/Sources/WalletConnectRelay/SocketConnectionHandler/SocketConnectionHandler.swift index dad34f1cd..60059d290 100644 --- a/Sources/WalletConnectRelay/SocketConnectionHandler/SocketConnectionHandler.swift +++ b/Sources/WalletConnectRelay/SocketConnectionHandler/SocketConnectionHandler.swift @@ -1,7 +1,7 @@ import Foundation protocol SocketConnectionHandler { - var socket: WebSocketConnecting {get} + var socket: WebSocketConnecting { get } func handleConnect() throws func handleDisconnect(closeCode: URLSessionWebSocketTask.CloseCode) throws } diff --git a/Sources/WalletConnectRelay/SocketConnectionHandler/WebSocketConnecting.swift b/Sources/WalletConnectRelay/SocketConnectionHandler/WebSocketConnecting.swift index 3ab34e8d4..1b3b46ddf 100644 --- a/Sources/WalletConnectRelay/SocketConnectionHandler/WebSocketConnecting.swift +++ b/Sources/WalletConnectRelay/SocketConnectionHandler/WebSocketConnecting.swift @@ -1,10 +1,14 @@ -import Starscream import Foundation -extension WebSocket: WebSocketConnecting {} +public protocol WebSocketConnecting { + static func instance(with url: URL) -> WebSocketConnecting + + var isConnected: Bool { get } + var onConnect: (() -> Void)? { get set } + var onDisconnect: ((Error?) -> Void)? { get set } + var onText: ((String) -> Void)? { get set } -protocol WebSocketConnecting { - var isConnected: Bool {get} func connect() func disconnect() + func write(string: String, completion: (() -> Void)?) } diff --git a/Sources/WalletConnectRelay/SocketConnectionHandler/WebSocketProtocol.swift b/Sources/WalletConnectRelay/SocketConnectionHandler/WebSocketProtocol.swift deleted file mode 100644 index 3c03a2c83..000000000 --- a/Sources/WalletConnectRelay/SocketConnectionHandler/WebSocketProtocol.swift +++ /dev/null @@ -1,11 +0,0 @@ -import Starscream - -extension WebSocket: WebSocketProtocol {} - -protocol WebSocketProtocol { - var isConnected: Bool {get} - var onConnect: (() -> Void)? { get set } - var onDisconnect: ((Error?) -> Void)? { get set } - var onText: ((String) -> Void)? { get set } - func write(string: String, completion: (() -> Void)?) -} diff --git a/Sources/WalletConnectSign/Sign/Sign.swift b/Sources/WalletConnectSign/Sign/Sign.swift index 8cd067080..aa7d6f025 100644 --- a/Sources/WalletConnectSign/Sign/Sign.swift +++ b/Sources/WalletConnectSign/Sign/Sign.swift @@ -17,13 +17,28 @@ public class Sign { guard let config = Sign.config else { fatalError("Error - you must call configure(_:) before accessing the shared instance.") } - relayClient = RelayClient(relayHost: "relay.walletconnect.com", projectId: config.projectId, socketConnectionType: config.socketConnectionType) + relayClient = RelayClient( + relayHost: "relay.walletconnect.com", + projectId: config.projectId, + socketImplementation: config.socketImplementation, + socketConnectionType: config.socketConnectionType + ) client = SignClient(metadata: config.metadata, relayClient: relayClient) client.delegate = self } - static public func configure(_ config: Config) { - Sign.config = config + static public func configure( + metadata: AppMetadata, + projectId: String, + socketImplementation: WebSocketConnecting.Type, + socketConnectionType: SocketConnectionType = .automatic + ) { + Sign.config = Sign.Config( + metadata: metadata, + projectId: projectId, + socketImplementation: socketImplementation, + socketConnectionType: socketConnectionType + ) } var sessionProposalPublisherSubject = PassthroughSubject() diff --git a/Sources/WalletConnectSign/Sign/SignClient.swift b/Sources/WalletConnectSign/Sign/SignClient.swift index 9659ef9d6..5faebefed 100644 --- a/Sources/WalletConnectSign/Sign/SignClient.swift +++ b/Sources/WalletConnectSign/Sign/SignClient.swift @@ -48,15 +48,15 @@ public final class SignClient { /// - keyValueStorage: by default WalletConnect SDK will store sequences in UserDefaults /// /// WalletConnect Client is not a singleton but once you create an instance, you should not deinitialize it. Usually only one instance of a client is required in the application. - public convenience init(metadata: AppMetadata, projectId: String, relayHost: String, keyValueStorage: KeyValueStorage = UserDefaults.standard) { - self.init(metadata: metadata, projectId: projectId, relayHost: relayHost, logger: ConsoleLogger(loggingLevel: .off), kms: KeyManagementService(serviceIdentifier: "com.walletconnect.sdk"), keyValueStorage: keyValueStorage) + public convenience init(metadata: AppMetadata, projectId: String, relayHost: String, socketImplementation: WebSocketConnecting.Type, keyValueStorage: KeyValueStorage = UserDefaults.standard) { + self.init(metadata: metadata, projectId: projectId, relayHost: relayHost, logger: ConsoleLogger(loggingLevel: .off), kms: KeyManagementService(serviceIdentifier: "com.walletconnect.sdk"), keyValueStorage: keyValueStorage, socketImplementation: socketImplementation) } - init(metadata: AppMetadata, projectId: String, relayHost: String, logger: ConsoleLogging, kms: KeyManagementService, keyValueStorage: KeyValueStorage) { + init(metadata: AppMetadata, projectId: String, relayHost: String, logger: ConsoleLogging, kms: KeyManagementService, keyValueStorage: KeyValueStorage, socketImplementation: WebSocketConnecting.Type) { self.metadata = metadata self.logger = logger self.kms = kms - let relayClient = RelayClient(relayHost: relayHost, projectId: projectId, keyValueStorage: keyValueStorage, logger: logger) + let relayClient = RelayClient(relayHost: relayHost, projectId: projectId, keyValueStorage: keyValueStorage, socketImplementation: socketImplementation, logger: logger) let serializer = Serializer(kms: kms) self.history = JsonRpcHistory(logger: logger, keyValueStore: CodableStore(defaults: keyValueStorage, identifier: StorageDomainIdentifiers.jsonRpcHistory.rawValue)) self.networkingInteractor = NetworkInteractor(relayClient: relayClient, serializer: serializer, logger: logger, jsonRpcHistory: history) diff --git a/Sources/WalletConnectSign/Sign/SignConfig.swift b/Sources/WalletConnectSign/Sign/SignConfig.swift index 09e84e788..7f92cc125 100644 --- a/Sources/WalletConnectSign/Sign/SignConfig.swift +++ b/Sources/WalletConnectSign/Sign/SignConfig.swift @@ -5,11 +5,18 @@ public extension Sign { struct Config { let metadata: AppMetadata let projectId: String + let socketImplementation: WebSocketConnecting.Type let socketConnectionType: SocketConnectionType - public init(metadata: AppMetadata, projectId: String, socketConnectionType: SocketConnectionType = .automatic) { + public init( + metadata: AppMetadata, + projectId: String, + socketImplementation: WebSocketConnecting.Type, + socketConnectionType: SocketConnectionType = .automatic + ) { self.metadata = metadata self.projectId = projectId + self.socketImplementation = socketImplementation self.socketConnectionType = socketConnectionType } } diff --git a/Tests/RelayerTests/RelayClientEndToEndTests.swift b/Tests/RelayerTests/RelayClientEndToEndTests.swift index 0a15b2fa1..8dd28e5a5 100644 --- a/Tests/RelayerTests/RelayClientEndToEndTests.swift +++ b/Tests/RelayerTests/RelayClientEndToEndTests.swift @@ -4,7 +4,6 @@ import XCTest import WalletConnectUtils import TestingUtils @testable import WalletConnectRelay -import Starscream final class RelayClientEndToEndTests: XCTestCase { From 6ba0dec4157f0b60baa2a34390870318bd0d25ec Mon Sep 17 00:00:00 2001 From: Artur Guseinov Date: Wed, 22 Jun 2022 18:23:07 +0500 Subject: [PATCH 2/9] WebSocket Factory --- Example/DApp/SceneDelegate.swift | 8 +++++--- Example/ExampleApp/SceneDelegate.swift | 13 ++++++++++++- Package.swift | 6 ++++-- Sources/WalletConnectRelay/RelayClient.swift | 4 ++-- .../{WebSocketConnecting.swift => WebSocket.swift} | 6 ++++-- Sources/WalletConnectSign/Sign/Sign.swift | 6 +++--- Sources/WalletConnectSign/Sign/SignClient.swift | 8 ++++---- Sources/WalletConnectSign/Sign/SignConfig.swift | 6 +++--- Tests/ChatTests/EndToEndTests.swift | 2 +- Tests/IntegrationTests/SignClientTests.swift | 3 ++- Tests/RelayerTests/DispatcherTests.swift | 2 +- Tests/RelayerTests/RelayClientEndToEndTests.swift | 1 + Tests/TestingUtils/WebSocketFactory.swift | 14 ++++++++++++++ 13 files changed, 56 insertions(+), 23 deletions(-) rename Sources/WalletConnectRelay/SocketConnectionHandler/{WebSocketConnecting.swift => WebSocket.swift} (78%) create mode 100644 Tests/TestingUtils/WebSocketFactory.swift diff --git a/Example/DApp/SceneDelegate.swift b/Example/DApp/SceneDelegate.swift index f32efeaa7..5e2d51a82 100644 --- a/Example/DApp/SceneDelegate.swift +++ b/Example/DApp/SceneDelegate.swift @@ -4,8 +4,10 @@ import WalletConnectRelay import Combine import Starscream -extension WebSocket: WebSocketConnecting { - public static func instance(with url: URL) -> WebSocketConnecting { +extension WebSocket: WebSocketConnecting { } + +struct SocketFactory: WebSocketFactory { + func create(with url: URL) -> WebSocketConnecting { return WebSocket(url: url) } } @@ -27,7 +29,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { url: "wallet.connect", icons: ["https://avatars.githubusercontent.com/u/37784886"]) - Sign.configure(metadata: metadata, projectId: "8ba9ee138960775e5231b70cc5ef1c3a", socketImplementation: WebSocket.self) + Sign.configure(metadata: metadata, projectId: "8ba9ee138960775e5231b70cc5ef1c3a", socketFactory: SocketFactory()) if CommandLine.arguments.contains("-cleanInstall") { try? Sign.instance.cleanup() diff --git a/Example/ExampleApp/SceneDelegate.swift b/Example/ExampleApp/SceneDelegate.swift index 0d6bebcf3..a0dd1b2d6 100644 --- a/Example/ExampleApp/SceneDelegate.swift +++ b/Example/ExampleApp/SceneDelegate.swift @@ -1,5 +1,15 @@ import UIKit import WalletConnectSign +import WalletConnectRelay +import Starscream + +extension WebSocket: WebSocketConnecting { } + +struct SocketFactory: WebSocketFactory { + func create(with url: URL) -> WebSocketConnecting { + return WebSocket(url: url) + } +} class SceneDelegate: UIResponder, UIWindowSceneDelegate { @@ -12,7 +22,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { description: "wallet description", url: "example.wallet", icons: ["https://avatars.githubusercontent.com/u/37784886"]) - Sign.configure(Sign.Config(metadata: metadata, projectId: "8ba9ee138960775e5231b70cc5ef1c3a")) + + Sign.configure(metadata: metadata, projectId: "8ba9ee138960775e5231b70cc5ef1c3a", socketFactory: SocketFactory()) if CommandLine.arguments.contains("-cleanInstall") { try? Sign.instance.cleanup() diff --git a/Package.swift b/Package.swift index 4f7f98d12..1c1ec5aaa 100644 --- a/Package.swift +++ b/Package.swift @@ -14,7 +14,9 @@ let package = Package( name: "WalletConnect", targets: ["WalletConnectSign"]) ], - dependencies: [], + dependencies: [ + .package(url: "https://github.com/daltoniam/Starscream.git", .upToNextMajor(from: "3.0.0")) + ], targets: [ .target( name: "WalletConnectSign", @@ -58,7 +60,7 @@ let package = Package( dependencies: ["WalletConnectKMS", "WalletConnectUtils", "TestingUtils"]), .target( name: "TestingUtils", - dependencies: ["WalletConnectUtils", "WalletConnectKMS"], + dependencies: ["WalletConnectUtils", "WalletConnectKMS", "Starscream", "WalletConnectRelay"], path: "Tests/TestingUtils"), .testTarget( name: "WalletConnectUtilsTests", diff --git a/Sources/WalletConnectRelay/RelayClient.swift b/Sources/WalletConnectRelay/RelayClient.swift index e52d16155..50cbaa19f 100644 --- a/Sources/WalletConnectRelay/RelayClient.swift +++ b/Sources/WalletConnectRelay/RelayClient.swift @@ -59,12 +59,12 @@ public final class RelayClient { projectId: String, keyValueStorage: KeyValueStorage = UserDefaults.standard, uniqueIdentifier: String? = nil, - socketImplementation: WebSocketConnecting.Type, + socketFactory: WebSocketFactory, socketConnectionType: SocketConnectionType = .automatic, logger: ConsoleLogging = ConsoleLogger(loggingLevel: .off)) { let url = Self.makeRelayUrl(host: relayHost, projectId: projectId) var socketConnectionHandler: SocketConnectionHandler - let socket = socketImplementation.instance(with: url) + let socket = socketFactory.create(with: url) switch socketConnectionType { case .automatic: socketConnectionHandler = AutomaticSocketConnectionHandler(socket: socket) diff --git a/Sources/WalletConnectRelay/SocketConnectionHandler/WebSocketConnecting.swift b/Sources/WalletConnectRelay/SocketConnectionHandler/WebSocket.swift similarity index 78% rename from Sources/WalletConnectRelay/SocketConnectionHandler/WebSocketConnecting.swift rename to Sources/WalletConnectRelay/SocketConnectionHandler/WebSocket.swift index 1b3b46ddf..57e1cfeb1 100644 --- a/Sources/WalletConnectRelay/SocketConnectionHandler/WebSocketConnecting.swift +++ b/Sources/WalletConnectRelay/SocketConnectionHandler/WebSocket.swift @@ -1,8 +1,6 @@ import Foundation public protocol WebSocketConnecting { - static func instance(with url: URL) -> WebSocketConnecting - var isConnected: Bool { get } var onConnect: (() -> Void)? { get set } var onDisconnect: ((Error?) -> Void)? { get set } @@ -12,3 +10,7 @@ public protocol WebSocketConnecting { func disconnect() func write(string: String, completion: (() -> Void)?) } + +public protocol WebSocketFactory { + func create(with url: URL) -> WebSocketConnecting +} diff --git a/Sources/WalletConnectSign/Sign/Sign.swift b/Sources/WalletConnectSign/Sign/Sign.swift index aa7d6f025..f5eb6e5dc 100644 --- a/Sources/WalletConnectSign/Sign/Sign.swift +++ b/Sources/WalletConnectSign/Sign/Sign.swift @@ -20,7 +20,7 @@ public class Sign { relayClient = RelayClient( relayHost: "relay.walletconnect.com", projectId: config.projectId, - socketImplementation: config.socketImplementation, + socketFactory: config.socketFactory, socketConnectionType: config.socketConnectionType ) client = SignClient(metadata: config.metadata, relayClient: relayClient) @@ -30,13 +30,13 @@ public class Sign { static public func configure( metadata: AppMetadata, projectId: String, - socketImplementation: WebSocketConnecting.Type, + socketFactory: WebSocketFactory, socketConnectionType: SocketConnectionType = .automatic ) { Sign.config = Sign.Config( metadata: metadata, projectId: projectId, - socketImplementation: socketImplementation, + socketFactory: socketFactory, socketConnectionType: socketConnectionType ) } diff --git a/Sources/WalletConnectSign/Sign/SignClient.swift b/Sources/WalletConnectSign/Sign/SignClient.swift index 5faebefed..e94b9a629 100644 --- a/Sources/WalletConnectSign/Sign/SignClient.swift +++ b/Sources/WalletConnectSign/Sign/SignClient.swift @@ -48,15 +48,15 @@ public final class SignClient { /// - keyValueStorage: by default WalletConnect SDK will store sequences in UserDefaults /// /// WalletConnect Client is not a singleton but once you create an instance, you should not deinitialize it. Usually only one instance of a client is required in the application. - public convenience init(metadata: AppMetadata, projectId: String, relayHost: String, socketImplementation: WebSocketConnecting.Type, keyValueStorage: KeyValueStorage = UserDefaults.standard) { - self.init(metadata: metadata, projectId: projectId, relayHost: relayHost, logger: ConsoleLogger(loggingLevel: .off), kms: KeyManagementService(serviceIdentifier: "com.walletconnect.sdk"), keyValueStorage: keyValueStorage, socketImplementation: socketImplementation) + public convenience init(metadata: AppMetadata, projectId: String, relayHost: String, socketFactory: WebSocketFactory, keyValueStorage: KeyValueStorage = UserDefaults.standard) { + self.init(metadata: metadata, projectId: projectId, relayHost: relayHost, logger: ConsoleLogger(loggingLevel: .off), kms: KeyManagementService(serviceIdentifier: "com.walletconnect.sdk"), keyValueStorage: keyValueStorage, socketFactory: socketFactory) } - init(metadata: AppMetadata, projectId: String, relayHost: String, logger: ConsoleLogging, kms: KeyManagementService, keyValueStorage: KeyValueStorage, socketImplementation: WebSocketConnecting.Type) { + init(metadata: AppMetadata, projectId: String, relayHost: String, logger: ConsoleLogging, kms: KeyManagementService, keyValueStorage: KeyValueStorage, socketFactory: WebSocketFactory) { self.metadata = metadata self.logger = logger self.kms = kms - let relayClient = RelayClient(relayHost: relayHost, projectId: projectId, keyValueStorage: keyValueStorage, socketImplementation: socketImplementation, logger: logger) + let relayClient = RelayClient(relayHost: relayHost, projectId: projectId, keyValueStorage: keyValueStorage, socketFactory: socketFactory, logger: logger) let serializer = Serializer(kms: kms) self.history = JsonRpcHistory(logger: logger, keyValueStore: CodableStore(defaults: keyValueStorage, identifier: StorageDomainIdentifiers.jsonRpcHistory.rawValue)) self.networkingInteractor = NetworkInteractor(relayClient: relayClient, serializer: serializer, logger: logger, jsonRpcHistory: history) diff --git a/Sources/WalletConnectSign/Sign/SignConfig.swift b/Sources/WalletConnectSign/Sign/SignConfig.swift index 7f92cc125..b6167c473 100644 --- a/Sources/WalletConnectSign/Sign/SignConfig.swift +++ b/Sources/WalletConnectSign/Sign/SignConfig.swift @@ -5,18 +5,18 @@ public extension Sign { struct Config { let metadata: AppMetadata let projectId: String - let socketImplementation: WebSocketConnecting.Type + let socketFactory: WebSocketFactory let socketConnectionType: SocketConnectionType public init( metadata: AppMetadata, projectId: String, - socketImplementation: WebSocketConnecting.Type, + socketFactory: WebSocketFactory, socketConnectionType: SocketConnectionType = .automatic ) { self.metadata = metadata self.projectId = projectId - self.socketImplementation = socketImplementation + self.socketFactory = socketFactory self.socketConnectionType = socketConnectionType } } diff --git a/Tests/ChatTests/EndToEndTests.swift b/Tests/ChatTests/EndToEndTests.swift index f6b5ab1d8..8fff8a4a5 100644 --- a/Tests/ChatTests/EndToEndTests.swift +++ b/Tests/ChatTests/EndToEndTests.swift @@ -42,7 +42,7 @@ final class ChatTests: XCTestCase { let logger = ConsoleLogger(suffix: prefix, loggingLevel: .debug) let relayHost = "dev.relay.walletconnect.com" let projectId = "8ba9ee138960775e5231b70cc5ef1c3a" - let relayClient = RelayClient(relayHost: relayHost, projectId: projectId, logger: logger) + let relayClient = RelayClient(relayHost: relayHost, projectId: projectId, socketFactory: SocketFactory(), logger: logger) let keychain = KeychainStorage(keychainService: KeychainServiceFake(), serviceIdentifier: "") return Chat(registry: registry, relayClient: relayClient, kms: KeyManagementService(keychain: keychain), logger: logger, keyValueStorage: RuntimeKeyValueStorage()) diff --git a/Tests/IntegrationTests/SignClientTests.swift b/Tests/IntegrationTests/SignClientTests.swift index 8e1a8818d..d992a98c3 100644 --- a/Tests/IntegrationTests/SignClientTests.swift +++ b/Tests/IntegrationTests/SignClientTests.swift @@ -24,7 +24,8 @@ final class SignClientTests: XCTestCase { relayHost: relayHost, logger: logger, kms: KeyManagementService(keychain: keychain), - keyValueStorage: RuntimeKeyValueStorage()) + keyValueStorage: RuntimeKeyValueStorage(), + socketFactory: SocketFactory()) return ClientDelegate(client: client) } diff --git a/Tests/RelayerTests/DispatcherTests.swift b/Tests/RelayerTests/DispatcherTests.swift index ab9cd914c..dca347dd8 100644 --- a/Tests/RelayerTests/DispatcherTests.swift +++ b/Tests/RelayerTests/DispatcherTests.swift @@ -3,7 +3,7 @@ import XCTest @testable import WalletConnectRelay import TestingUtils -class WebSocketMock: WebSocketProtocol, WebSocketConnecting { +class WebSocketMock: WebSocketConnecting { var onText: ((String) -> Void)? var onConnect: (() -> Void)? var onDisconnect: ((Error?) -> Void)? diff --git a/Tests/RelayerTests/RelayClientEndToEndTests.swift b/Tests/RelayerTests/RelayClientEndToEndTests.swift index 8dd28e5a5..140e79de5 100644 --- a/Tests/RelayerTests/RelayClientEndToEndTests.swift +++ b/Tests/RelayerTests/RelayClientEndToEndTests.swift @@ -3,6 +3,7 @@ import Combine import XCTest import WalletConnectUtils import TestingUtils +import Starscream @testable import WalletConnectRelay final class RelayClientEndToEndTests: XCTestCase { diff --git a/Tests/TestingUtils/WebSocketFactory.swift b/Tests/TestingUtils/WebSocketFactory.swift new file mode 100644 index 000000000..22f45a8cb --- /dev/null +++ b/Tests/TestingUtils/WebSocketFactory.swift @@ -0,0 +1,14 @@ +import Foundation +import Starscream +import WalletConnectRelay + +extension WebSocket: WebSocketConnecting { } + +public struct SocketFactory: WebSocketFactory { + + public init() { } + + public func create(with url: URL) -> WebSocketConnecting { + return WebSocket(url: url) + } +} From 4b9ceb4419bb1db64e1dd80d0d4440e8ef1c1945 Mon Sep 17 00:00:00 2001 From: Artur Guseinov Date: Thu, 23 Jun 2022 14:05:18 +0500 Subject: [PATCH 3/9] Dapp and Wallet tests removed --- Example/DappTests/DappTests.swift | 35 --- Example/ExampleApp.xcodeproj/project.pbxproj | 251 ------------------- Example/WalletTests/WalletTests.swift | 35 --- 3 files changed, 321 deletions(-) delete mode 100644 Example/DappTests/DappTests.swift delete mode 100644 Example/WalletTests/WalletTests.swift diff --git a/Example/DappTests/DappTests.swift b/Example/DappTests/DappTests.swift deleted file mode 100644 index 2792b20c0..000000000 --- a/Example/DappTests/DappTests.swift +++ /dev/null @@ -1,35 +0,0 @@ -// -// DappTests.swift -// DappTests -// -// Created by Admin on 27/01/2022. -// - -import XCTest - -class DappTests: XCTestCase { - - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - func testExample() throws { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. - // Any test you write for XCTest can be annotated as throws and async. - // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. - // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. - } - - func testPerformanceExample() throws { - // This is an example of a performance test case. - measure { - // Put the code you want to measure the time of here. - } - } - -} diff --git a/Example/ExampleApp.xcodeproj/project.pbxproj b/Example/ExampleApp.xcodeproj/project.pbxproj index 7dcbb6218..536050959 100644 --- a/Example/ExampleApp.xcodeproj/project.pbxproj +++ b/Example/ExampleApp.xcodeproj/project.pbxproj @@ -43,8 +43,6 @@ 84CE644E279ED2FF00142511 /* SelectChainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84CE644D279ED2FF00142511 /* SelectChainView.swift */; }; 84CE6452279ED42B00142511 /* ConnectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84CE6451279ED42B00142511 /* ConnectView.swift */; }; 84CE645527A29D4D00142511 /* ResponseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84CE645427A29D4C00142511 /* ResponseViewController.swift */; }; - 84CE646127A2C85B00142511 /* DappTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84CE646027A2C85B00142511 /* DappTests.swift */; }; - 84CE647027A2CD6B00142511 /* WalletTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84CE646F27A2CD6B00142511 /* WalletTests.swift */; }; 84F568C2279582D200D0A289 /* Signer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F568C1279582D200D0A289 /* Signer.swift */; }; 84F568C42795832A00D0A289 /* EthereumTransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F568C32795832A00D0A289 /* EthereumTransaction.swift */; }; A5A4FC56283CBB7800BBEC1E /* SessionDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A4FC55283CBB7800BBEC1E /* SessionDetailView.swift */; }; @@ -65,27 +63,6 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 84CE646227A2C85B00142511 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 764E1D3426F8D3FC00A1FB15 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 764E1D3B26F8D3FC00A1FB15; - remoteInfo = Wallet; - }; - 84CE646727A2C86100142511 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 764E1D3426F8D3FC00A1FB15 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 84CE641B27981DED00142511; - remoteInfo = DApp; - }; - 84CE647127A2CD6B00142511 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 764E1D3426F8D3FC00A1FB15 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 764E1D3B26F8D3FC00A1FB15; - remoteInfo = Wallet; - }; A5A4FC7D2840C5D400BBEC1E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 764E1D3426F8D3FC00A1FB15 /* Project object */; @@ -143,10 +120,6 @@ 84CE6451279ED42B00142511 /* ConnectView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectView.swift; sourceTree = ""; }; 84CE6453279FFE1100142511 /* Wallet.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Wallet.entitlements; sourceTree = ""; }; 84CE645427A29D4C00142511 /* ResponseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResponseViewController.swift; sourceTree = ""; }; - 84CE645E27A2C85B00142511 /* DappTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DappTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 84CE646027A2C85B00142511 /* DappTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DappTests.swift; sourceTree = ""; }; - 84CE646D27A2CD6B00142511 /* WalletTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WalletTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 84CE646F27A2CD6B00142511 /* WalletTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletTests.swift; sourceTree = ""; }; 84F568C1279582D200D0A289 /* Signer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Signer.swift; sourceTree = ""; }; 84F568C32795832A00D0A289 /* EthereumTransaction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EthereumTransaction.swift; sourceTree = ""; }; A5A4FC55283CBB7800BBEC1E /* SessionDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionDetailView.swift; sourceTree = ""; }; @@ -186,20 +159,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 84CE645B27A2C85B00142511 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 84CE646A27A2CD6B00142511 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; A5A4FC6F2840C12C00BBEC1E /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -253,8 +212,6 @@ 84CE6453279FFE1100142511 /* Wallet.entitlements */, 764E1D3E26F8D3FC00A1FB15 /* ExampleApp */, 84CE641D27981DED00142511 /* DApp */, - 84CE645F27A2C85B00142511 /* DappTests */, - 84CE646E27A2CD6B00142511 /* WalletTests */, A5A4FC732840C12C00BBEC1E /* UITests */, 764E1D3D26F8D3FC00A1FB15 /* Products */, 764E1D5326F8DAC800A1FB15 /* Frameworks */, @@ -267,8 +224,6 @@ children = ( 764E1D3C26F8D3FC00A1FB15 /* WalletConnect Wallet.app */, 84CE641C27981DED00142511 /* DApp.app */, - 84CE645E27A2C85B00142511 /* DappTests.xctest */, - 84CE646D27A2CD6B00142511 /* WalletTests.xctest */, A5A4FC722840C12C00BBEC1E /* UITests.xctest */, ); name = Products; @@ -373,22 +328,6 @@ path = Connect; sourceTree = ""; }; - 84CE645F27A2C85B00142511 /* DappTests */ = { - isa = PBXGroup; - children = ( - 84CE646027A2C85B00142511 /* DappTests.swift */, - ); - path = DappTests; - sourceTree = ""; - }; - 84CE646E27A2CD6B00142511 /* WalletTests */ = { - isa = PBXGroup; - children = ( - 84CE646F27A2CD6B00142511 /* WalletTests.swift */, - ); - path = WalletTests; - sourceTree = ""; - }; A5A4FC732840C12C00BBEC1E /* UITests */ = { isa = PBXGroup; children = ( @@ -475,43 +414,6 @@ productReference = 84CE641C27981DED00142511 /* DApp.app */; productType = "com.apple.product-type.application"; }; - 84CE645D27A2C85B00142511 /* DappTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 84CE646427A2C85B00142511 /* Build configuration list for PBXNativeTarget "DappTests" */; - buildPhases = ( - 84CE645A27A2C85B00142511 /* Sources */, - 84CE645B27A2C85B00142511 /* Frameworks */, - 84CE645C27A2C85B00142511 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 84CE646327A2C85B00142511 /* PBXTargetDependency */, - 84CE646827A2C86100142511 /* PBXTargetDependency */, - ); - name = DappTests; - productName = DappTests; - productReference = 84CE645E27A2C85B00142511 /* DappTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 84CE646C27A2CD6B00142511 /* WalletTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 84CE647327A2CD6C00142511 /* Build configuration list for PBXNativeTarget "WalletTests" */; - buildPhases = ( - 84CE646927A2CD6B00142511 /* Sources */, - 84CE646A27A2CD6B00142511 /* Frameworks */, - 84CE646B27A2CD6B00142511 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 84CE647227A2CD6B00142511 /* PBXTargetDependency */, - ); - name = WalletTests; - productName = WalletTests; - productReference = 84CE646D27A2CD6B00142511 /* WalletTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; A5A4FC712840C12C00BBEC1E /* UITests */ = { isa = PBXNativeTarget; buildConfigurationList = A5A4FC7A2840C12C00BBEC1E /* Build configuration list for PBXNativeTarget "UITests" */; @@ -546,14 +448,6 @@ 84CE641B27981DED00142511 = { CreatedOnToolsVersion = 13.2; }; - 84CE645D27A2C85B00142511 = { - CreatedOnToolsVersion = 13.2; - TestTargetID = 84CE641B27981DED00142511; - }; - 84CE646C27A2CD6B00142511 = { - CreatedOnToolsVersion = 13.2; - TestTargetID = 764E1D3B26F8D3FC00A1FB15; - }; A5A4FC712840C12C00BBEC1E = { CreatedOnToolsVersion = 13.3; }; @@ -578,8 +472,6 @@ targets = ( 764E1D3B26F8D3FC00A1FB15 /* Wallet */, 84CE641B27981DED00142511 /* DApp */, - 84CE645D27A2C85B00142511 /* DappTests */, - 84CE646C27A2CD6B00142511 /* WalletTests */, A5A4FC712840C12C00BBEC1E /* UITests */, ); }; @@ -604,20 +496,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 84CE645C27A2C85B00142511 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 84CE646B27A2CD6B00142511 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; A5A4FC702840C12C00BBEC1E /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -677,22 +555,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 84CE645A27A2C85B00142511 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 84CE646127A2C85B00142511 /* DappTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 84CE646927A2CD6B00142511 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 84CE647027A2CD6B00142511 /* WalletTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; A5A4FC6E2840C12C00BBEC1E /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -711,21 +573,6 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 84CE646327A2C85B00142511 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 764E1D3B26F8D3FC00A1FB15 /* Wallet */; - targetProxy = 84CE646227A2C85B00142511 /* PBXContainerItemProxy */; - }; - 84CE646827A2C86100142511 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 84CE641B27981DED00142511 /* DApp */; - targetProxy = 84CE646727A2C86100142511 /* PBXContainerItemProxy */; - }; - 84CE647227A2CD6B00142511 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 764E1D3B26F8D3FC00A1FB15 /* Wallet */; - targetProxy = 84CE647127A2CD6B00142511 /* PBXContainerItemProxy */; - }; A5A4FC7E2840C5D400BBEC1E /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 84CE641B27981DED00142511 /* DApp */; @@ -992,86 +839,6 @@ }; name = Release; }; - 84CE646527A2C85B00142511 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = W5R8AG9K22; - GENERATE_INFOPLIST_FILE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = walletconnect.DappTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_EMIT_LOC_STRINGS = NO; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DApp.app/DApp"; - }; - name = Debug; - }; - 84CE646627A2C85B00142511 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = W5R8AG9K22; - GENERATE_INFOPLIST_FILE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = walletconnect.DappTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_EMIT_LOC_STRINGS = NO; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DApp.app/DApp"; - }; - name = Release; - }; - 84CE647427A2CD6C00142511 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = W5R8AG9K22; - GENERATE_INFOPLIST_FILE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = walletconnect.WalletTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_EMIT_LOC_STRINGS = NO; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WalletConnect Wallet.app/WalletConnect Wallet"; - }; - name = Debug; - }; - 84CE647527A2CD6C00142511 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = W5R8AG9K22; - GENERATE_INFOPLIST_FILE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = walletconnect.WalletTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_EMIT_LOC_STRINGS = NO; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WalletConnect Wallet.app/WalletConnect Wallet"; - }; - name = Release; - }; A5A4FC782840C12C00BBEC1E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -1140,24 +907,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 84CE646427A2C85B00142511 /* Build configuration list for PBXNativeTarget "DappTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 84CE646527A2C85B00142511 /* Debug */, - 84CE646627A2C85B00142511 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 84CE647327A2CD6C00142511 /* Build configuration list for PBXNativeTarget "WalletTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 84CE647427A2CD6C00142511 /* Debug */, - 84CE647527A2CD6C00142511 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; A5A4FC7A2840C12C00BBEC1E /* Build configuration list for PBXNativeTarget "UITests" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/Example/WalletTests/WalletTests.swift b/Example/WalletTests/WalletTests.swift deleted file mode 100644 index a248726c3..000000000 --- a/Example/WalletTests/WalletTests.swift +++ /dev/null @@ -1,35 +0,0 @@ -// -// WalletTests.swift -// WalletTests -// -// Created by Admin on 27/01/2022. -// - -import XCTest - -class WalletTests: XCTestCase { - - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - func testExample() throws { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. - // Any test you write for XCTest can be annotated as throws and async. - // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. - // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. - } - - func testPerformanceExample() throws { - // This is an example of a performance test case. - measure { - // Put the code you want to measure the time of here. - } - } - -} From 7c4fd3647267a1135e38b20e882d4d824f6ea642 Mon Sep 17 00:00:00 2001 From: Artur Guseinov Date: Thu, 23 Jun 2022 15:02:33 +0500 Subject: [PATCH 4/9] Separate integration tests from SDK --- .github/workflows/swift.yml | 2 + Example/ExampleApp.xcodeproj/project.pbxproj | 188 ++++++++++++++++++ .../xcschemes/IntegrationTests.xcscheme | 8 +- .../IntegrationTests/Chat/ChatTests.swift | 3 +- .../Relay}/RelayClientEndToEndTests.swift | 2 +- .../Sign}/ClientDelegate.swift | 0 .../Sign}/SignClientTests.swift | 3 +- .../Stubs}/KeychainServiceFake.swift | 18 +- .../IntegrationTests/Stubs}/Stubs.swift | 0 .../Stubs}/WebSocketFactory.swift | 0 Package.swift | 19 +- .../Mocks/KeychainServiceFake.swift | 2 +- .../KeychainStorageTests.swift | 1 + .../SerialiserTests.swift | 2 - 14 files changed, 220 insertions(+), 28 deletions(-) rename {.swiftpm/xcode => Example/ExampleApp.xcodeproj}/xcshareddata/xcschemes/IntegrationTests.xcscheme (87%) rename Tests/ChatTests/EndToEndTests.swift => Example/IntegrationTests/Chat/ChatTests.swift (97%) rename {Tests/RelayerTests => Example/IntegrationTests/Relay}/RelayClientEndToEndTests.swift (98%) rename {Tests/IntegrationTests => Example/IntegrationTests/Sign}/ClientDelegate.swift (100%) rename {Tests/IntegrationTests => Example/IntegrationTests/Sign}/SignClientTests.swift (99%) rename {Tests/WalletConnectKMSTests => Example/IntegrationTests/Stubs}/KeychainServiceFake.swift (80%) rename {Tests/IntegrationTests/Helpers => Example/IntegrationTests/Stubs}/Stubs.swift (100%) rename {Tests/TestingUtils => Example/IntegrationTests/Stubs}/WebSocketFactory.swift (100%) rename Tests/{IntegrationTests => WalletConnectKMSTests}/SerialiserTests.swift (99%) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 257ebc38a..dc8c14213 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -31,6 +31,8 @@ jobs: run: swift build -v - name: Run tests run: swift test -v + - name: Run integration tests + run: xcodebuild -project Example/ExampleApp.xcodeproj -scheme IntegrationTests -destination 'platform=iOS Simulator,name=iPhone 13' test # Example app builds - name: Build Example Wallet diff --git a/Example/ExampleApp.xcodeproj/project.pbxproj b/Example/ExampleApp.xcodeproj/project.pbxproj index 536050959..8b0e5acb9 100644 --- a/Example/ExampleApp.xcodeproj/project.pbxproj +++ b/Example/ExampleApp.xcodeproj/project.pbxproj @@ -45,6 +45,7 @@ 84CE645527A29D4D00142511 /* ResponseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84CE645427A29D4C00142511 /* ResponseViewController.swift */; }; 84F568C2279582D200D0A289 /* Signer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F568C1279582D200D0A289 /* Signer.swift */; }; 84F568C42795832A00D0A289 /* EthereumTransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F568C32795832A00D0A289 /* EthereumTransaction.swift */; }; + A50FFDBD286473D500F76E06 /* TestingUtils in Frameworks */ = {isa = PBXBuildFile; productRef = A50FFDBC286473D500F76E06 /* TestingUtils */; }; A5A4FC56283CBB7800BBEC1E /* SessionDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A4FC55283CBB7800BBEC1E /* SessionDetailView.swift */; }; A5A4FC58283CBB9F00BBEC1E /* SessionDetailViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A4FC57283CBB9F00BBEC1E /* SessionDetailViewModel.swift */; }; A5A4FC5A283CC08600BBEC1E /* SessionNamespaceViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A4FC59283CC08600BBEC1E /* SessionNamespaceViewModel.swift */; }; @@ -53,6 +54,16 @@ A5A4FC772840C12C00BBEC1E /* RegressionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A4FC762840C12C00BBEC1E /* RegressionTests.swift */; }; A5D85226286333D500DAF5C3 /* Starscream in Frameworks */ = {isa = PBXBuildFile; productRef = A5D85225286333D500DAF5C3 /* Starscream */; }; A5D85228286333E300DAF5C3 /* Starscream in Frameworks */ = {isa = PBXBuildFile; productRef = A5D85227286333E300DAF5C3 /* Starscream */; }; + A5E03DF52864651200888481 /* Starscream in Frameworks */ = {isa = PBXBuildFile; productRef = A5E03DF42864651200888481 /* Starscream */; }; + A5E03DFA286465C700888481 /* SignClientTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E03DF9286465C700888481 /* SignClientTests.swift */; }; + A5E03DFB286465C700888481 /* ClientDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E03DF8286465C700888481 /* ClientDelegate.swift */; }; + A5E03DFD286465D100888481 /* Stubs.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E03DFC286465D100888481 /* Stubs.swift */; }; + A5E03DFF2864662500888481 /* WalletConnect in Frameworks */ = {isa = PBXBuildFile; productRef = A5E03DFE2864662500888481 /* WalletConnect */; }; + A5E03E01286466EA00888481 /* WalletConnectChat in Frameworks */ = {isa = PBXBuildFile; productRef = A5E03E00286466EA00888481 /* WalletConnectChat */; }; + A5E03E03286466F400888481 /* ChatTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E03E02286466F400888481 /* ChatTests.swift */; }; + A5E03E0D28646AD200888481 /* RelayClientEndToEndTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E03E0C28646AD200888481 /* RelayClientEndToEndTests.swift */; }; + A5E03E0F28646D8A00888481 /* WebSocketFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E03E0E28646D8A00888481 /* WebSocketFactory.swift */; }; + A5E03E1128646F8000888481 /* KeychainServiceFake.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E03E1028646F8000888481 /* KeychainServiceFake.swift */; }; A5E22D1A2840C62A00E36487 /* Engine.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E22D192840C62A00E36487 /* Engine.swift */; }; A5E22D1C2840C85D00E36487 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E22D1B2840C85D00E36487 /* App.swift */; }; A5E22D1E2840C8BF00E36487 /* RoutingEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E22D1D2840C8BF00E36487 /* RoutingEngine.swift */; }; @@ -129,6 +140,14 @@ A5A4FC5D283D23CA00BBEC1E /* Array.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Array.swift; sourceTree = ""; }; A5A4FC722840C12C00BBEC1E /* UITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; A5A4FC762840C12C00BBEC1E /* RegressionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegressionTests.swift; sourceTree = ""; }; + A5E03DED286464DB00888481 /* IntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = IntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + A5E03DF8286465C700888481 /* ClientDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientDelegate.swift; sourceTree = ""; }; + A5E03DF9286465C700888481 /* SignClientTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignClientTests.swift; sourceTree = ""; }; + A5E03DFC286465D100888481 /* Stubs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Stubs.swift; sourceTree = ""; }; + A5E03E02286466F400888481 /* ChatTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatTests.swift; sourceTree = ""; }; + A5E03E0C28646AD200888481 /* RelayClientEndToEndTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RelayClientEndToEndTests.swift; sourceTree = ""; }; + A5E03E0E28646D8A00888481 /* WebSocketFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebSocketFactory.swift; sourceTree = ""; }; + A5E03E1028646F8000888481 /* KeychainServiceFake.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeychainServiceFake.swift; sourceTree = ""; }; A5E22D192840C62A00E36487 /* Engine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Engine.swift; sourceTree = ""; }; A5E22D1B2840C85D00E36487 /* App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = ""; }; A5E22D1D2840C8BF00E36487 /* RoutingEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoutingEngine.swift; sourceTree = ""; }; @@ -166,6 +185,17 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + A5E03DEA286464DB00888481 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + A5E03DFF2864662500888481 /* WalletConnect in Frameworks */, + A5E03DF52864651200888481 /* Starscream in Frameworks */, + A5E03E01286466EA00888481 /* WalletConnectChat in Frameworks */, + A50FFDBD286473D500F76E06 /* TestingUtils in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -213,6 +243,7 @@ 764E1D3E26F8D3FC00A1FB15 /* ExampleApp */, 84CE641D27981DED00142511 /* DApp */, A5A4FC732840C12C00BBEC1E /* UITests */, + A5E03DEE286464DB00888481 /* IntegrationTests */, 764E1D3D26F8D3FC00A1FB15 /* Products */, 764E1D5326F8DAC800A1FB15 /* Frameworks */, 764E1D5626F8DB6000A1FB15 /* WalletConnectSwiftV2 */, @@ -225,6 +256,7 @@ 764E1D3C26F8D3FC00A1FB15 /* WalletConnect Wallet.app */, 84CE641C27981DED00142511 /* DApp.app */, A5A4FC722840C12C00BBEC1E /* UITests.xctest */, + A5E03DED286464DB00888481 /* IntegrationTests.xctest */, ); name = Products; sourceTree = ""; @@ -351,6 +383,52 @@ path = Engine; sourceTree = ""; }; + A5E03DEE286464DB00888481 /* IntegrationTests */ = { + isa = PBXGroup; + children = ( + A5E03E0B28646AA500888481 /* Relay */, + A5E03E0A28646A8A00888481 /* Stubs */, + A5E03E0928646A8100888481 /* Sign */, + A5E03E0828646A7B00888481 /* Chat */, + ); + path = IntegrationTests; + sourceTree = ""; + }; + A5E03E0828646A7B00888481 /* Chat */ = { + isa = PBXGroup; + children = ( + A5E03E02286466F400888481 /* ChatTests.swift */, + ); + path = Chat; + sourceTree = ""; + }; + A5E03E0928646A8100888481 /* Sign */ = { + isa = PBXGroup; + children = ( + A5E03DF8286465C700888481 /* ClientDelegate.swift */, + A5E03DF9286465C700888481 /* SignClientTests.swift */, + ); + path = Sign; + sourceTree = ""; + }; + A5E03E0A28646A8A00888481 /* Stubs */ = { + isa = PBXGroup; + children = ( + A5E03E1028646F8000888481 /* KeychainServiceFake.swift */, + A5E03E0E28646D8A00888481 /* WebSocketFactory.swift */, + A5E03DFC286465D100888481 /* Stubs.swift */, + ); + path = Stubs; + sourceTree = ""; + }; + A5E03E0B28646AA500888481 /* Relay */ = { + isa = PBXGroup; + children = ( + A5E03E0C28646AD200888481 /* RelayClientEndToEndTests.swift */, + ); + path = Relay; + sourceTree = ""; + }; A5E22D252840D08B00E36487 /* Regression */ = { isa = PBXGroup; children = ( @@ -433,6 +511,29 @@ productReference = A5A4FC722840C12C00BBEC1E /* UITests.xctest */; productType = "com.apple.product-type.bundle.ui-testing"; }; + A5E03DEC286464DB00888481 /* IntegrationTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = A5E03DF1286464DB00888481 /* Build configuration list for PBXNativeTarget "IntegrationTests" */; + buildPhases = ( + A5E03DE9286464DB00888481 /* Sources */, + A5E03DEA286464DB00888481 /* Frameworks */, + A5E03DEB286464DB00888481 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = IntegrationTests; + packageProductDependencies = ( + A5E03DF42864651200888481 /* Starscream */, + A5E03DFE2864662500888481 /* WalletConnect */, + A5E03E00286466EA00888481 /* WalletConnectChat */, + A50FFDBC286473D500F76E06 /* TestingUtils */, + ); + productName = IntegrationTests; + productReference = A5E03DED286464DB00888481 /* IntegrationTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -451,6 +552,9 @@ A5A4FC712840C12C00BBEC1E = { CreatedOnToolsVersion = 13.3; }; + A5E03DEC286464DB00888481 = { + CreatedOnToolsVersion = 13.3; + }; }; }; buildConfigurationList = 764E1D3726F8D3FC00A1FB15 /* Build configuration list for PBXProject "ExampleApp" */; @@ -473,6 +577,7 @@ 764E1D3B26F8D3FC00A1FB15 /* Wallet */, 84CE641B27981DED00142511 /* DApp */, A5A4FC712840C12C00BBEC1E /* UITests */, + A5E03DEC286464DB00888481 /* IntegrationTests */, ); }; /* End PBXProject section */ @@ -503,6 +608,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + A5E03DEB286464DB00888481 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -570,6 +682,20 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + A5E03DE9286464DB00888481 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A5E03DFB286465C700888481 /* ClientDelegate.swift in Sources */, + A5E03E03286466F400888481 /* ChatTests.swift in Sources */, + A5E03E0D28646AD200888481 /* RelayClientEndToEndTests.swift in Sources */, + A5E03DFA286465C700888481 /* SignClientTests.swift in Sources */, + A5E03E0F28646D8A00888481 /* WebSocketFactory.swift in Sources */, + A5E03E1128646F8000888481 /* KeychainServiceFake.swift in Sources */, + A5E03DFD286465D100888481 /* Stubs.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -877,6 +1003,42 @@ }; name = Release; }; + A5E03DF2286464DB00888481 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = W5R8AG9K22; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.4; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.walletconnect.IntegrationTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + A5E03DF3286464DB00888481 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = W5R8AG9K22; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.4; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.walletconnect.IntegrationTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -916,6 +1078,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + A5E03DF1286464DB00888481 /* Build configuration list for PBXNativeTarget "IntegrationTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A5E03DF2286464DB00888481 /* Debug */, + A5E03DF3286464DB00888481 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ @@ -956,6 +1127,10 @@ package = 8449439F278EC49700CC26BB /* XCRemoteSwiftPackageReference "Web3" */; productName = Web3; }; + A50FFDBC286473D500F76E06 /* TestingUtils */ = { + isa = XCSwiftPackageProductDependency; + productName = TestingUtils; + }; A5D85225286333D500DAF5C3 /* Starscream */ = { isa = XCSwiftPackageProductDependency; package = A5D85224286333D500DAF5C3 /* XCRemoteSwiftPackageReference "Starscream" */; @@ -966,6 +1141,19 @@ package = A5D85224286333D500DAF5C3 /* XCRemoteSwiftPackageReference "Starscream" */; productName = Starscream; }; + A5E03DF42864651200888481 /* Starscream */ = { + isa = XCSwiftPackageProductDependency; + package = A5D85224286333D500DAF5C3 /* XCRemoteSwiftPackageReference "Starscream" */; + productName = Starscream; + }; + A5E03DFE2864662500888481 /* WalletConnect */ = { + isa = XCSwiftPackageProductDependency; + productName = WalletConnect; + }; + A5E03E00286466EA00888481 /* WalletConnectChat */ = { + isa = XCSwiftPackageProductDependency; + productName = WalletConnectChat; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = 764E1D3426F8D3FC00A1FB15 /* Project object */; diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/IntegrationTests.xcscheme b/Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/IntegrationTests.xcscheme similarity index 87% rename from .swiftpm/xcode/xcshareddata/xcschemes/IntegrationTests.xcscheme rename to Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/IntegrationTests.xcscheme index 6c5757fc3..59b88b4e0 100644 --- a/.swiftpm/xcode/xcshareddata/xcschemes/IntegrationTests.xcscheme +++ b/Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/IntegrationTests.xcscheme @@ -1,6 +1,6 @@ + ReferencedContainer = "container:ExampleApp.xcodeproj"> diff --git a/Tests/ChatTests/EndToEndTests.swift b/Example/IntegrationTests/Chat/ChatTests.swift similarity index 97% rename from Tests/ChatTests/EndToEndTests.swift rename to Example/IntegrationTests/Chat/ChatTests.swift index 8fff8a4a5..bdcb86908 100644 --- a/Tests/ChatTests/EndToEndTests.swift +++ b/Example/IntegrationTests/Chat/ChatTests.swift @@ -3,7 +3,6 @@ import XCTest @testable import Chat import WalletConnectUtils @testable import WalletConnectKMS -@testable import TestingUtils import WalletConnectRelay import Combine @@ -40,7 +39,7 @@ final class ChatTests: XCTestCase { func makeClient(prefix: String) -> Chat { let logger = ConsoleLogger(suffix: prefix, loggingLevel: .debug) - let relayHost = "dev.relay.walletconnect.com" + let relayHost = "relay.walletconnect.com" let projectId = "8ba9ee138960775e5231b70cc5ef1c3a" let relayClient = RelayClient(relayHost: relayHost, projectId: projectId, socketFactory: SocketFactory(), logger: logger) let keychain = KeychainStorage(keychainService: KeychainServiceFake(), serviceIdentifier: "") diff --git a/Tests/RelayerTests/RelayClientEndToEndTests.swift b/Example/IntegrationTests/Relay/RelayClientEndToEndTests.swift similarity index 98% rename from Tests/RelayerTests/RelayClientEndToEndTests.swift rename to Example/IntegrationTests/Relay/RelayClientEndToEndTests.swift index 140e79de5..e6c8b161b 100644 --- a/Tests/RelayerTests/RelayClientEndToEndTests.swift +++ b/Example/IntegrationTests/Relay/RelayClientEndToEndTests.swift @@ -8,7 +8,7 @@ import Starscream final class RelayClientEndToEndTests: XCTestCase { - let relayHost = "dev.relay.walletconnect.com" + let relayHost = "relay.walletconnect.com" let projectId = "8ba9ee138960775e5231b70cc5ef1c3a" private var publishers = [AnyCancellable]() diff --git a/Tests/IntegrationTests/ClientDelegate.swift b/Example/IntegrationTests/Sign/ClientDelegate.swift similarity index 100% rename from Tests/IntegrationTests/ClientDelegate.swift rename to Example/IntegrationTests/Sign/ClientDelegate.swift diff --git a/Tests/IntegrationTests/SignClientTests.swift b/Example/IntegrationTests/Sign/SignClientTests.swift similarity index 99% rename from Tests/IntegrationTests/SignClientTests.swift rename to Example/IntegrationTests/Sign/SignClientTests.swift index d992a98c3..dc2adc587 100644 --- a/Tests/IntegrationTests/SignClientTests.swift +++ b/Example/IntegrationTests/Sign/SignClientTests.swift @@ -1,6 +1,5 @@ import XCTest import WalletConnectUtils -import TestingUtils @testable import WalletConnectKMS @testable import WalletConnectSign @@ -13,7 +12,7 @@ final class SignClientTests: XCTestCase { static private func makeClientDelegate( name: String, - relayHost: String = "dev.relay.walletconnect.com", + relayHost: String = "relay.walletconnect.com", projectId: String = "8ba9ee138960775e5231b70cc5ef1c3a" ) -> ClientDelegate { let logger = ConsoleLogger(suffix: name, loggingLevel: .debug) diff --git a/Tests/WalletConnectKMSTests/KeychainServiceFake.swift b/Example/IntegrationTests/Stubs/KeychainServiceFake.swift similarity index 80% rename from Tests/WalletConnectKMSTests/KeychainServiceFake.swift rename to Example/IntegrationTests/Stubs/KeychainServiceFake.swift index 49fb82687..460ab5a08 100644 --- a/Tests/WalletConnectKMSTests/KeychainServiceFake.swift +++ b/Example/IntegrationTests/Stubs/KeychainServiceFake.swift @@ -1,13 +1,17 @@ import Foundation @testable import WalletConnectKMS -final class KeychainServiceFake: KeychainServiceProtocol { +final public class KeychainServiceFake: KeychainServiceProtocol { - var errorStatus: OSStatus? + public var errorStatus: OSStatus? - private var storage: [String: Data] = [:] + private var storage: [String: Data] - func add(_ attributes: CFDictionary, _ result: UnsafeMutablePointer?) -> OSStatus { + public init() { + self.storage = [:] + } + + public func add(_ attributes: CFDictionary, _ result: UnsafeMutablePointer?) -> OSStatus { if let forceError = errorStatus { return forceError } @@ -22,7 +26,7 @@ final class KeychainServiceFake: KeychainServiceProtocol { return errSecInternalError } - func copyMatching(_ query: CFDictionary, _ result: UnsafeMutablePointer?) -> OSStatus { + public func copyMatching(_ query: CFDictionary, _ result: UnsafeMutablePointer?) -> OSStatus { if let forceError = errorStatus { return forceError } @@ -37,7 +41,7 @@ final class KeychainServiceFake: KeychainServiceProtocol { return errSecInternalError } - func update(_ query: CFDictionary, _ attributesToUpdate: CFDictionary) -> OSStatus { + public func update(_ query: CFDictionary, _ attributesToUpdate: CFDictionary) -> OSStatus { if let forceError = errorStatus { return forceError } @@ -53,7 +57,7 @@ final class KeychainServiceFake: KeychainServiceProtocol { return errSecInternalError } - func delete(_ query: CFDictionary) -> OSStatus { + public func delete(_ query: CFDictionary) -> OSStatus { if let forceError = errorStatus { return forceError } diff --git a/Tests/IntegrationTests/Helpers/Stubs.swift b/Example/IntegrationTests/Stubs/Stubs.swift similarity index 100% rename from Tests/IntegrationTests/Helpers/Stubs.swift rename to Example/IntegrationTests/Stubs/Stubs.swift diff --git a/Tests/TestingUtils/WebSocketFactory.swift b/Example/IntegrationTests/Stubs/WebSocketFactory.swift similarity index 100% rename from Tests/TestingUtils/WebSocketFactory.swift rename to Example/IntegrationTests/Stubs/WebSocketFactory.swift diff --git a/Package.swift b/Package.swift index 1c1ec5aaa..e9a53e8fb 100644 --- a/Package.swift +++ b/Package.swift @@ -12,11 +12,15 @@ let package = Package( products: [ .library( name: "WalletConnect", - targets: ["WalletConnectSign"]) - ], - dependencies: [ - .package(url: "https://github.com/daltoniam/Starscream.git", .upToNextMajor(from: "3.0.0")) + targets: ["WalletConnectSign"]), + .library( + name: "WalletConnectChat", + targets: ["Chat"]), + .library( + name: "TestingUtils", + targets: ["TestingUtils"]) ], + dependencies: [], targets: [ .target( name: "WalletConnectSign", @@ -45,10 +49,7 @@ let package = Package( dependencies: []), .testTarget( name: "WalletConnectSignTests", - dependencies: ["WalletConnectSign", "TestingUtils", "WalletConnectKMS"]), - .testTarget( - name: "IntegrationTests", - dependencies: ["WalletConnectSign", "TestingUtils", "WalletConnectKMS"]), + dependencies: ["WalletConnectSign", "TestingUtils"]), .testTarget( name: "ChatTests", dependencies: ["Chat", "WalletConnectUtils", "TestingUtils"]), @@ -60,7 +61,7 @@ let package = Package( dependencies: ["WalletConnectKMS", "WalletConnectUtils", "TestingUtils"]), .target( name: "TestingUtils", - dependencies: ["WalletConnectUtils", "WalletConnectKMS", "Starscream", "WalletConnectRelay"], + dependencies: ["WalletConnectUtils", "WalletConnectKMS"], path: "Tests/TestingUtils"), .testTarget( name: "WalletConnectUtilsTests", diff --git a/Tests/TestingUtils/Mocks/KeychainServiceFake.swift b/Tests/TestingUtils/Mocks/KeychainServiceFake.swift index abed2d3f5..460ab5a08 100644 --- a/Tests/TestingUtils/Mocks/KeychainServiceFake.swift +++ b/Tests/TestingUtils/Mocks/KeychainServiceFake.swift @@ -3,7 +3,7 @@ import Foundation final public class KeychainServiceFake: KeychainServiceProtocol { - var errorStatus: OSStatus? + public var errorStatus: OSStatus? private var storage: [String: Data] diff --git a/Tests/WalletConnectKMSTests/KeychainStorageTests.swift b/Tests/WalletConnectKMSTests/KeychainStorageTests.swift index 83ff4e5ca..19c57bdaf 100644 --- a/Tests/WalletConnectKMSTests/KeychainStorageTests.swift +++ b/Tests/WalletConnectKMSTests/KeychainStorageTests.swift @@ -1,5 +1,6 @@ import XCTest import CryptoKit +import TestingUtils @testable import WalletConnectKMS extension Curve25519.KeyAgreement.PrivateKey: GenericPasswordConvertible {} diff --git a/Tests/IntegrationTests/SerialiserTests.swift b/Tests/WalletConnectKMSTests/SerialiserTests.swift similarity index 99% rename from Tests/IntegrationTests/SerialiserTests.swift rename to Tests/WalletConnectKMSTests/SerialiserTests.swift index ec68379bf..2c6ca0384 100644 --- a/Tests/IntegrationTests/SerialiserTests.swift +++ b/Tests/WalletConnectKMSTests/SerialiserTests.swift @@ -1,5 +1,3 @@ -// - import Foundation import XCTest @testable import WalletConnectKMS From 02632bc13a59be5ee71a7ea59b15fe350d6ace3b Mon Sep 17 00:00:00 2001 From: Artur Guseinov Date: Thu, 23 Jun 2022 15:41:52 +0500 Subject: [PATCH 5/9] Deployment target updated --- Example/ExampleApp.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Example/ExampleApp.xcodeproj/project.pbxproj b/Example/ExampleApp.xcodeproj/project.pbxproj index 8b0e5acb9..e04131a28 100644 --- a/Example/ExampleApp.xcodeproj/project.pbxproj +++ b/Example/ExampleApp.xcodeproj/project.pbxproj @@ -1011,7 +1011,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = W5R8AG9K22; GENERATE_INFOPLIST_FILE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 15.4; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.walletconnect.IntegrationTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1029,7 +1029,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = W5R8AG9K22; GENERATE_INFOPLIST_FILE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 15.4; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.walletconnect.IntegrationTests; PRODUCT_NAME = "$(TARGET_NAME)"; From d259438af0d084bf7ce4eadf9d32a252ebe9ae91 Mon Sep 17 00:00:00 2001 From: Artur Guseinov Date: Thu, 23 Jun 2022 16:02:27 +0500 Subject: [PATCH 6/9] Removing TestingUtills library --- Example/ExampleApp.xcodeproj/project.pbxproj | 7 ------- Example/IntegrationTests/Chat/ChatTests.swift | 2 +- .../Relay/RelayClientEndToEndTests.swift | 11 +++++++++-- Example/IntegrationTests/Sign/SignClientTests.swift | 2 +- Package.swift | 5 +---- Sources/WalletConnectSign/Sign/Sign.swift | 2 +- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/Example/ExampleApp.xcodeproj/project.pbxproj b/Example/ExampleApp.xcodeproj/project.pbxproj index e04131a28..6c60e069d 100644 --- a/Example/ExampleApp.xcodeproj/project.pbxproj +++ b/Example/ExampleApp.xcodeproj/project.pbxproj @@ -45,7 +45,6 @@ 84CE645527A29D4D00142511 /* ResponseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84CE645427A29D4C00142511 /* ResponseViewController.swift */; }; 84F568C2279582D200D0A289 /* Signer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F568C1279582D200D0A289 /* Signer.swift */; }; 84F568C42795832A00D0A289 /* EthereumTransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F568C32795832A00D0A289 /* EthereumTransaction.swift */; }; - A50FFDBD286473D500F76E06 /* TestingUtils in Frameworks */ = {isa = PBXBuildFile; productRef = A50FFDBC286473D500F76E06 /* TestingUtils */; }; A5A4FC56283CBB7800BBEC1E /* SessionDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A4FC55283CBB7800BBEC1E /* SessionDetailView.swift */; }; A5A4FC58283CBB9F00BBEC1E /* SessionDetailViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A4FC57283CBB9F00BBEC1E /* SessionDetailViewModel.swift */; }; A5A4FC5A283CC08600BBEC1E /* SessionNamespaceViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A4FC59283CC08600BBEC1E /* SessionNamespaceViewModel.swift */; }; @@ -192,7 +191,6 @@ A5E03DFF2864662500888481 /* WalletConnect in Frameworks */, A5E03DF52864651200888481 /* Starscream in Frameworks */, A5E03E01286466EA00888481 /* WalletConnectChat in Frameworks */, - A50FFDBD286473D500F76E06 /* TestingUtils in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -528,7 +526,6 @@ A5E03DF42864651200888481 /* Starscream */, A5E03DFE2864662500888481 /* WalletConnect */, A5E03E00286466EA00888481 /* WalletConnectChat */, - A50FFDBC286473D500F76E06 /* TestingUtils */, ); productName = IntegrationTests; productReference = A5E03DED286464DB00888481 /* IntegrationTests.xctest */; @@ -1127,10 +1124,6 @@ package = 8449439F278EC49700CC26BB /* XCRemoteSwiftPackageReference "Web3" */; productName = Web3; }; - A50FFDBC286473D500F76E06 /* TestingUtils */ = { - isa = XCSwiftPackageProductDependency; - productName = TestingUtils; - }; A5D85225286333D500DAF5C3 /* Starscream */ = { isa = XCSwiftPackageProductDependency; package = A5D85224286333D500DAF5C3 /* XCRemoteSwiftPackageReference "Starscream" */; diff --git a/Example/IntegrationTests/Chat/ChatTests.swift b/Example/IntegrationTests/Chat/ChatTests.swift index bdcb86908..5024149aa 100644 --- a/Example/IntegrationTests/Chat/ChatTests.swift +++ b/Example/IntegrationTests/Chat/ChatTests.swift @@ -39,7 +39,7 @@ final class ChatTests: XCTestCase { func makeClient(prefix: String) -> Chat { let logger = ConsoleLogger(suffix: prefix, loggingLevel: .debug) - let relayHost = "relay.walletconnect.com" + let relayHost = "dev.relay.walletconnect.com" let projectId = "8ba9ee138960775e5231b70cc5ef1c3a" let relayClient = RelayClient(relayHost: relayHost, projectId: projectId, socketFactory: SocketFactory(), logger: logger) let keychain = KeychainStorage(keychainService: KeychainServiceFake(), serviceIdentifier: "") diff --git a/Example/IntegrationTests/Relay/RelayClientEndToEndTests.swift b/Example/IntegrationTests/Relay/RelayClientEndToEndTests.swift index e6c8b161b..ccb6cbab4 100644 --- a/Example/IntegrationTests/Relay/RelayClientEndToEndTests.swift +++ b/Example/IntegrationTests/Relay/RelayClientEndToEndTests.swift @@ -2,13 +2,14 @@ import Foundation import Combine import XCTest import WalletConnectUtils -import TestingUtils import Starscream @testable import WalletConnectRelay final class RelayClientEndToEndTests: XCTestCase { - let relayHost = "relay.walletconnect.com" + let defaultTimeout: TimeInterval = 5 + + let relayHost = "dev.relay.walletconnect.com" let projectId = "8ba9ee138960775e5231b70cc5ef1c3a" private var publishers = [AnyCancellable]() @@ -90,3 +91,9 @@ final class RelayClientEndToEndTests: XCTestCase { // XCTAssertEqual(subscriptionAPayload, payloadB) } } + +extension String { + static func randomTopic() -> String { + "\(UUID().uuidString)\(UUID().uuidString)".replacingOccurrences(of: "-", with: "").lowercased() + } +} diff --git a/Example/IntegrationTests/Sign/SignClientTests.swift b/Example/IntegrationTests/Sign/SignClientTests.swift index dc2adc587..5010ff067 100644 --- a/Example/IntegrationTests/Sign/SignClientTests.swift +++ b/Example/IntegrationTests/Sign/SignClientTests.swift @@ -12,7 +12,7 @@ final class SignClientTests: XCTestCase { static private func makeClientDelegate( name: String, - relayHost: String = "relay.walletconnect.com", + relayHost: String = "dev.relay.walletconnect.com", projectId: String = "8ba9ee138960775e5231b70cc5ef1c3a" ) -> ClientDelegate { let logger = ConsoleLogger(suffix: name, loggingLevel: .debug) diff --git a/Package.swift b/Package.swift index e9a53e8fb..537aeed2a 100644 --- a/Package.swift +++ b/Package.swift @@ -15,10 +15,7 @@ let package = Package( targets: ["WalletConnectSign"]), .library( name: "WalletConnectChat", - targets: ["Chat"]), - .library( - name: "TestingUtils", - targets: ["TestingUtils"]) + targets: ["Chat"]) ], dependencies: [], targets: [ diff --git a/Sources/WalletConnectSign/Sign/Sign.swift b/Sources/WalletConnectSign/Sign/Sign.swift index f5eb6e5dc..e252f6b13 100644 --- a/Sources/WalletConnectSign/Sign/Sign.swift +++ b/Sources/WalletConnectSign/Sign/Sign.swift @@ -18,7 +18,7 @@ public class Sign { fatalError("Error - you must call configure(_:) before accessing the shared instance.") } relayClient = RelayClient( - relayHost: "relay.walletconnect.com", + relayHost: "dev.relay.walletconnect.com", projectId: config.projectId, socketFactory: config.socketFactory, socketConnectionType: config.socketConnectionType From 10374628ded18d9b2d34edfaf28ef3d1560cc3e1 Mon Sep 17 00:00:00 2001 From: Artur Guseinov Date: Thu, 23 Jun 2022 17:22:56 +0500 Subject: [PATCH 7/9] Task priority hight --- Example/IntegrationTests/Sign/SignClientTests.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Example/IntegrationTests/Sign/SignClientTests.swift b/Example/IntegrationTests/Sign/SignClientTests.swift index 5010ff067..e6b5b8a01 100644 --- a/Example/IntegrationTests/Sign/SignClientTests.swift +++ b/Example/IntegrationTests/Sign/SignClientTests.swift @@ -5,7 +5,7 @@ import WalletConnectUtils final class SignClientTests: XCTestCase { - let defaultTimeout: TimeInterval = 5.0 + let defaultTimeout: TimeInterval = 5 var proposer: ClientDelegate! var responder: ClientDelegate! @@ -62,7 +62,7 @@ final class SignClientTests: XCTestCase { let sessionNamespaces = SessionNamespace.make(toRespond: requiredNamespaces) wallet.onSessionProposal = { proposal in - Task { + Task(priority: .high) { do { try await wallet.client.approve(proposalId: proposal.id, namespaces: sessionNamespaces) } catch { XCTFail("\(error)") } } } @@ -90,7 +90,7 @@ final class SignClientTests: XCTestCase { try await wallet.client.pair(uri: uri!) wallet.onSessionProposal = { proposal in - Task { + Task(priority: .high) { do { try await wallet.client.reject(proposalId: proposal.id, reason: .disapprovedChains) // TODO: Review reason store.rejectedProposal = proposal From c8ba4509daf3021bf2c0697cdfb11bb6d986babe Mon Sep 17 00:00:00 2001 From: Artur Guseinov Date: Thu, 23 Jun 2022 17:43:26 +0500 Subject: [PATCH 8/9] Specify derivedDataPath --- .github/workflows/swift.yml | 47 ++++++++++++++----- .../xcschemes/WalletConnect.xcscheme | 30 ++++-------- 2 files changed, 45 insertions(+), 32 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index dc8c14213..7dc66c564 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -7,12 +7,11 @@ on: branches: [ main, develop ] jobs: - build: + build: runs-on: macos-latest steps: - - name: Checkout - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - name: Setup Xcode Version uses: maxim-lobanov/setup-xcode@v1 @@ -21,26 +20,50 @@ jobs: - uses: actions/cache@v2 with: - path: .build + path: | + .build + SourcePackages key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }} restore-keys: | ${{ runner.os }}-spm- # Package builds - - name: Build Package - run: swift build -v - name: Run tests - run: swift test -v + run: "xcodebuild \ + -project Example/ExampleApp.xcodeproj \ + -scheme WalletConnect \ + -clonedSourcePackagesDirPath SourcePackages \ + -sdk iphonesimulator" + + # Integration tests - name: Run integration tests - run: xcodebuild -project Example/ExampleApp.xcodeproj -scheme IntegrationTests -destination 'platform=iOS Simulator,name=iPhone 13' test + run: "xcodebuild \ + -project Example/ExampleApp.xcodeproj \ + -scheme IntegrationTests \ + -clonedSourcePackagesDirPath SourcePackages \ + -destination 'platform=iOS Simulator,name=iPhone 13' test" - # Example app builds + # Wallet build - name: Build Example Wallet - run: xcodebuild -project Example/ExampleApp.xcodeproj -scheme Wallet -sdk iphonesimulator + run: "xcodebuild \ + -project Example/ExampleApp.xcodeproj \ + -scheme Wallet \ + -clonedSourcePackagesDirPath SourcePackages \ + -sdk iphonesimulator" + + # DApp build - name: Build Example Dapp - run: xcodebuild -project Example/ExampleApp.xcodeproj -scheme DApp -sdk iphonesimulator + run: "xcodebuild \ + -project Example/ExampleApp.xcodeproj \ + -scheme DApp \ + -clonedSourcePackagesDirPath SourcePackages \ + -sdk iphonesimulator" # UI tests - name: UI Tests - run: xcodebuild -project Example/ExampleApp.xcodeproj -scheme UITests -destination 'platform=iOS Simulator,name=iPhone 13' test + run: "xcodebuild \ + -project Example/ExampleApp.xcodeproj \ + -scheme UITests \ + -clonedSourcePackagesDirPath SourcePackages \ + -destination 'platform=iOS Simulator,name=iPhone 13' test" continue-on-error: true diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/WalletConnect.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/WalletConnect.xcscheme index d7d784447..3f9debd20 100644 --- a/.swiftpm/xcode/xcshareddata/xcschemes/WalletConnect.xcscheme +++ b/.swiftpm/xcode/xcshareddata/xcschemes/WalletConnect.xcscheme @@ -192,26 +192,6 @@ - - - - - - - - + + + + Date: Mon, 27 Jun 2022 14:27:36 +0500 Subject: [PATCH 9/9] Switch to prod relay host --- Example/IntegrationTests/Chat/ChatTests.swift | 2 +- Example/IntegrationTests/Relay/RelayClientEndToEndTests.swift | 2 +- Example/IntegrationTests/Sign/SignClientTests.swift | 2 +- Sources/WalletConnectSign/Sign/Sign.swift | 2 +- Tests/WalletConnectSignTests/PairingEngineTests.swift | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Example/IntegrationTests/Chat/ChatTests.swift b/Example/IntegrationTests/Chat/ChatTests.swift index 5024149aa..bdcb86908 100644 --- a/Example/IntegrationTests/Chat/ChatTests.swift +++ b/Example/IntegrationTests/Chat/ChatTests.swift @@ -39,7 +39,7 @@ final class ChatTests: XCTestCase { func makeClient(prefix: String) -> Chat { let logger = ConsoleLogger(suffix: prefix, loggingLevel: .debug) - let relayHost = "dev.relay.walletconnect.com" + let relayHost = "relay.walletconnect.com" let projectId = "8ba9ee138960775e5231b70cc5ef1c3a" let relayClient = RelayClient(relayHost: relayHost, projectId: projectId, socketFactory: SocketFactory(), logger: logger) let keychain = KeychainStorage(keychainService: KeychainServiceFake(), serviceIdentifier: "") diff --git a/Example/IntegrationTests/Relay/RelayClientEndToEndTests.swift b/Example/IntegrationTests/Relay/RelayClientEndToEndTests.swift index ccb6cbab4..55ce77d74 100644 --- a/Example/IntegrationTests/Relay/RelayClientEndToEndTests.swift +++ b/Example/IntegrationTests/Relay/RelayClientEndToEndTests.swift @@ -9,7 +9,7 @@ final class RelayClientEndToEndTests: XCTestCase { let defaultTimeout: TimeInterval = 5 - let relayHost = "dev.relay.walletconnect.com" + let relayHost = "relay.walletconnect.com" let projectId = "8ba9ee138960775e5231b70cc5ef1c3a" private var publishers = [AnyCancellable]() diff --git a/Example/IntegrationTests/Sign/SignClientTests.swift b/Example/IntegrationTests/Sign/SignClientTests.swift index e6b5b8a01..8a18738ba 100644 --- a/Example/IntegrationTests/Sign/SignClientTests.swift +++ b/Example/IntegrationTests/Sign/SignClientTests.swift @@ -12,7 +12,7 @@ final class SignClientTests: XCTestCase { static private func makeClientDelegate( name: String, - relayHost: String = "dev.relay.walletconnect.com", + relayHost: String = "relay.walletconnect.com", projectId: String = "8ba9ee138960775e5231b70cc5ef1c3a" ) -> ClientDelegate { let logger = ConsoleLogger(suffix: name, loggingLevel: .debug) diff --git a/Sources/WalletConnectSign/Sign/Sign.swift b/Sources/WalletConnectSign/Sign/Sign.swift index e252f6b13..f5eb6e5dc 100644 --- a/Sources/WalletConnectSign/Sign/Sign.swift +++ b/Sources/WalletConnectSign/Sign/Sign.swift @@ -18,7 +18,7 @@ public class Sign { fatalError("Error - you must call configure(_:) before accessing the shared instance.") } relayClient = RelayClient( - relayHost: "dev.relay.walletconnect.com", + relayHost: "relay.walletconnect.com", projectId: config.projectId, socketFactory: config.socketFactory, socketConnectionType: config.socketConnectionType diff --git a/Tests/WalletConnectSignTests/PairingEngineTests.swift b/Tests/WalletConnectSignTests/PairingEngineTests.swift index 4761d37c3..683ca8731 100644 --- a/Tests/WalletConnectSignTests/PairingEngineTests.swift +++ b/Tests/WalletConnectSignTests/PairingEngineTests.swift @@ -87,7 +87,7 @@ final class PairingEngineTests: XCTestCase { @MainActor func testHandleSessionProposeResponse() async { - let uri = try! await engine.create() + let uri = try! await engine.create() let pairing = storageMock.getPairing(forTopic: uri.topic)! let topicA = pairing.topic let relayOptions = RelayProtocolOptions(protocol: "", data: nil)