From 6a5863e37708d3283d3e06aca3da13da4a780d5b Mon Sep 17 00:00:00 2001 From: Alexander Lisovik Date: Wed, 8 Mar 2023 22:37:01 +0100 Subject: [PATCH 01/15] Throw error when method is not implemented, update UI for requested/optional namespaces --- Example/ExampleApp.xcodeproj/project.pbxproj | 12 -- .../SessionDetailViewController.swift | 10 +- Example/ExampleApp/Shared/Signer/Signer.swift | 20 ++- .../Wallet/WalletViewController.swift | 10 +- .../grey50.colorset/Contents.json | 6 +- .../ConnectionDetailsView.swift | 1 + .../SessionProposal/Models/Proposal.swift | 58 --------- .../SessionProposalPresenter.swift | 4 +- .../SessionProposal/SessionProposalView.swift | 117 ++++++++++++------ .../SessionRequestInteractor.swift | 16 ++- .../SessionRequestPresenter.swift | 12 +- .../SessionRequest/SessionRequestView.swift | 7 +- 12 files changed, 141 insertions(+), 132 deletions(-) delete mode 100644 Example/WalletApp/PresentationLayer/Wallet/SessionProposal/Models/Proposal.swift diff --git a/Example/ExampleApp.xcodeproj/project.pbxproj b/Example/ExampleApp.xcodeproj/project.pbxproj index 4348df5e6..0466e71ae 100644 --- a/Example/ExampleApp.xcodeproj/project.pbxproj +++ b/Example/ExampleApp.xcodeproj/project.pbxproj @@ -236,7 +236,6 @@ C55D3497295DFA750004314A /* WelcomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C55D3492295DFA750004314A /* WelcomeView.swift */; }; C55D349929630D440004314A /* Web3Wallet in Frameworks */ = {isa = PBXBuildFile; productRef = C55D349829630D440004314A /* Web3Wallet */; }; C55D349B2965BC2F0004314A /* TagsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C55D349A2965BC2F0004314A /* TagsView.swift */; }; - C55D349D2965F8D40004314A /* Proposal.swift in Sources */ = {isa = PBXBuildFile; fileRef = C55D349C2965F8D30004314A /* Proposal.swift */; }; C55D34AE2965FB750004314A /* SessionProposalModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = C55D34A92965FB750004314A /* SessionProposalModule.swift */; }; C55D34AF2965FB750004314A /* SessionProposalPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C55D34AA2965FB750004314A /* SessionProposalPresenter.swift */; }; C55D34B02965FB750004314A /* SessionProposalRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C55D34AB2965FB750004314A /* SessionProposalRouter.swift */; }; @@ -566,7 +565,6 @@ C55D3491295DFA750004314A /* WelcomeInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeInteractor.swift; sourceTree = ""; }; C55D3492295DFA750004314A /* WelcomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeView.swift; sourceTree = ""; }; C55D349A2965BC2F0004314A /* TagsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagsView.swift; sourceTree = ""; }; - C55D349C2965F8D30004314A /* Proposal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Proposal.swift; sourceTree = ""; }; C55D34A92965FB750004314A /* SessionProposalModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionProposalModule.swift; sourceTree = ""; }; C55D34AA2965FB750004314A /* SessionProposalPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionProposalPresenter.swift; sourceTree = ""; }; C55D34AB2965FB750004314A /* SessionProposalRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionProposalRouter.swift; sourceTree = ""; }; @@ -1532,7 +1530,6 @@ C55D349E2965FAC30004314A /* SessionProposal */ = { isa = PBXGroup; children = ( - C55D34B32965FF750004314A /* Models */, C55D34A92965FB750004314A /* SessionProposalModule.swift */, C55D34AA2965FB750004314A /* SessionProposalPresenter.swift */, C55D34AB2965FB750004314A /* SessionProposalRouter.swift */, @@ -1542,14 +1539,6 @@ path = SessionProposal; sourceTree = ""; }; - C55D34B32965FF750004314A /* Models */ = { - isa = PBXGroup; - children = ( - C55D349C2965F8D30004314A /* Proposal.swift */, - ); - path = Models; - sourceTree = ""; - }; C56EE21C293F55ED004840D1 /* WalletApp */ = { isa = PBXGroup; children = ( @@ -2347,7 +2336,6 @@ C5F32A322954816C00A6476E /* ConnectionDetailsPresenter.swift in Sources */, 84B815562991217900FAD54E /* PushMessagesRouter.swift in Sources */, C56EE246293F566D004840D1 /* ScanRouter.swift in Sources */, - C55D349D2965F8D40004314A /* Proposal.swift in Sources */, C55D3481295DD7140004314A /* AuthRequestRouter.swift in Sources */, C5B2F6F829705293000DBA0E /* SessionRequestView.swift in Sources */, C56EE28C293F5757004840D1 /* Configurator.swift in Sources */, diff --git a/Example/ExampleApp/SessionDetails/SessionDetailViewController.swift b/Example/ExampleApp/SessionDetails/SessionDetailViewController.swift index 71ec2b634..26bddee7f 100644 --- a/Example/ExampleApp/SessionDetails/SessionDetailViewController.swift +++ b/Example/ExampleApp/SessionDetails/SessionDetailViewController.swift @@ -23,9 +23,13 @@ final class SessionDetailViewController: UIHostingController private func showSessionRequest(_ request: Request) { let viewController = RequestViewController(request) viewController.onSign = { [unowned self] in - let result = Signer.sign(request: request) - respondOnSign(request: request, response: result) - reload() + do { + let result = try Signer.sign(request: request) + respondOnSign(request: request, response: result) + reload() + } catch { + fatalError(error.localizedDescription) + } } viewController.onReject = { [unowned self] in respondOnReject(request: request) diff --git a/Example/ExampleApp/Shared/Signer/Signer.swift b/Example/ExampleApp/Shared/Signer/Signer.swift index d22d863da..f7fa459c5 100644 --- a/Example/ExampleApp/Shared/Signer/Signer.swift +++ b/Example/ExampleApp/Shared/Signer/Signer.swift @@ -2,11 +2,14 @@ import Foundation import Commons import WalletConnectSign -class Signer { - +final class Signer { + enum Errors: Error { + case notImplemented + } + private init() {} - static func sign(request: Request) -> AnyCodable { + static func sign(request: Request) throws -> AnyCodable { switch request.method { case "personal_sign": return ETHSigner.personalSign(request.params) @@ -19,8 +22,17 @@ class Signer { case "solana_signTransaction": return SOLSigner.signTransaction(request.params) + default: - fatalError("not implemented") + throw Signer.Errors.notImplemented + } + } +} + +extension Signer.Errors: LocalizedError { + var errorDescription: String? { + switch self { + case .notImplemented: return "Requested method is not implemented" } } } diff --git a/Example/ExampleApp/Wallet/WalletViewController.swift b/Example/ExampleApp/Wallet/WalletViewController.swift index 349ba325e..5879a771a 100644 --- a/Example/ExampleApp/Wallet/WalletViewController.swift +++ b/Example/ExampleApp/Wallet/WalletViewController.swift @@ -82,9 +82,13 @@ final class WalletViewController: UIViewController { private func showSessionRequest(_ request: Request) { let requestVC = RequestViewController(request) requestVC.onSign = { [unowned self] in - let result = Signer.sign(request: request) - respondOnSign(request: request, response: result) - reloadSessionDetailsIfNeeded() + do { + let result = try Signer.sign(request: request) + respondOnSign(request: request, response: result) + reloadSessionDetailsIfNeeded() + } catch { + fatalError(error.localizedDescription) + } } requestVC.onReject = { [unowned self] in respondOnReject(request: request) diff --git a/Example/WalletApp/Other/Colors.xcassets/grey50.colorset/Contents.json b/Example/WalletApp/Other/Colors.xcassets/grey50.colorset/Contents.json index ec37b029c..6d4f9a370 100644 --- a/Example/WalletApp/Other/Colors.xcassets/grey50.colorset/Contents.json +++ b/Example/WalletApp/Other/Colors.xcassets/grey50.colorset/Contents.json @@ -5,9 +5,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "0x86", - "green" : "0x86", - "red" : "0x79" + "blue" : "134", + "green" : "134", + "red" : "121" } }, "idiom" : "universal" diff --git a/Example/WalletApp/PresentationLayer/Wallet/ConnectionDetails/ConnectionDetailsView.swift b/Example/WalletApp/PresentationLayer/Wallet/ConnectionDetails/ConnectionDetailsView.swift index a6a6c3593..91f2f6f57 100644 --- a/Example/WalletApp/PresentationLayer/Wallet/ConnectionDetails/ConnectionDetailsView.swift +++ b/Example/WalletApp/PresentationLayer/Wallet/ConnectionDetails/ConnectionDetailsView.swift @@ -34,6 +34,7 @@ struct ConnectionDetailsView: View { .foregroundColor(.grey50) .font(.system(size: 13, weight: .medium, design: .rounded)) } + .padding(.horizontal, 15) ForEach(presenter.session.namespaces.keys.sorted(), id: \.self) { namespace in VStack { diff --git a/Example/WalletApp/PresentationLayer/Wallet/SessionProposal/Models/Proposal.swift b/Example/WalletApp/PresentationLayer/Wallet/SessionProposal/Models/Proposal.swift deleted file mode 100644 index 437feb37b..000000000 --- a/Example/WalletApp/PresentationLayer/Wallet/SessionProposal/Models/Proposal.swift +++ /dev/null @@ -1,58 +0,0 @@ -import WalletConnectSign - -struct Proposal { - let proposerName: String - let proposerDescription: String - let proposerURL: String - let iconURL: String - let permissions: [Namespace] - - struct Namespace: Hashable { - let chains: [String] - let methods: [String] - let events: [String] - } - - internal init(proposal: Session.Proposal) { - self.proposerName = proposal.proposer.name - self.proposerDescription = proposal.proposer.description - self.proposerURL = proposal.proposer.url - self.iconURL = proposal.proposer.icons.first ?? "https://avatars.githubusercontent.com/u/37784886" - self.permissions = [ - Namespace( - chains: ["eip155:1"], - methods: ["eth_sendTransaction", "personal_sign", "eth_signTypedData"], - events: ["accountsChanged", "chainChanged"] - ) - ] - } - - internal init(proposerName: String, proposerDescription: String, proposerURL: String, iconURL: String, permissions: [Proposal.Namespace]) { - self.proposerName = proposerName - self.proposerDescription = proposerDescription - self.proposerURL = proposerURL - self.iconURL = iconURL - self.permissions = permissions - } - - static func mock() -> Proposal { - Proposal( - proposerName: "Example name", - proposerDescription: "Example description", - proposerURL: "example.url", - iconURL: "https://avatars.githubusercontent.com/u/37784886", - permissions: [ - Namespace( - chains: ["eip155:1"], - methods: ["eth_sendTransaction", "personal_sign", "eth_signTypedData"], - events: ["accountsChanged", "chainChanged"] - ), - Namespace( - chains: ["cosmos:cosmoshub-2"], - methods: ["cosmos_signDirect", "cosmos_signAmino"], - events: [] - ) - ] - ) - } -} diff --git a/Example/WalletApp/PresentationLayer/Wallet/SessionProposal/SessionProposalPresenter.swift b/Example/WalletApp/PresentationLayer/Wallet/SessionProposal/SessionProposalPresenter.swift index 8e8b6b564..3c5eca87f 100644 --- a/Example/WalletApp/PresentationLayer/Wallet/SessionProposal/SessionProposalPresenter.swift +++ b/Example/WalletApp/PresentationLayer/Wallet/SessionProposal/SessionProposalPresenter.swift @@ -7,8 +7,7 @@ final class SessionProposalPresenter: ObservableObject { private let interactor: SessionProposalInteractor private let router: SessionProposalRouter - let proposal: Proposal - private let sessionProposal: Session.Proposal + let sessionProposal: Session.Proposal private var disposeBag = Set() @@ -20,7 +19,6 @@ final class SessionProposalPresenter: ObservableObject { defer { setupInitialState() } self.interactor = interactor self.router = router - self.proposal = Proposal(proposal: proposal) self.sessionProposal = proposal } diff --git a/Example/WalletApp/PresentationLayer/Wallet/SessionProposal/SessionProposalView.swift b/Example/WalletApp/PresentationLayer/Wallet/SessionProposal/SessionProposalView.swift index b8b3fc9e6..2e18baba4 100644 --- a/Example/WalletApp/PresentationLayer/Wallet/SessionProposal/SessionProposalView.swift +++ b/Example/WalletApp/PresentationLayer/Wallet/SessionProposal/SessionProposalView.swift @@ -1,4 +1,5 @@ import SwiftUI +import Web3Wallet struct SessionProposalView: View { @EnvironmentObject var presenter: SessionProposalPresenter @@ -33,7 +34,43 @@ struct SessionProposalView: View { .lineSpacing(4) .padding(.top, 8) - sessionProposalView() + Divider() + .padding(.top, 12) + .padding(.horizontal, -18) + + ScrollView { + Text("Required namespaces".uppercased()) + .foregroundColor(.grey50) + .font(.system(size: 12, weight: .semibold, design: .rounded)) + .multilineTextAlignment(.center) + .lineSpacing(4) + .padding(.vertical, 12) + + ForEach(presenter.sessionProposal.requiredNamespaces.keys.sorted(), id: \.self) { chain in + if let namespaces = presenter.sessionProposal.requiredNamespaces[chain] { + sessionProposalView(namespaces: namespaces) + } + } + + if let optionalNamespaces = presenter.sessionProposal.optionalNamespaces { + if !optionalNamespaces.isEmpty { + Text("Optional namespaces".uppercased()) + .foregroundColor(.grey50) + .font(.system(size: 12, weight: .semibold, design: .rounded)) + .multilineTextAlignment(.center) + .lineSpacing(4) + .padding(.vertical, 12) + } + + ForEach(optionalNamespaces.keys.sorted(), id: \.self) { chain in + if let namespaces = optionalNamespaces[chain] { + sessionProposalView(namespaces: namespaces) + } + } + } + } + .frame(height: 250) + .padding(.top, 12) HStack(spacing: 20) { Button { @@ -92,19 +129,21 @@ struct SessionProposalView: View { } .edgesIgnoringSafeArea(.all) } - - private func sessionProposalView() -> some View { + //private func sessionProposalView(chain: String) -> some View { + private func sessionProposalView(namespaces: ProposalNamespace) -> some View { VStack { VStack(alignment: .leading) { - Text(presenter.proposal.permissions.first?.chains.first ?? "Chain") - .font(.system(size: 15, weight: .semibold, design: .rounded)) - .foregroundColor(.whiteBackground) - .padding(.horizontal, 8) - .padding(.vertical, 5) - .background(Color.grey70) - .cornerRadius(28, corners: .allCorners) - .padding(.leading, 15) - .padding(.top, 9) + TagsView(items: Array(namespaces.chains ?? Set())) { + Text($0.absoluteString.uppercased()) + .font(.system(size: 15, weight: .semibold, design: .rounded)) + .foregroundColor(.whiteBackground) + .padding(.horizontal, 8) + .padding(.vertical, 3) + .background(Color.grey70) + .cornerRadius(28, corners: .allCorners) + } + .padding(.horizontal, 15) + .padding(.top, 9) VStack(spacing: 0) { HStack { @@ -117,7 +156,7 @@ struct SessionProposalView: View { .padding(.horizontal, 18) .padding(.top, 10) - TagsView(items: presenter.proposal.permissions.first?.methods ?? []) { + TagsView(items: Array(namespaces.methods)) { Text($0) .foregroundColor(.cyanBackround) .font(.system(size: 13, weight: .semibold, design: .rounded)) @@ -132,37 +171,41 @@ struct SessionProposalView: View { .cornerRadius(20, corners: .allCorners) .padding(.horizontal, 5) - VStack(spacing: 0) { - HStack { - Text("Events") - .foregroundColor(.grey50) - .font(.system(size: 13, weight: .semibold, design: .rounded)) + if !namespaces.events.isEmpty { + VStack(spacing: 0) { + HStack { + Text("Events") + .foregroundColor(.grey50) + .font(.system(size: 13, weight: .semibold, design: .rounded)) + + Spacer() + } + .padding(.horizontal, 18) + .padding(.top, 10) - Spacer() - } - .padding(.horizontal, 18) - .padding(.top, 10) - - TagsView(items: presenter.proposal.permissions.first?.events ?? []) { - Text($0) - .foregroundColor(.cyanBackround) - .font(.system(size: 13, weight: .semibold, design: .rounded)) - .padding(.horizontal, 8) - .padding(.vertical, 3) - .background(Color.cyanBackround.opacity(0.2)) - .cornerRadius(10, corners: .allCorners) + TagsView(items: Array(namespaces.events)) { + Text($0) + .foregroundColor(.cyanBackround) + .font(.system(size: 13, weight: .semibold, design: .rounded)) + .padding(.horizontal, 8) + .padding(.vertical, 3) + .background(Color.cyanBackround.opacity(0.2)) + .cornerRadius(10, corners: .allCorners) + } + .padding(10) } - .padding(10) + .background(Color.whiteBackground) + .cornerRadius(20, corners: .allCorners) + .padding(.horizontal, 5) + .padding(.bottom, 5) + } else { + Spacer(minLength: 5) } - .background(Color.whiteBackground) - .cornerRadius(20, corners: .allCorners) - .padding(.horizontal, 5) - .padding(.bottom, 5) } .background(.thinMaterial) .cornerRadius(25, corners: .allCorners) } - .padding(.top, 30) + .padding(.bottom, 15) } } diff --git a/Example/WalletApp/PresentationLayer/Wallet/SessionRequest/SessionRequestInteractor.swift b/Example/WalletApp/PresentationLayer/Wallet/SessionRequest/SessionRequestInteractor.swift index dce7d5fca..11aa20ce8 100644 --- a/Example/WalletApp/PresentationLayer/Wallet/SessionRequest/SessionRequestInteractor.swift +++ b/Example/WalletApp/PresentationLayer/Wallet/SessionRequest/SessionRequestInteractor.swift @@ -3,12 +3,16 @@ import Web3Wallet final class SessionRequestInteractor { func approve(sessionRequest: Request) async throws { - let result = Signer.sign(request: sessionRequest) - try await Web3Wallet.instance.respond( - topic: sessionRequest.topic, - requestId: sessionRequest.id, - response: .response(result) - ) + do { + let result = try Signer.sign(request: sessionRequest) + try await Web3Wallet.instance.respond( + topic: sessionRequest.topic, + requestId: sessionRequest.id, + response: .response(result) + ) + } catch { + throw error + } } func reject(sessionRequest: Request) async throws { diff --git a/Example/WalletApp/PresentationLayer/Wallet/SessionRequest/SessionRequestPresenter.swift b/Example/WalletApp/PresentationLayer/Wallet/SessionRequest/SessionRequestPresenter.swift index bdff02f2b..c811d9f77 100644 --- a/Example/WalletApp/PresentationLayer/Wallet/SessionRequest/SessionRequestPresenter.swift +++ b/Example/WalletApp/PresentationLayer/Wallet/SessionRequest/SessionRequestPresenter.swift @@ -7,6 +7,9 @@ final class SessionRequestPresenter: ObservableObject { private let interactor: SessionRequestInteractor private let router: SessionRequestRouter + @Published var showError = false + @Published var errorMessage = "Error" + let sessionRequest: Request var message: String { @@ -28,8 +31,13 @@ final class SessionRequestPresenter: ObservableObject { @MainActor func onApprove() async throws { - try await interactor.approve(sessionRequest: sessionRequest) - router.dismiss() + do { + try await interactor.approve(sessionRequest: sessionRequest) + router.dismiss() + } catch { + errorMessage = error.localizedDescription + showError.toggle() + } } @MainActor diff --git a/Example/WalletApp/PresentationLayer/Wallet/SessionRequest/SessionRequestView.swift b/Example/WalletApp/PresentationLayer/Wallet/SessionRequest/SessionRequestView.swift index 053cb34c2..e6a719606 100644 --- a/Example/WalletApp/PresentationLayer/Wallet/SessionRequest/SessionRequestView.swift +++ b/Example/WalletApp/PresentationLayer/Wallet/SessionRequest/SessionRequestView.swift @@ -22,7 +22,9 @@ struct SessionRequestView: View { .font(.system(size: 22, weight: .bold, design: .rounded)) .padding(.top, 10) - authRequestView() + if presenter.message != "[:]" { + authRequestView() + } HStack(spacing: 20) { Button { @@ -78,6 +80,9 @@ struct SessionRequestView: View { Spacer() } + .alert(presenter.errorMessage, isPresented: $presenter.showError) { + Button("OK", role: .cancel) {} + } } .edgesIgnoringSafeArea(.all) } From 6b8d616acb0f9179dd53e97043e6777e0d7d5e77 Mon Sep 17 00:00:00 2001 From: Alexander Lisovik Date: Thu, 9 Mar 2023 09:13:32 +0100 Subject: [PATCH 02/15] Update proposer name --- .../Wallet/SessionProposal/SessionProposalView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Example/WalletApp/PresentationLayer/Wallet/SessionProposal/SessionProposalView.swift b/Example/WalletApp/PresentationLayer/Wallet/SessionProposal/SessionProposalView.swift index 2e18baba4..9c69a7043 100644 --- a/Example/WalletApp/PresentationLayer/Wallet/SessionProposal/SessionProposalView.swift +++ b/Example/WalletApp/PresentationLayer/Wallet/SessionProposal/SessionProposalView.swift @@ -18,7 +18,7 @@ struct SessionProposalView: View { .resizable() .scaledToFit() - Text(presenter.proposal.proposerName) + Text(presenter.sessionProposal.proposer.name) .foregroundColor(.grey8) .font(.system(size: 22, weight: .bold, design: .rounded)) .padding(.top, 10) @@ -27,7 +27,7 @@ struct SessionProposalView: View { .foregroundColor(.grey8) .font(.system(size: 22, weight: .medium, design: .rounded)) - Text(presenter.proposal.proposerName) + Text(presenter.sessionProposal.proposer.name) .foregroundColor(.grey50) .font(.system(size: 13, weight: .semibold, design: .rounded)) .multilineTextAlignment(.center) From e7f7f3b5958755d26c97b5d46b20da72a66d3fbb Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Thu, 9 Mar 2023 10:58:03 +0100 Subject: [PATCH 03/15] add irn integration test target --- Example/ExampleApp.xcodeproj/project.pbxproj | 158 +++++++++++++++++++ 1 file changed, 158 insertions(+) diff --git a/Example/ExampleApp.xcodeproj/project.pbxproj b/Example/ExampleApp.xcodeproj/project.pbxproj index 0466e71ae..56fd2a49c 100644 --- a/Example/ExampleApp.xcodeproj/project.pbxproj +++ b/Example/ExampleApp.xcodeproj/project.pbxproj @@ -30,6 +30,13 @@ 840BCF142949B9F900CB0655 /* WalletConnectPush in Frameworks */ = {isa = PBXBuildFile; productRef = 840BCF132949B9F900CB0655 /* WalletConnectPush */; }; 84310D05298BC980000C15B6 /* MainInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84310D04298BC980000C15B6 /* MainInteractor.swift */; }; 8439CB89293F658E00F2F2E2 /* PushMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8439CB88293F658E00F2F2E2 /* PushMessage.swift */; }; + 844749C029B9E355005F520B /* WalletConnect in Frameworks */ = {isa = PBXBuildFile; productRef = 844749A129B9E355005F520B /* WalletConnect */; }; + 844749C129B9E355005F520B /* Starscream in Frameworks */ = {isa = PBXBuildFile; productRef = 8447499F29B9E355005F520B /* Starscream */; }; + 844749C229B9E355005F520B /* WalletConnectPush in Frameworks */ = {isa = PBXBuildFile; productRef = 844749A429B9E355005F520B /* WalletConnectPush */; settings = {ATTRIBUTES = (Required, ); }; }; + 844749C329B9E355005F520B /* Web3 in Frameworks */ = {isa = PBXBuildFile; productRef = 844749A529B9E355005F520B /* Web3 */; }; + 844749C429B9E355005F520B /* WalletConnectAuth in Frameworks */ = {isa = PBXBuildFile; productRef = 844749A329B9E355005F520B /* WalletConnectAuth */; }; + 844749C529B9E355005F520B /* Web3Wallet in Frameworks */ = {isa = PBXBuildFile; productRef = 844749A729B9E355005F520B /* Web3Wallet */; }; + 844749C629B9E355005F520B /* WalletConnectChat in Frameworks */ = {isa = PBXBuildFile; productRef = 844749A229B9E355005F520B /* WalletConnectChat */; }; 8448F1D427E4726F0000B866 /* WalletConnect in Frameworks */ = {isa = PBXBuildFile; productRef = 8448F1D327E4726F0000B866 /* WalletConnect */; }; 84494388278D9C1B00CC26BB /* UIAlertController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84494387278D9C1B00CC26BB /* UIAlertController.swift */; }; 845B8D8C2934B36C0084A966 /* Account.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845B8D8B2934B36C0084A966 /* Account.swift */; }; @@ -381,6 +388,7 @@ 8414FC832962F3D9007E20C9 /* PushDecryptionService.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PushDecryptionService.entitlements; sourceTree = ""; }; 84310D04298BC980000C15B6 /* MainInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainInteractor.swift; sourceTree = ""; }; 8439CB88293F658E00F2F2E2 /* PushMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PushMessage.swift; sourceTree = ""; }; + 844749CB29B9E355005F520B /* IrnIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = IrnIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 84494387278D9C1B00CC26BB /* UIAlertController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIAlertController.swift; sourceTree = ""; }; 845B8D8B2934B36C0084A966 /* Account.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Account.swift; sourceTree = ""; }; 8460DCFB274F98A10081F94C /* RequestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestViewController.swift; sourceTree = ""; }; @@ -631,6 +639,20 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 844749BF29B9E355005F520B /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 844749C029B9E355005F520B /* WalletConnect in Frameworks */, + 844749C129B9E355005F520B /* Starscream in Frameworks */, + 844749C229B9E355005F520B /* WalletConnectPush in Frameworks */, + 844749C329B9E355005F520B /* Web3 in Frameworks */, + 844749C429B9E355005F520B /* WalletConnectAuth in Frameworks */, + 844749C529B9E355005F520B /* Web3Wallet in Frameworks */, + 844749C629B9E355005F520B /* WalletConnectChat in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 84B767732954554A00E92316 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -778,6 +800,7 @@ 84B767762954554A00E92316 /* PushDecryptionService.appex */, C56EE21B293F55ED004840D1 /* WalletApp.app */, 84E6B84729787A8000428BAF /* PNDecryptionService.appex */, + 844749CB29B9E355005F520B /* IrnIntegrationTests.xctest */, ); name = Products; sourceTree = ""; @@ -1769,6 +1792,32 @@ productReference = 764E1D3C26F8D3FC00A1FB15 /* WalletConnect Wallet.app */; productType = "com.apple.product-type.application"; }; + 8447499E29B9E355005F520B /* IrnIntegrationTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 844749C829B9E355005F520B /* Build configuration list for PBXNativeTarget "IrnIntegrationTests" */; + buildPhases = ( + 844749A829B9E355005F520B /* Sources */, + 844749BF29B9E355005F520B /* Frameworks */, + 844749C729B9E355005F520B /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = IrnIntegrationTests; + packageProductDependencies = ( + 8447499F29B9E355005F520B /* Starscream */, + 844749A129B9E355005F520B /* WalletConnect */, + 844749A229B9E355005F520B /* WalletConnectChat */, + 844749A329B9E355005F520B /* WalletConnectAuth */, + 844749A429B9E355005F520B /* WalletConnectPush */, + 844749A529B9E355005F520B /* Web3 */, + 844749A729B9E355005F520B /* Web3Wallet */, + ); + productName = IntegrationTests; + productReference = 844749CB29B9E355005F520B /* IrnIntegrationTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; 84B767752954554A00E92316 /* PushDecryptionService */ = { isa = PBXNativeTarget; buildConfigurationList = 84B767812954554A00E92316 /* Build configuration list for PBXNativeTarget "PushDecryptionService" */; @@ -1993,6 +2042,7 @@ 84B767752954554A00E92316 /* PushDecryptionService */, C56EE21A293F55ED004840D1 /* WalletApp */, 84E6B84629787A8000428BAF /* PNDecryptionService */, + 8447499E29B9E355005F520B /* IrnIntegrationTests */, ); }; /* End PBXProject section */ @@ -2007,6 +2057,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 844749C729B9E355005F520B /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 84B767742954554A00E92316 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -2100,6 +2157,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 844749A829B9E355005F520B /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 84B767722954554A00E92316 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -2590,6 +2654,45 @@ }; name = Release; }; + 844749C929B9E355005F520B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 7; + DEVELOPMENT_TEAM = W5R8AG9K22; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + "RELAY_HOST=$(RELAY_HOST)", + ); + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + PRODUCT_BUNDLE_IDENTIFIER = com.walletconnect.IrnIntegrationTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 844749CA29B9E355005F520B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 7; + DEVELOPMENT_TEAM = W5R8AG9K22; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + PRODUCT_BUNDLE_IDENTIFIER = com.walletconnect.IrnIntegrationTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; 84B7677F2954554A00E92316 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -3025,6 +3128,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 844749C829B9E355005F520B /* Build configuration list for PBXNativeTarget "IrnIntegrationTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 844749C929B9E355005F520B /* Debug */, + 844749CA29B9E355005F520B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 84B767812954554A00E92316 /* Build configuration list for PBXNativeTarget "PushDecryptionService" */ = { isa = XCConfigurationList; buildConfigurations = ( @@ -3091,6 +3203,22 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ + 844749A029B9E355005F520B /* XCRemoteSwiftPackageReference "Starscream" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/daltoniam/Starscream"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 3.0.0; + }; + }; + 844749A629B9E355005F520B /* XCRemoteSwiftPackageReference "Web3" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/WalletConnect/Web3.swift"; + requirement = { + kind = exactVersion; + version = 1.0.2; + }; + }; A5434021291E6A270068F706 /* XCRemoteSwiftPackageReference "solana-swift" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/flypaper0/solana-swift"; @@ -3134,6 +3262,36 @@ isa = XCSwiftPackageProductDependency; productName = WalletConnectPush; }; + 8447499F29B9E355005F520B /* Starscream */ = { + isa = XCSwiftPackageProductDependency; + package = 844749A029B9E355005F520B /* XCRemoteSwiftPackageReference "Starscream" */; + productName = Starscream; + }; + 844749A129B9E355005F520B /* WalletConnect */ = { + isa = XCSwiftPackageProductDependency; + productName = WalletConnect; + }; + 844749A229B9E355005F520B /* WalletConnectChat */ = { + isa = XCSwiftPackageProductDependency; + productName = WalletConnectChat; + }; + 844749A329B9E355005F520B /* WalletConnectAuth */ = { + isa = XCSwiftPackageProductDependency; + productName = WalletConnectAuth; + }; + 844749A429B9E355005F520B /* WalletConnectPush */ = { + isa = XCSwiftPackageProductDependency; + productName = WalletConnectPush; + }; + 844749A529B9E355005F520B /* Web3 */ = { + isa = XCSwiftPackageProductDependency; + package = 844749A629B9E355005F520B /* XCRemoteSwiftPackageReference "Web3" */; + productName = Web3; + }; + 844749A729B9E355005F520B /* Web3Wallet */ = { + isa = XCSwiftPackageProductDependency; + productName = Web3Wallet; + }; 8448F1D327E4726F0000B866 /* WalletConnect */ = { isa = XCSwiftPackageProductDependency; productName = WalletConnect; From 806aa4b386ecd55f250213cf8ece7d9345167c70 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Thu, 9 Mar 2023 12:16:11 +0100 Subject: [PATCH 04/15] Add relay integration tests scheme --- Example/ExampleApp.xcodeproj/project.pbxproj | 148 +++++++----------- .../xcschemes/PushDecryptionService.xcscheme | 11 ++ .../xcschemes/RelayIntegrationTests.xcscheme | 74 +++++++++ .../xcshareddata/xcschemes/Wallet.xcscheme | 11 ++ .../RelayClientEndToEndTests.swift | 100 ++++++++++++ 5 files changed, 253 insertions(+), 91 deletions(-) create mode 100644 Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/RelayIntegrationTests.xcscheme create mode 100644 Example/RelayIntegrationTests/RelayClientEndToEndTests.swift diff --git a/Example/ExampleApp.xcodeproj/project.pbxproj b/Example/ExampleApp.xcodeproj/project.pbxproj index 56fd2a49c..4b8e34a1c 100644 --- a/Example/ExampleApp.xcodeproj/project.pbxproj +++ b/Example/ExampleApp.xcodeproj/project.pbxproj @@ -30,13 +30,12 @@ 840BCF142949B9F900CB0655 /* WalletConnectPush in Frameworks */ = {isa = PBXBuildFile; productRef = 840BCF132949B9F900CB0655 /* WalletConnectPush */; }; 84310D05298BC980000C15B6 /* MainInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84310D04298BC980000C15B6 /* MainInteractor.swift */; }; 8439CB89293F658E00F2F2E2 /* PushMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8439CB88293F658E00F2F2E2 /* PushMessage.swift */; }; - 844749C029B9E355005F520B /* WalletConnect in Frameworks */ = {isa = PBXBuildFile; productRef = 844749A129B9E355005F520B /* WalletConnect */; }; - 844749C129B9E355005F520B /* Starscream in Frameworks */ = {isa = PBXBuildFile; productRef = 8447499F29B9E355005F520B /* Starscream */; }; - 844749C229B9E355005F520B /* WalletConnectPush in Frameworks */ = {isa = PBXBuildFile; productRef = 844749A429B9E355005F520B /* WalletConnectPush */; settings = {ATTRIBUTES = (Required, ); }; }; - 844749C329B9E355005F520B /* Web3 in Frameworks */ = {isa = PBXBuildFile; productRef = 844749A529B9E355005F520B /* Web3 */; }; - 844749C429B9E355005F520B /* WalletConnectAuth in Frameworks */ = {isa = PBXBuildFile; productRef = 844749A329B9E355005F520B /* WalletConnectAuth */; }; - 844749C529B9E355005F520B /* Web3Wallet in Frameworks */ = {isa = PBXBuildFile; productRef = 844749A729B9E355005F520B /* Web3Wallet */; }; - 844749C629B9E355005F520B /* WalletConnectChat in Frameworks */ = {isa = PBXBuildFile; productRef = 844749A229B9E355005F520B /* WalletConnectChat */; }; + 844749F629B9E5B9005F520B /* RelayClientEndToEndTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844749F529B9E5B9005F520B /* RelayClientEndToEndTests.swift */; }; + 844749FD29B9E6B2005F520B /* WalletConnectNetworking in Frameworks */ = {isa = PBXBuildFile; productRef = 844749FC29B9E6B2005F520B /* WalletConnectNetworking */; }; + 844749FE29B9EB1B005F520B /* InputConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = A518B31328E33A6500A2CE93 /* InputConfig.swift */; }; + 844749FF29B9EB3B005F520B /* KeychainStorageMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E03E1028646F8000888481 /* KeychainStorageMock.swift */; }; + 84474A0129B9EB74005F520B /* Starscream in Frameworks */ = {isa = PBXBuildFile; productRef = 84474A0029B9EB74005F520B /* Starscream */; }; + 84474A0229B9ECA2005F520B /* DefaultSocketFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5629AEF2877F73000094373 /* DefaultSocketFactory.swift */; }; 8448F1D427E4726F0000B866 /* WalletConnect in Frameworks */ = {isa = PBXBuildFile; productRef = 8448F1D327E4726F0000B866 /* WalletConnect */; }; 84494388278D9C1B00CC26BB /* UIAlertController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84494387278D9C1B00CC26BB /* UIAlertController.swift */; }; 845B8D8C2934B36C0084A966 /* Account.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845B8D8B2934B36C0084A966 /* Account.swift */; }; @@ -388,7 +387,8 @@ 8414FC832962F3D9007E20C9 /* PushDecryptionService.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PushDecryptionService.entitlements; sourceTree = ""; }; 84310D04298BC980000C15B6 /* MainInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainInteractor.swift; sourceTree = ""; }; 8439CB88293F658E00F2F2E2 /* PushMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PushMessage.swift; sourceTree = ""; }; - 844749CB29B9E355005F520B /* IrnIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = IrnIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 844749F329B9E5B9005F520B /* RelayIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RelayIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 844749F529B9E5B9005F520B /* RelayClientEndToEndTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayClientEndToEndTests.swift; sourceTree = ""; }; 84494387278D9C1B00CC26BB /* UIAlertController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIAlertController.swift; sourceTree = ""; }; 845B8D8B2934B36C0084A966 /* Account.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Account.swift; sourceTree = ""; }; 8460DCFB274F98A10081F94C /* RequestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestViewController.swift; sourceTree = ""; }; @@ -639,17 +639,12 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 844749BF29B9E355005F520B /* Frameworks */ = { + 844749F029B9E5B9005F520B /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 844749C029B9E355005F520B /* WalletConnect in Frameworks */, - 844749C129B9E355005F520B /* Starscream in Frameworks */, - 844749C229B9E355005F520B /* WalletConnectPush in Frameworks */, - 844749C329B9E355005F520B /* Web3 in Frameworks */, - 844749C429B9E355005F520B /* WalletConnectAuth in Frameworks */, - 844749C529B9E355005F520B /* Web3Wallet in Frameworks */, - 844749C629B9E355005F520B /* WalletConnectChat in Frameworks */, + 844749FD29B9E6B2005F520B /* WalletConnectNetworking in Frameworks */, + 84474A0129B9EB74005F520B /* Starscream in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -783,6 +778,7 @@ 84B767772954554A00E92316 /* PushDecryptionService */, C56EE21C293F55ED004840D1 /* WalletApp */, 84E6B84829787A8000428BAF /* PNDecryptionService */, + 844749F429B9E5B9005F520B /* RelayIntegrationTests */, 764E1D3D26F8D3FC00A1FB15 /* Products */, 764E1D5326F8DAC800A1FB15 /* Frameworks */, 764E1D5626F8DB6000A1FB15 /* WalletConnectSwiftV2 */, @@ -800,7 +796,7 @@ 84B767762954554A00E92316 /* PushDecryptionService.appex */, C56EE21B293F55ED004840D1 /* WalletApp.app */, 84E6B84729787A8000428BAF /* PNDecryptionService.appex */, - 844749CB29B9E355005F520B /* IrnIntegrationTests.xctest */, + 844749F329B9E5B9005F520B /* RelayIntegrationTests.xctest */, ); name = Products; sourceTree = ""; @@ -842,6 +838,14 @@ path = Helpers; sourceTree = ""; }; + 844749F429B9E5B9005F520B /* RelayIntegrationTests */ = { + isa = PBXGroup; + children = ( + 844749F529B9E5B9005F520B /* RelayClientEndToEndTests.swift */, + ); + path = RelayIntegrationTests; + sourceTree = ""; + }; 8460DCFD274F98A90081F94C /* Request */ = { isa = PBXGroup; children = ( @@ -1792,30 +1796,25 @@ productReference = 764E1D3C26F8D3FC00A1FB15 /* WalletConnect Wallet.app */; productType = "com.apple.product-type.application"; }; - 8447499E29B9E355005F520B /* IrnIntegrationTests */ = { + 844749F229B9E5B9005F520B /* RelayIntegrationTests */ = { isa = PBXNativeTarget; - buildConfigurationList = 844749C829B9E355005F520B /* Build configuration list for PBXNativeTarget "IrnIntegrationTests" */; + buildConfigurationList = 844749FB29B9E5B9005F520B /* Build configuration list for PBXNativeTarget "RelayIntegrationTests" */; buildPhases = ( - 844749A829B9E355005F520B /* Sources */, - 844749BF29B9E355005F520B /* Frameworks */, - 844749C729B9E355005F520B /* Resources */, + 844749EF29B9E5B9005F520B /* Sources */, + 844749F029B9E5B9005F520B /* Frameworks */, + 844749F129B9E5B9005F520B /* Resources */, ); buildRules = ( ); dependencies = ( ); - name = IrnIntegrationTests; + name = RelayIntegrationTests; packageProductDependencies = ( - 8447499F29B9E355005F520B /* Starscream */, - 844749A129B9E355005F520B /* WalletConnect */, - 844749A229B9E355005F520B /* WalletConnectChat */, - 844749A329B9E355005F520B /* WalletConnectAuth */, - 844749A429B9E355005F520B /* WalletConnectPush */, - 844749A529B9E355005F520B /* Web3 */, - 844749A729B9E355005F520B /* Web3Wallet */, + 844749FC29B9E6B2005F520B /* WalletConnectNetworking */, + 84474A0029B9EB74005F520B /* Starscream */, ); - productName = IntegrationTests; - productReference = 844749CB29B9E355005F520B /* IrnIntegrationTests.xctest */; + productName = RelayIntegrationTests; + productReference = 844749F329B9E5B9005F520B /* RelayIntegrationTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; 84B767752954554A00E92316 /* PushDecryptionService */ = { @@ -1992,6 +1991,9 @@ 764E1D3B26F8D3FC00A1FB15 = { CreatedOnToolsVersion = 12.5.1; }; + 844749F229B9E5B9005F520B = { + CreatedOnToolsVersion = 14.2; + }; 84B767752954554A00E92316 = { CreatedOnToolsVersion = 14.2; }; @@ -2042,7 +2044,7 @@ 84B767752954554A00E92316 /* PushDecryptionService */, C56EE21A293F55ED004840D1 /* WalletApp */, 84E6B84629787A8000428BAF /* PNDecryptionService */, - 8447499E29B9E355005F520B /* IrnIntegrationTests */, + 844749F229B9E5B9005F520B /* RelayIntegrationTests */, ); }; /* End PBXProject section */ @@ -2057,7 +2059,7 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 844749C729B9E355005F520B /* Resources */ = { + 844749F129B9E5B9005F520B /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( @@ -2157,10 +2159,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 844749A829B9E355005F520B /* Sources */ = { + 844749EF29B9E5B9005F520B /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 84474A0229B9ECA2005F520B /* DefaultSocketFactory.swift in Sources */, + 844749FF29B9EB3B005F520B /* KeychainStorageMock.swift in Sources */, + 844749FE29B9EB1B005F520B /* InputConfig.swift in Sources */, + 844749F629B9E5B9005F520B /* RelayClientEndToEndTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2654,21 +2660,17 @@ }; name = Release; }; - 844749C929B9E355005F520B /* Debug */ = { + 844749F929B9E5B9005F520B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = W5R8AG9K22; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - "RELAY_HOST=$(RELAY_HOST)", - ); GENERATE_INFOPLIST_FILE = YES; IPHONEOS_DEPLOYMENT_TARGET = 13.0; - PRODUCT_BUNDLE_IDENTIFIER = com.walletconnect.IrnIntegrationTests; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.walletconnect.RelayIntegrationTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = NO; SWIFT_VERSION = 5.0; @@ -2676,16 +2678,17 @@ }; name = Debug; }; - 844749CA29B9E355005F520B /* Release */ = { + 844749FA29B9E5B9005F520B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = W5R8AG9K22; GENERATE_INFOPLIST_FILE = YES; IPHONEOS_DEPLOYMENT_TARGET = 13.0; - PRODUCT_BUNDLE_IDENTIFIER = com.walletconnect.IrnIntegrationTests; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.walletconnect.RelayIntegrationTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = NO; SWIFT_VERSION = 5.0; @@ -3128,11 +3131,11 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 844749C829B9E355005F520B /* Build configuration list for PBXNativeTarget "IrnIntegrationTests" */ = { + 844749FB29B9E5B9005F520B /* Build configuration list for PBXNativeTarget "RelayIntegrationTests" */ = { isa = XCConfigurationList; buildConfigurations = ( - 844749C929B9E355005F520B /* Debug */, - 844749CA29B9E355005F520B /* Release */, + 844749F929B9E5B9005F520B /* Debug */, + 844749FA29B9E5B9005F520B /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; @@ -3203,22 +3206,6 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - 844749A029B9E355005F520B /* XCRemoteSwiftPackageReference "Starscream" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/daltoniam/Starscream"; - requirement = { - kind = upToNextMajorVersion; - minimumVersion = 3.0.0; - }; - }; - 844749A629B9E355005F520B /* XCRemoteSwiftPackageReference "Web3" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/WalletConnect/Web3.swift"; - requirement = { - kind = exactVersion; - version = 1.0.2; - }; - }; A5434021291E6A270068F706 /* XCRemoteSwiftPackageReference "solana-swift" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/flypaper0/solana-swift"; @@ -3262,35 +3249,14 @@ isa = XCSwiftPackageProductDependency; productName = WalletConnectPush; }; - 8447499F29B9E355005F520B /* Starscream */ = { + 844749FC29B9E6B2005F520B /* WalletConnectNetworking */ = { isa = XCSwiftPackageProductDependency; - package = 844749A029B9E355005F520B /* XCRemoteSwiftPackageReference "Starscream" */; - productName = Starscream; - }; - 844749A129B9E355005F520B /* WalletConnect */ = { - isa = XCSwiftPackageProductDependency; - productName = WalletConnect; - }; - 844749A229B9E355005F520B /* WalletConnectChat */ = { - isa = XCSwiftPackageProductDependency; - productName = WalletConnectChat; + productName = WalletConnectNetworking; }; - 844749A329B9E355005F520B /* WalletConnectAuth */ = { + 84474A0029B9EB74005F520B /* Starscream */ = { isa = XCSwiftPackageProductDependency; - productName = WalletConnectAuth; - }; - 844749A429B9E355005F520B /* WalletConnectPush */ = { - isa = XCSwiftPackageProductDependency; - productName = WalletConnectPush; - }; - 844749A529B9E355005F520B /* Web3 */ = { - isa = XCSwiftPackageProductDependency; - package = 844749A629B9E355005F520B /* XCRemoteSwiftPackageReference "Web3" */; - productName = Web3; - }; - 844749A729B9E355005F520B /* Web3Wallet */ = { - isa = XCSwiftPackageProductDependency; - productName = Web3Wallet; + package = A5D85224286333D500DAF5C3 /* XCRemoteSwiftPackageReference "Starscream" */; + productName = Starscream; }; 8448F1D327E4726F0000B866 /* WalletConnect */ = { isa = XCSwiftPackageProductDependency; diff --git a/Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/PushDecryptionService.xcscheme b/Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/PushDecryptionService.xcscheme index 59e2134d6..66122a584 100644 --- a/Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/PushDecryptionService.xcscheme +++ b/Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/PushDecryptionService.xcscheme @@ -43,6 +43,17 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/Wallet.xcscheme b/Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/Wallet.xcscheme index 5c9f393ee..d786c3306 100644 --- a/Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/Wallet.xcscheme +++ b/Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/Wallet.xcscheme @@ -48,6 +48,17 @@ ReferencedContainer = "container:ExampleApp.xcodeproj"> + + + + () + + func makeRelayClient() -> RelayClient { + let clientIdStorage = ClientIdStorage(keychain: KeychainStorageMock()) + let socketAuthenticator = SocketAuthenticator( + clientIdStorage: clientIdStorage, + relayHost: InputConfig.relayHost + ) + let urlFactory = RelayUrlFactory(socketAuthenticator: socketAuthenticator) + let socket = WebSocket(url: urlFactory.create(host: InputConfig.relayHost, projectId: InputConfig.projectId)) + + let logger = ConsoleLogger() + let dispatcher = Dispatcher(socket: socket, socketConnectionHandler: ManualSocketConnectionHandler(socket: socket), logger: logger) + return RelayClient(dispatcher: dispatcher, logger: logger, keyValueStorage: RuntimeKeyValueStorage(), clientIdStorage: clientIdStorage) + } + + func testSubscribe() { + let relayClient = makeRelayClient() + + try! relayClient.connect() + let subscribeExpectation = expectation(description: "subscribe call succeeds") + subscribeExpectation.assertForOverFulfill = true + relayClient.socketConnectionStatusPublisher.sink { status in + if status == .connected { + Task(priority: .high) { try await relayClient.subscribe(topic: "ecb78f2df880c43d3418ddbf871092b847801932e21765b250cc50b9e96a9131") } + subscribeExpectation.fulfill() + } + }.store(in: &publishers) + + wait(for: [subscribeExpectation], timeout: InputConfig.defaultTimeout) + } + + func testEndToEndPayload() { + let relayA = makeRelayClient() + let relayB = makeRelayClient() + + try! relayA.connect() + try! relayB.connect() + + let randomTopic = String.randomTopic() + let payloadA = "A" + let payloadB = "B" + var subscriptionATopic: String! + var subscriptionBTopic: String! + var subscriptionAPayload: String! + var subscriptionBPayload: String! + + let expectationA = expectation(description: "publish payloads send and receive successfuly") + let expectationB = expectation(description: "publish payloads send and receive successfuly") + + expectationA.assertForOverFulfill = false + expectationB.assertForOverFulfill = false + + relayA.messagePublisher.sink { topic, payload, _ in + (subscriptionATopic, subscriptionAPayload) = (topic, payload) + expectationA.fulfill() + }.store(in: &publishers) + + relayB.messagePublisher.sink { topic, payload, _ in + (subscriptionBTopic, subscriptionBPayload) = (topic, payload) + expectationB.fulfill() + }.store(in: &publishers) + + relayA.socketConnectionStatusPublisher.sink { _ in + Task(priority: .high) { + try await relayA.publish(topic: randomTopic, payload: payloadA, tag: 0, prompt: false, ttl: 60) + try await relayA.subscribe(topic: randomTopic) + } + }.store(in: &publishers) + relayB.socketConnectionStatusPublisher.sink { _ in + Task(priority: .high) { + try await relayB.publish(topic: randomTopic, payload: payloadB, tag: 0, prompt: false, ttl: 60) + try await relayB.subscribe(topic: randomTopic) + } + }.store(in: &publishers) + + wait(for: [expectationA, expectationB], timeout: InputConfig.defaultTimeout) + + XCTAssertEqual(subscriptionATopic, randomTopic) + XCTAssertEqual(subscriptionBTopic, randomTopic) + + XCTAssertEqual(subscriptionBPayload, payloadA) + XCTAssertEqual(subscriptionAPayload, payloadB) + } +} + +extension String { + static func randomTopic() -> String { + "\(UUID().uuidString)\(UUID().uuidString)".replacingOccurrences(of: "-", with: "").lowercased() + } +} From 8df8117cb244fad37b688cfa017039acfcec0b29 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Thu, 9 Mar 2023 12:41:51 +0100 Subject: [PATCH 05/15] update files locations --- Example/ExampleApp.xcodeproj/project.pbxproj | 12 ++++++++++-- .../Stubs => Shared/Tests}/InputConfig.swift | 0 .../Stubs => Shared/Tests}/KeychainStorageMock.swift | 0 3 files changed, 10 insertions(+), 2 deletions(-) rename Example/{IntegrationTests/Stubs => Shared/Tests}/InputConfig.swift (100%) rename Example/{IntegrationTests/Stubs => Shared/Tests}/KeychainStorageMock.swift (100%) diff --git a/Example/ExampleApp.xcodeproj/project.pbxproj b/Example/ExampleApp.xcodeproj/project.pbxproj index 4b8e34a1c..2de06eeb9 100644 --- a/Example/ExampleApp.xcodeproj/project.pbxproj +++ b/Example/ExampleApp.xcodeproj/project.pbxproj @@ -947,6 +947,15 @@ path = Models; sourceTree = ""; }; + 84CB43D429B9FC88004DDA31 /* Tests */ = { + isa = PBXGroup; + children = ( + A5E03E1028646F8000888481 /* KeychainStorageMock.swift */, + A518B31328E33A6500A2CE93 /* InputConfig.swift */, + ); + path = Tests; + sourceTree = ""; + }; 84CE641D27981DED00142511 /* DApp */ = { isa = PBXGroup; children = ( @@ -1367,6 +1376,7 @@ A5A8E479293A1C4400FEB97D /* Shared */ = { isa = PBXGroup; children = ( + 84CB43D429B9FC88004DDA31 /* Tests */, A5629AEF2877F73000094373 /* DefaultSocketFactory.swift */, A59CF4F5292F83D50031A42F /* DefaultSignerFactory.swift */, ); @@ -1483,8 +1493,6 @@ A5E03E0A28646A8A00888481 /* Stubs */ = { isa = PBXGroup; children = ( - A518B31328E33A6500A2CE93 /* InputConfig.swift */, - A5E03E1028646F8000888481 /* KeychainStorageMock.swift */, A5E03DFC286465D100888481 /* Stubs.swift */, 84FE684528ACDB4700C893FF /* RequestParams.swift */, 845B8D8B2934B36C0084A966 /* Account.swift */, diff --git a/Example/IntegrationTests/Stubs/InputConfig.swift b/Example/Shared/Tests/InputConfig.swift similarity index 100% rename from Example/IntegrationTests/Stubs/InputConfig.swift rename to Example/Shared/Tests/InputConfig.swift diff --git a/Example/IntegrationTests/Stubs/KeychainStorageMock.swift b/Example/Shared/Tests/KeychainStorageMock.swift similarity index 100% rename from Example/IntegrationTests/Stubs/KeychainStorageMock.swift rename to Example/Shared/Tests/KeychainStorageMock.swift From 6463e2ea8cbf542af14adf99596adedc339a76a5 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Thu, 9 Mar 2023 15:14:14 +0100 Subject: [PATCH 06/15] add test plan --- .../IntegrationTests.xctestplan | 77 +++++++++++++++++++ Example/ExampleApp.xcodeproj/project.pbxproj | 2 + .../xcschemes/IntegrationTests.xcscheme | 17 ++-- 3 files changed, 86 insertions(+), 10 deletions(-) create mode 100644 Example/ExampleApp.xcodeproj/IntegrationTests.xctestplan diff --git a/Example/ExampleApp.xcodeproj/IntegrationTests.xctestplan b/Example/ExampleApp.xcodeproj/IntegrationTests.xctestplan new file mode 100644 index 000000000..a9ef3ebcc --- /dev/null +++ b/Example/ExampleApp.xcodeproj/IntegrationTests.xctestplan @@ -0,0 +1,77 @@ +{ + "configurations" : [ + { + "id" : "BAABD63B-F7E2-4928-AD6F-325C999C17BB", + "name" : "Smoke Tests", + "options" : { + + } + } + ], + "defaultOptions" : { + "codeCoverage" : false, + "environmentVariableEntries" : [ + { + "key" : "RELAY_HOST", + "value" : "$(RELAY_HOST)" + }, + { + "key" : "PROJECT_ID", + "value" : "$(PROJECT_ID)" + } + ], + "targetForVariableExpansion" : { + "containerPath" : "container:ExampleApp.xcodeproj", + "identifier" : "A5E03DEC286464DB00888481", + "name" : "IntegrationTests" + } + }, + "testTargets" : [ + { + "skippedTests" : [ + "AuthTests\/testEIP1271RespondSuccess()", + "AuthTests\/testEIP191RespondError()", + "AuthTests\/testRequest()", + "AuthTests\/testRespondSignatureVerificationFailed()", + "AuthTests\/testUserRespondError()", + "CacaoSignerTest", + "ChatTests\/testAcceptAndCreateNewThread()", + "ChatTests\/testInvite()", + "EIP1271VerifierTests", + "EIP191VerifierTests", + "PairingTests\/testDisconnect()", + "PairingTests\/testProposePushOnPairing()", + "PairingTests\/testResponseErrorForMethodUnregistered()", + "PushTests\/testDappDeletePushSubscription()", + "PushTests\/testRequestPush()", + "PushTests\/testWalletApprovesPushRequest()", + "PushTests\/testWalletDeletePushSubscription()", + "PushTests\/testWalletRejectsPushRequest()", + "RegistryTests", + "RelayClientEndToEndTests", + "SignClientTests\/testCaip25SatisfyAllRequiredAllOptionalNamespacesSuccessful()", + "SignClientTests\/testCaip25SatisfyAllRequiredNamespacesSuccessful()", + "SignClientTests\/testCaip25SatisfyEmptyRequiredNamespacesExtraOptionalNamespacesSuccessful()", + "SignClientTests\/testCaip25SatisfyPartiallyRequiredNamespacesFails()", + "SignClientTests\/testCaip25SatisfyPartiallyRequiredNamespacesMethodsFails()", + "SignClientTests\/testNewSessionOnExistingPairing()", + "SignClientTests\/testSessionDelete()", + "SignClientTests\/testSessionEventFails()", + "SignClientTests\/testSessionEventSucceeds()", + "SignClientTests\/testSessionPing()", + "SignClientTests\/testSessionPropose()", + "SignClientTests\/testSessionReject()", + "SignClientTests\/testSessionRequestFailureResponse()", + "SignClientTests\/testSuccessfulSessionExtend()", + "SignClientTests\/testSuccessfulSessionUpdateNamespaces()", + "SignerTest" + ], + "target" : { + "containerPath" : "container:ExampleApp.xcodeproj", + "identifier" : "A5E03DEC286464DB00888481", + "name" : "IntegrationTests" + } + } + ], + "version" : 1 +} diff --git a/Example/ExampleApp.xcodeproj/project.pbxproj b/Example/ExampleApp.xcodeproj/project.pbxproj index 2de06eeb9..93c0da52d 100644 --- a/Example/ExampleApp.xcodeproj/project.pbxproj +++ b/Example/ExampleApp.xcodeproj/project.pbxproj @@ -390,6 +390,7 @@ 844749F329B9E5B9005F520B /* RelayIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RelayIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 844749F529B9E5B9005F520B /* RelayClientEndToEndTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayClientEndToEndTests.swift; sourceTree = ""; }; 84494387278D9C1B00CC26BB /* UIAlertController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIAlertController.swift; sourceTree = ""; }; + 845AA7D929BA1EBA00F33739 /* IntegrationTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = IntegrationTests.xctestplan; path = ExampleApp.xcodeproj/IntegrationTests.xctestplan; sourceTree = ""; }; 845B8D8B2934B36C0084A966 /* Account.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Account.swift; sourceTree = ""; }; 8460DCFB274F98A10081F94C /* RequestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestViewController.swift; sourceTree = ""; }; 847BD1D12989492500076C90 /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; }; @@ -767,6 +768,7 @@ 764E1D3326F8D3FC00A1FB15 = { isa = PBXGroup; children = ( + 845AA7D929BA1EBA00F33739 /* IntegrationTests.xctestplan */, A5A8E479293A1C4400FEB97D /* Shared */, A5F48A0528E43D3F0034CBFB /* Configuration.xcconfig */, 84CE6453279FFE1100142511 /* Wallet.entitlements */, diff --git a/Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/IntegrationTests.xcscheme b/Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/IntegrationTests.xcscheme index 177cd0cec..2fcedb836 100644 --- a/Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/IntegrationTests.xcscheme +++ b/Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/IntegrationTests.xcscheme @@ -1,7 +1,7 @@ + version = "1.7"> @@ -48,6 +48,12 @@ isEnabled = "YES"> + + + + @@ -78,15 +84,6 @@ savedToolIdentifier = "" useCustomWorkingDirectory = "NO" debugDocumentVersioning = "YES"> - - - - From 5438dcab5f9ae9937f1298bc27711a053822cab5 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Thu, 9 Mar 2023 15:23:52 +0100 Subject: [PATCH 07/15] update test plan --- .github/actions/ci/action.yml | 10 ++++++++++ .github/workflows/ci.yml | 2 +- .../ExampleApp.xcodeproj/IntegrationTests.xctestplan | 2 +- Makefile | 3 +++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/actions/ci/action.yml b/.github/actions/ci/action.yml index 1c105f783..e52dc3840 100644 --- a/.github/actions/ci/action.yml +++ b/.github/actions/ci/action.yml @@ -30,6 +30,16 @@ runs: PROJECT_ID: ${{ inputs.project-id }} run: make integration_tests RELAY_HOST=$RELAY_ENDPOINT PROJECT_ID=$PROJECT_ID + # Smoke tests + - name: Run smoke tests + if: inputs.type == 'smoke-tests' + shell: bash + env: + RELAY_ENDPOINT: ${{ inputs.relay-endpoint }} + PROJECT_ID: ${{ inputs.project-id }} + run: make smoke_tests RELAY_HOST=$RELAY_ENDPOINT PROJECT_ID=$PROJECT_ID + + # Wallet build - name: Build Example Wallet if: inputs.type == 'build-example-wallet' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1846f591..edbf81473 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: runs-on: macos-12 strategy: matrix: - test-type: [unit-tests, integration-tests, build-example-wallet, build-example-dapp] + test-type: [smoke-tests] steps: - uses: actions/checkout@v2 diff --git a/Example/ExampleApp.xcodeproj/IntegrationTests.xctestplan b/Example/ExampleApp.xcodeproj/IntegrationTests.xctestplan index a9ef3ebcc..13cd8e840 100644 --- a/Example/ExampleApp.xcodeproj/IntegrationTests.xctestplan +++ b/Example/ExampleApp.xcodeproj/IntegrationTests.xctestplan @@ -2,7 +2,7 @@ "configurations" : [ { "id" : "BAABD63B-F7E2-4928-AD6F-325C999C17BB", - "name" : "Smoke Tests", + "name" : "SmokeTests", "options" : { } diff --git a/Makefile b/Makefile index fa43c4abf..43e4b8f66 100755 --- a/Makefile +++ b/Makefile @@ -31,6 +31,9 @@ unit_tests: integration_tests: fastlane tests scheme:IntegrationTests relay_host:$(RELAY_HOST) project_id:$(PROJECT_ID) +smoke_tests: + fastlane tests scheme:IntegrationTests -only-test-configuration:SmokeTests relay_host:$(RELAY_HOST) project_id:$(PROJECT_ID) + resolve_packages: fastlane resolve scheme:WalletApp From fb74c11c92b00d7f3fca4f86c06b8f63689223a4 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Thu, 9 Mar 2023 15:31:49 +0100 Subject: [PATCH 08/15] test test plan --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 43e4b8f66..14d995043 100755 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ integration_tests: fastlane tests scheme:IntegrationTests relay_host:$(RELAY_HOST) project_id:$(PROJECT_ID) smoke_tests: - fastlane tests scheme:IntegrationTests -only-test-configuration:SmokeTests relay_host:$(RELAY_HOST) project_id:$(PROJECT_ID) + fastlane tests scheme:IntegrationTests testplan:IntegrationTests only-test-configuration:SmokeTests relay_host:$(RELAY_HOST) project_id:$(PROJECT_ID) resolve_packages: fastlane resolve scheme:WalletApp From e3fc895dc62676d81f8d8fb7f036bd99b9b982da Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Fri, 10 Mar 2023 11:53:29 +0100 Subject: [PATCH 09/15] add second test plan --- .../IntegrationTests.xctestplan | 40 +--------- Example/ExampleApp.xcodeproj/project.pbxproj | 2 + .../xcschemes/IntegrationTests.xcscheme | 12 +++ Example/SmokeTests.xctestplan | 74 +++++++++++++++++++ 4 files changed, 89 insertions(+), 39 deletions(-) create mode 100644 Example/SmokeTests.xctestplan diff --git a/Example/ExampleApp.xcodeproj/IntegrationTests.xctestplan b/Example/ExampleApp.xcodeproj/IntegrationTests.xctestplan index 13cd8e840..5b274df17 100644 --- a/Example/ExampleApp.xcodeproj/IntegrationTests.xctestplan +++ b/Example/ExampleApp.xcodeproj/IntegrationTests.xctestplan @@ -2,7 +2,7 @@ "configurations" : [ { "id" : "BAABD63B-F7E2-4928-AD6F-325C999C17BB", - "name" : "SmokeTests", + "name" : "Configuration 1", "options" : { } @@ -28,44 +28,6 @@ }, "testTargets" : [ { - "skippedTests" : [ - "AuthTests\/testEIP1271RespondSuccess()", - "AuthTests\/testEIP191RespondError()", - "AuthTests\/testRequest()", - "AuthTests\/testRespondSignatureVerificationFailed()", - "AuthTests\/testUserRespondError()", - "CacaoSignerTest", - "ChatTests\/testAcceptAndCreateNewThread()", - "ChatTests\/testInvite()", - "EIP1271VerifierTests", - "EIP191VerifierTests", - "PairingTests\/testDisconnect()", - "PairingTests\/testProposePushOnPairing()", - "PairingTests\/testResponseErrorForMethodUnregistered()", - "PushTests\/testDappDeletePushSubscription()", - "PushTests\/testRequestPush()", - "PushTests\/testWalletApprovesPushRequest()", - "PushTests\/testWalletDeletePushSubscription()", - "PushTests\/testWalletRejectsPushRequest()", - "RegistryTests", - "RelayClientEndToEndTests", - "SignClientTests\/testCaip25SatisfyAllRequiredAllOptionalNamespacesSuccessful()", - "SignClientTests\/testCaip25SatisfyAllRequiredNamespacesSuccessful()", - "SignClientTests\/testCaip25SatisfyEmptyRequiredNamespacesExtraOptionalNamespacesSuccessful()", - "SignClientTests\/testCaip25SatisfyPartiallyRequiredNamespacesFails()", - "SignClientTests\/testCaip25SatisfyPartiallyRequiredNamespacesMethodsFails()", - "SignClientTests\/testNewSessionOnExistingPairing()", - "SignClientTests\/testSessionDelete()", - "SignClientTests\/testSessionEventFails()", - "SignClientTests\/testSessionEventSucceeds()", - "SignClientTests\/testSessionPing()", - "SignClientTests\/testSessionPropose()", - "SignClientTests\/testSessionReject()", - "SignClientTests\/testSessionRequestFailureResponse()", - "SignClientTests\/testSuccessfulSessionExtend()", - "SignClientTests\/testSuccessfulSessionUpdateNamespaces()", - "SignerTest" - ], "target" : { "containerPath" : "container:ExampleApp.xcodeproj", "identifier" : "A5E03DEC286464DB00888481", diff --git a/Example/ExampleApp.xcodeproj/project.pbxproj b/Example/ExampleApp.xcodeproj/project.pbxproj index 93c0da52d..146358ecc 100644 --- a/Example/ExampleApp.xcodeproj/project.pbxproj +++ b/Example/ExampleApp.xcodeproj/project.pbxproj @@ -391,6 +391,7 @@ 844749F529B9E5B9005F520B /* RelayClientEndToEndTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayClientEndToEndTests.swift; sourceTree = ""; }; 84494387278D9C1B00CC26BB /* UIAlertController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIAlertController.swift; sourceTree = ""; }; 845AA7D929BA1EBA00F33739 /* IntegrationTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = IntegrationTests.xctestplan; path = ExampleApp.xcodeproj/IntegrationTests.xctestplan; sourceTree = ""; }; + 845AA7DC29BB424800F33739 /* SmokeTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = SmokeTests.xctestplan; sourceTree = ""; }; 845B8D8B2934B36C0084A966 /* Account.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Account.swift; sourceTree = ""; }; 8460DCFB274F98A10081F94C /* RequestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestViewController.swift; sourceTree = ""; }; 847BD1D12989492500076C90 /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; }; @@ -769,6 +770,7 @@ isa = PBXGroup; children = ( 845AA7D929BA1EBA00F33739 /* IntegrationTests.xctestplan */, + 845AA7DC29BB424800F33739 /* SmokeTests.xctestplan */, A5A8E479293A1C4400FEB97D /* Shared */, A5F48A0528E43D3F0034CBFB /* Configuration.xcconfig */, 84CE6453279FFE1100142511 /* Wallet.entitlements */, diff --git a/Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/IntegrationTests.xcscheme b/Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/IntegrationTests.xcscheme index 2fcedb836..ddd361a6d 100644 --- a/Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/IntegrationTests.xcscheme +++ b/Example/ExampleApp.xcodeproj/xcshareddata/xcschemes/IntegrationTests.xcscheme @@ -53,6 +53,9 @@ reference = "container:ExampleApp.xcodeproj/IntegrationTests.xctestplan" default = "YES"> + + + + + + diff --git a/Example/SmokeTests.xctestplan b/Example/SmokeTests.xctestplan new file mode 100644 index 000000000..d6346a7ba --- /dev/null +++ b/Example/SmokeTests.xctestplan @@ -0,0 +1,74 @@ +{ + "configurations" : [ + { + "id" : "EB662E8C-8DC0-4689-A2FF-B41B80A99F85", + "name" : "Configuration 1", + "options" : { + "targetForVariableExpansion" : { + "containerPath" : "container:ExampleApp.xcodeproj", + "identifier" : "A5E03DEC286464DB00888481", + "name" : "IntegrationTests" + } + } + } + ], + "defaultOptions" : { + "environmentVariableEntries" : [ + { + "key" : "RELAY_HOST", + "value" : "$(RELAY_HOST)" + }, + { + "key" : "PROJECT_ID", + "value" : "$(PROJECT_ID)" + } + ], + "testTimeoutsEnabled" : true + }, + "testTargets" : [ + { + "skippedTests" : [ + "AuthTests\/testEIP1271RespondSuccess()", + "AuthTests\/testEIP191RespondError()", + "AuthTests\/testRequest()", + "AuthTests\/testRespondSignatureVerificationFailed()", + "AuthTests\/testUserRespondError()", + "CacaoSignerTest", + "ChatTests\/testAcceptAndCreateNewThread()", + "ChatTests\/testInvite()", + "EIP1271VerifierTests", + "EIP191VerifierTests", + "PairingTests", + "PushTests\/testDappDeletePushSubscription()", + "PushTests\/testRequestPush()", + "PushTests\/testWalletApprovesPushRequest()", + "PushTests\/testWalletDeletePushSubscription()", + "PushTests\/testWalletRejectsPushRequest()", + "RegistryTests", + "RelayClientEndToEndTests", + "SignClientTests\/testCaip25SatisfyAllRequiredAllOptionalNamespacesSuccessful()", + "SignClientTests\/testCaip25SatisfyAllRequiredNamespacesSuccessful()", + "SignClientTests\/testCaip25SatisfyEmptyRequiredNamespacesExtraOptionalNamespacesSuccessful()", + "SignClientTests\/testCaip25SatisfyPartiallyRequiredNamespacesFails()", + "SignClientTests\/testCaip25SatisfyPartiallyRequiredNamespacesMethodsFails()", + "SignClientTests\/testNewSessionOnExistingPairing()", + "SignClientTests\/testSessionDelete()", + "SignClientTests\/testSessionEventFails()", + "SignClientTests\/testSessionEventSucceeds()", + "SignClientTests\/testSessionPing()", + "SignClientTests\/testSessionPropose()", + "SignClientTests\/testSessionReject()", + "SignClientTests\/testSessionRequestFailureResponse()", + "SignClientTests\/testSuccessfulSessionExtend()", + "SignClientTests\/testSuccessfulSessionUpdateNamespaces()", + "SignerTest" + ], + "target" : { + "containerPath" : "container:ExampleApp.xcodeproj", + "identifier" : "A5E03DEC286464DB00888481", + "name" : "IntegrationTests" + } + } + ], + "version" : 1 +} From ef315e196b44d125816e707155648f98ab6fa4d8 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Fri, 10 Mar 2023 11:55:01 +0100 Subject: [PATCH 10/15] update makefile --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 14d995043..b115b6e76 100755 --- a/Makefile +++ b/Makefile @@ -29,10 +29,10 @@ unit_tests: fastlane tests scheme:WalletConnect integration_tests: - fastlane tests scheme:IntegrationTests relay_host:$(RELAY_HOST) project_id:$(PROJECT_ID) + fastlane tests scheme:IntegrationTests testplan:IntegrationTests relay_host:$(RELAY_HOST) project_id:$(PROJECT_ID) smoke_tests: - fastlane tests scheme:IntegrationTests testplan:IntegrationTests only-test-configuration:SmokeTests relay_host:$(RELAY_HOST) project_id:$(PROJECT_ID) + fastlane tests scheme:IntegrationTests testplan:SmokeTests relay_host:$(RELAY_HOST) project_id:$(PROJECT_ID) resolve_packages: fastlane resolve scheme:WalletApp From 8f3491af5f587fc1310ec82228137b263d5142b8 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Fri, 10 Mar 2023 12:03:06 +0100 Subject: [PATCH 11/15] Add relay integration tests step --- .github/actions/ci/action.yml | 9 ++ .github/workflows/ci.yml | 2 +- Example/ExampleApp.xcodeproj/project.pbxproj | 12 --- .../Relay/RelayClientEndToEndTests.swift | 100 ------------------ Makefile | 3 + 5 files changed, 13 insertions(+), 113 deletions(-) delete mode 100644 Example/IntegrationTests/Relay/RelayClientEndToEndTests.swift diff --git a/.github/actions/ci/action.yml b/.github/actions/ci/action.yml index e52dc3840..cf03c7a7d 100644 --- a/.github/actions/ci/action.yml +++ b/.github/actions/ci/action.yml @@ -30,6 +30,15 @@ runs: PROJECT_ID: ${{ inputs.project-id }} run: make integration_tests RELAY_HOST=$RELAY_ENDPOINT PROJECT_ID=$PROJECT_ID + # Relay Integration tests + - name: Run integration tests + if: inputs.type == 'relay-tests' + shell: bash + env: + RELAY_ENDPOINT: ${{ inputs.relay-endpoint }} + PROJECT_ID: ${{ inputs.project-id }} + run: make relay_tests RELAY_HOST=$RELAY_ENDPOINT PROJECT_ID=$PROJECT_ID + # Smoke tests - name: Run smoke tests if: inputs.type == 'smoke-tests' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index edbf81473..2be3cc7c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: runs-on: macos-12 strategy: matrix: - test-type: [smoke-tests] + test-type: [unit-tests, integration-tests, build-example-wallet, build-example-dapp, relay-tests] steps: - uses: actions/checkout@v2 diff --git a/Example/ExampleApp.xcodeproj/project.pbxproj b/Example/ExampleApp.xcodeproj/project.pbxproj index 146358ecc..8cccc1637 100644 --- a/Example/ExampleApp.xcodeproj/project.pbxproj +++ b/Example/ExampleApp.xcodeproj/project.pbxproj @@ -214,7 +214,6 @@ 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 */; }; A5E03E1128646F8000888481 /* KeychainStorageMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E03E1028646F8000888481 /* KeychainStorageMock.swift */; }; A5E22D1A2840C62A00E36487 /* Engine.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E22D192840C62A00E36487 /* Engine.swift */; }; A5E22D1C2840C85D00E36487 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E22D1B2840C85D00E36487 /* App.swift */; }; @@ -549,7 +548,6 @@ 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 = ""; }; A5E03E1028646F8000888481 /* KeychainStorageMock.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeychainStorageMock.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 = ""; }; @@ -1467,7 +1465,6 @@ children = ( 849D7A91292E2115006A2BD4 /* Push */, 84CEC64728D8A98900D081A8 /* Pairing */, - A5E03E0B28646AA500888481 /* Relay */, A5E03E0A28646A8A00888481 /* Stubs */, A5E03E0928646A8100888481 /* Sign */, A5E03E0828646A7B00888481 /* Chat */, @@ -1505,14 +1502,6 @@ path = Stubs; sourceTree = ""; }; - A5E03E0B28646AA500888481 /* Relay */ = { - isa = PBXGroup; - children = ( - A5E03E0C28646AD200888481 /* RelayClientEndToEndTests.swift */, - ); - path = Relay; - sourceTree = ""; - }; A5E22D252840D08B00E36487 /* Regression */ = { isa = PBXGroup; children = ( @@ -2334,7 +2323,6 @@ 7694A5262874296A0001257E /* RegistryTests.swift in Sources */, A541959F2934BFEF0035AD19 /* SignerTests.swift in Sources */, A50C036528AAD32200FE72D3 /* ClientDelegate.swift in Sources */, - A5E03E0D28646AD200888481 /* RelayClientEndToEndTests.swift in Sources */, A5E03DFA286465C700888481 /* SignClientTests.swift in Sources */, A54195A02934BFEF0035AD19 /* EIP1271VerifierTests.swift in Sources */, A54195A12934BFEF0035AD19 /* EIP191VerifierTests.swift in Sources */, diff --git a/Example/IntegrationTests/Relay/RelayClientEndToEndTests.swift b/Example/IntegrationTests/Relay/RelayClientEndToEndTests.swift deleted file mode 100644 index 4f4917dea..000000000 --- a/Example/IntegrationTests/Relay/RelayClientEndToEndTests.swift +++ /dev/null @@ -1,100 +0,0 @@ -import Foundation -import Combine -import XCTest -import WalletConnectUtils -import Starscream -@testable import WalletConnectRelay - -final class RelayClientEndToEndTests: XCTestCase { - - private var publishers = Set() - - func makeRelayClient() -> RelayClient { - let clientIdStorage = ClientIdStorage(keychain: KeychainStorageMock()) - let socketAuthenticator = SocketAuthenticator( - clientIdStorage: clientIdStorage, - relayHost: InputConfig.relayHost - ) - let urlFactory = RelayUrlFactory(socketAuthenticator: socketAuthenticator) - let socket = WebSocket(url: urlFactory.create(host: InputConfig.relayHost, projectId: InputConfig.projectId)) - - let logger = ConsoleLogger() - let dispatcher = Dispatcher(socket: socket, socketConnectionHandler: ManualSocketConnectionHandler(socket: socket), logger: logger) - return RelayClient(dispatcher: dispatcher, logger: logger, keyValueStorage: RuntimeKeyValueStorage(), clientIdStorage: clientIdStorage) - } - - func testSubscribe() { - let relayClient = makeRelayClient() - - try! relayClient.connect() - let subscribeExpectation = expectation(description: "subscribe call succeeds") - subscribeExpectation.assertForOverFulfill = true - relayClient.socketConnectionStatusPublisher.sink { status in - if status == .connected { - Task(priority: .high) { try await relayClient.subscribe(topic: "ecb78f2df880c43d3418ddbf871092b847801932e21765b250cc50b9e96a9131") } - subscribeExpectation.fulfill() - } - }.store(in: &publishers) - - wait(for: [subscribeExpectation], timeout: InputConfig.defaultTimeout) - } - - func testEndToEndPayload() { - let relayA = makeRelayClient() - let relayB = makeRelayClient() - - try! relayA.connect() - try! relayB.connect() - - let randomTopic = String.randomTopic() - let payloadA = "A" - let payloadB = "B" - var subscriptionATopic: String! - var subscriptionBTopic: String! - var subscriptionAPayload: String! - var subscriptionBPayload: String! - - let expectationA = expectation(description: "publish payloads send and receive successfuly") - let expectationB = expectation(description: "publish payloads send and receive successfuly") - - expectationA.assertForOverFulfill = false - expectationB.assertForOverFulfill = false - - relayA.messagePublisher.sink { topic, payload, _ in - (subscriptionATopic, subscriptionAPayload) = (topic, payload) - expectationA.fulfill() - }.store(in: &publishers) - - relayB.messagePublisher.sink { topic, payload, _ in - (subscriptionBTopic, subscriptionBPayload) = (topic, payload) - expectationB.fulfill() - }.store(in: &publishers) - - relayA.socketConnectionStatusPublisher.sink { _ in - Task(priority: .high) { - try await relayA.publish(topic: randomTopic, payload: payloadA, tag: 0, prompt: false, ttl: 60) - try await relayA.subscribe(topic: randomTopic) - } - }.store(in: &publishers) - relayB.socketConnectionStatusPublisher.sink { _ in - Task(priority: .high) { - try await relayB.publish(topic: randomTopic, payload: payloadB, tag: 0, prompt: false, ttl: 60) - try await relayB.subscribe(topic: randomTopic) - } - }.store(in: &publishers) - - wait(for: [expectationA, expectationB], timeout: InputConfig.defaultTimeout) - - XCTAssertEqual(subscriptionATopic, randomTopic) - XCTAssertEqual(subscriptionBTopic, randomTopic) - - XCTAssertEqual(subscriptionBPayload, payloadA) - XCTAssertEqual(subscriptionAPayload, payloadB) - } -} - -extension String { - static func randomTopic() -> String { - "\(UUID().uuidString)\(UUID().uuidString)".replacingOccurrences(of: "-", with: "").lowercased() - } -} diff --git a/Makefile b/Makefile index b115b6e76..cd690d5f8 100755 --- a/Makefile +++ b/Makefile @@ -34,6 +34,9 @@ integration_tests: smoke_tests: fastlane tests scheme:IntegrationTests testplan:SmokeTests relay_host:$(RELAY_HOST) project_id:$(PROJECT_ID) +relay_tests: + fastlane tests scheme:RelayIntegrationTests relay_host:$(RELAY_HOST) project_id:$(PROJECT_ID) + resolve_packages: fastlane resolve scheme:WalletApp From 95de475f1cfab79148476a7f0da2f14aadf6d38c Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Mon, 13 Mar 2023 09:23:36 +0100 Subject: [PATCH 12/15] update fastfile, use xcodebuild for smoke tests --- .github/actions/ci/action.yml | 11 ++++++++++- Makefile | 3 --- fastlane/Fastfile | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/actions/ci/action.yml b/.github/actions/ci/action.yml index cf03c7a7d..cac904594 100644 --- a/.github/actions/ci/action.yml +++ b/.github/actions/ci/action.yml @@ -46,7 +46,16 @@ runs: env: RELAY_ENDPOINT: ${{ inputs.relay-endpoint }} PROJECT_ID: ${{ inputs.project-id }} - run: make smoke_tests RELAY_HOST=$RELAY_ENDPOINT PROJECT_ID=$PROJECT_ID + run: "xcodebuild \ + -project Example/ExampleApp.xcodeproj \ + -scheme IntegrationTests \ + -testPlan SmokeTests \ + -clonedSourcePackagesDirPath SourcePackagesCache \ + -destination 'platform=iOS Simulator,name=iPhone 13' \ + -derivedDataPath DerivedDataCache \ + RELAY_HOST='$RELAY_ENDPOINT' \ + PROJECT_ID='$PROJECT_ID' \ + test" # Wallet build diff --git a/Makefile b/Makefile index cd690d5f8..5b28eb940 100755 --- a/Makefile +++ b/Makefile @@ -31,9 +31,6 @@ unit_tests: integration_tests: fastlane tests scheme:IntegrationTests testplan:IntegrationTests relay_host:$(RELAY_HOST) project_id:$(PROJECT_ID) -smoke_tests: - fastlane tests scheme:IntegrationTests testplan:SmokeTests relay_host:$(RELAY_HOST) project_id:$(PROJECT_ID) - relay_tests: fastlane tests scheme:RelayIntegrationTests relay_host:$(RELAY_HOST) project_id:$(PROJECT_ID) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index b32acd249..3c19c1be9 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -23,6 +23,7 @@ platform :ios do run_tests( project: 'Example/ExampleApp.xcodeproj', scheme: options[:scheme], + testplan: options[:testplan], cloned_source_packages_path: 'SourcePackagesCache', destination: 'platform=iOS Simulator,name=iPhone 13', derived_data_path: 'DerivedDataCache', From 7adb0b89055417a5c83a1d513ffd4b975e47d813 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Mon, 13 Mar 2023 11:28:15 +0100 Subject: [PATCH 13/15] savepoint --- .github/actions/ci/action.yml | 11 +---------- Makefile | 12 ++++++++++++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/actions/ci/action.yml b/.github/actions/ci/action.yml index cac904594..cf03c7a7d 100644 --- a/.github/actions/ci/action.yml +++ b/.github/actions/ci/action.yml @@ -46,16 +46,7 @@ runs: env: RELAY_ENDPOINT: ${{ inputs.relay-endpoint }} PROJECT_ID: ${{ inputs.project-id }} - run: "xcodebuild \ - -project Example/ExampleApp.xcodeproj \ - -scheme IntegrationTests \ - -testPlan SmokeTests \ - -clonedSourcePackagesDirPath SourcePackagesCache \ - -destination 'platform=iOS Simulator,name=iPhone 13' \ - -derivedDataPath DerivedDataCache \ - RELAY_HOST='$RELAY_ENDPOINT' \ - PROJECT_ID='$PROJECT_ID' \ - test" + run: make smoke_tests RELAY_HOST=$RELAY_ENDPOINT PROJECT_ID=$PROJECT_ID # Wallet build diff --git a/Makefile b/Makefile index 5b28eb940..04ea64890 100755 --- a/Makefile +++ b/Makefile @@ -34,6 +34,18 @@ integration_tests: relay_tests: fastlane tests scheme:RelayIntegrationTests relay_host:$(RELAY_HOST) project_id:$(PROJECT_ID) +smoke_tests: + xcodebuild \ + -project Example/ExampleApp.xcodeproj \ + -scheme IntegrationTests \ + -testPlan SmokeTests \ + -clonedSourcePackagesDirPath SourcePackagesCache \ + -destination 'platform=iOS Simulator,name=iPhone 14' \ + -derivedDataPath DerivedDataCache \ + RELAY_HOST=$(RELAY_HOST) \ + PROJECT_ID=$(PROJECT_ID) \ + test + resolve_packages: fastlane resolve scheme:WalletApp From 9c517425e7475f8110e59fe751c6f6108caffea3 Mon Sep 17 00:00:00 2001 From: Artur Guseinov Date: Mon, 13 Mar 2023 18:08:49 +0500 Subject: [PATCH 14/15] Ensure application state read from main thread --- .../WalletConnectRelay/AppStateObserving.swift | 15 +++++++++------ Sources/WalletConnectRelay/Dispatching.swift | 5 ++++- .../AutomaticSocketConnectionHandler.swift | 7 +++---- .../ManualSocketConnectionHandler.swift | 2 +- .../SocketConnectionHandler.swift | 2 +- .../AutomaticSocketConnectionHandlerTests.swift | 8 ++++---- 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Sources/WalletConnectRelay/AppStateObserving.swift b/Sources/WalletConnectRelay/AppStateObserving.swift index 3db4ff629..9626d463e 100644 --- a/Sources/WalletConnectRelay/AppStateObserving.swift +++ b/Sources/WalletConnectRelay/AppStateObserving.swift @@ -11,7 +11,7 @@ enum ApplicationState { } protocol AppStateObserving: AnyObject { - var currentState: ApplicationState { get } + var currentState: ApplicationState { get async } var onWillEnterForeground: (() -> Void)? {get set} var onWillEnterBackground: (() -> Void)? {get set} } @@ -26,14 +26,17 @@ class AppStateObserver: AppStateObserving { subscribeNotificationCenter() } - var currentState: ApplicationState { + @MainActor + var currentState: ApplicationState{ + get async { #if canImport(UIKit) - let isActive = UIApplication.shared.applicationState == .active - return isActive ? .foreground : .background + let isActive = UIApplication.shared.applicationState == .active + return isActive ? .foreground : .background #elseif canImport(AppKit) - let isActive = NSApplication.shared.isActive - return isActive ? .foreground : .background + let isActive = NSApplication.shared.isActive + return isActive ? .foreground : .background #endif + } } private func subscribeNotificationCenter() { diff --git a/Sources/WalletConnectRelay/Dispatching.swift b/Sources/WalletConnectRelay/Dispatching.swift index dd32df37b..73fa3c5b2 100644 --- a/Sources/WalletConnectRelay/Dispatching.swift +++ b/Sources/WalletConnectRelay/Dispatching.swift @@ -103,7 +103,10 @@ final class Dispatcher: NSObject, Dispatching { } socket.onDisconnect = { [unowned self] _ in self.socketConnectionStatusPublisherSubject.send(.disconnected) - self.socketConnectionHandler.handleDisconnection() + + Task(priority: .high) { + await self.socketConnectionHandler.handleDisconnection() + } } } } diff --git a/Sources/WalletConnectRelay/SocketConnectionHandler/AutomaticSocketConnectionHandler.swift b/Sources/WalletConnectRelay/SocketConnectionHandler/AutomaticSocketConnectionHandler.swift index 5e95f79b8..804ee14f0 100644 --- a/Sources/WalletConnectRelay/SocketConnectionHandler/AutomaticSocketConnectionHandler.swift +++ b/Sources/WalletConnectRelay/SocketConnectionHandler/AutomaticSocketConnectionHandler.swift @@ -80,9 +80,8 @@ extension AutomaticSocketConnectionHandler: SocketConnectionHandler { throw Errors.manualSocketDisconnectionForbidden } - func handleDisconnection() { - if appStateObserver.currentState == .foreground { - reconnectIfNeeded() - } + func handleDisconnection() async { + guard await appStateObserver.currentState == .foreground else { return } + reconnectIfNeeded() } } diff --git a/Sources/WalletConnectRelay/SocketConnectionHandler/ManualSocketConnectionHandler.swift b/Sources/WalletConnectRelay/SocketConnectionHandler/ManualSocketConnectionHandler.swift index bed340e44..7f145d1c5 100644 --- a/Sources/WalletConnectRelay/SocketConnectionHandler/ManualSocketConnectionHandler.swift +++ b/Sources/WalletConnectRelay/SocketConnectionHandler/ManualSocketConnectionHandler.swift @@ -15,7 +15,7 @@ class ManualSocketConnectionHandler: SocketConnectionHandler { socket.disconnect() } - func handleDisconnection() { + func handleDisconnection() async { // No operation // ManualSocketConnectionHandler does not support reconnection logic } diff --git a/Sources/WalletConnectRelay/SocketConnectionHandler/SocketConnectionHandler.swift b/Sources/WalletConnectRelay/SocketConnectionHandler/SocketConnectionHandler.swift index 035d1d1df..4ac3046dd 100644 --- a/Sources/WalletConnectRelay/SocketConnectionHandler/SocketConnectionHandler.swift +++ b/Sources/WalletConnectRelay/SocketConnectionHandler/SocketConnectionHandler.swift @@ -3,5 +3,5 @@ import Foundation protocol SocketConnectionHandler { func handleConnect() throws func handleDisconnect(closeCode: URLSessionWebSocketTask.CloseCode) throws - func handleDisconnection() + func handleDisconnection() async } diff --git a/Tests/RelayerTests/AutomaticSocketConnectionHandlerTests.swift b/Tests/RelayerTests/AutomaticSocketConnectionHandlerTests.swift index 1207b4335..92c0895af 100644 --- a/Tests/RelayerTests/AutomaticSocketConnectionHandlerTests.swift +++ b/Tests/RelayerTests/AutomaticSocketConnectionHandlerTests.swift @@ -55,19 +55,19 @@ final class AutomaticSocketConnectionHandlerTests: XCTestCase { XCTAssertFalse(webSocketSession.isConnected) } - func testReconnectOnDisconnectForeground() { + func testReconnectOnDisconnectForeground() async { appStateObserver.currentState = .foreground XCTAssertTrue(webSocketSession.isConnected) webSocketSession.disconnect() - sut.handleDisconnection() + await sut.handleDisconnection() XCTAssertTrue(webSocketSession.isConnected) } - func testReconnectOnDisconnectBackground() { + func testReconnectOnDisconnectBackground() async { appStateObserver.currentState = .background XCTAssertTrue(webSocketSession.isConnected) webSocketSession.disconnect() - sut.handleDisconnection() + await sut.handleDisconnection() XCTAssertFalse(webSocketSession.isConnected) } } From fc49833063750bc7fada1eba4a20dbde3438fdb3 Mon Sep 17 00:00:00 2001 From: flypaper0 Date: Tue, 14 Mar 2023 11:50:26 +0000 Subject: [PATCH 15/15] Set User Agent --- Sources/WalletConnectRelay/PackageConfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/WalletConnectRelay/PackageConfig.json b/Sources/WalletConnectRelay/PackageConfig.json index b4f543928..818e3430c 100644 --- a/Sources/WalletConnectRelay/PackageConfig.json +++ b/Sources/WalletConnectRelay/PackageConfig.json @@ -1 +1 @@ -{"version": "1.5.0"} +{"version": "1.5.1"}