From 969a002db68e709f048b6d4a819003643cbe3dde Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Mon, 19 Aug 2024 08:41:25 +0200 Subject: [PATCH 1/2] reorder methods execution --- .../Sign/SignClientTests.swift | 2 ++ .../Engine/Common/ApproveEngine.swift | 22 ++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Example/IntegrationTests/Sign/SignClientTests.swift b/Example/IntegrationTests/Sign/SignClientTests.swift index 4575da2db..6cec32d42 100644 --- a/Example/IntegrationTests/Sign/SignClientTests.swift +++ b/Example/IntegrationTests/Sign/SignClientTests.swift @@ -89,6 +89,7 @@ final class SignClientTests: XCTestCase { } func testSessionPropose() async throws { + //start measuring here let dappSettlementExpectation = expectation(description: "Dapp expects to settle a session") let walletSettlementExpectation = expectation(description: "Wallet expects to settle a session") let requiredNamespaces = ProposalNamespace.stubRequired() @@ -104,6 +105,7 @@ final class SignClientTests: XCTestCase { } }.store(in: &publishers) dapp.sessionSettlePublisher.sink { _ in + //end measuring here dappSettlementExpectation.fulfill() }.store(in: &publishers) wallet.sessionSettlePublisher.sink { _ in diff --git a/Sources/WalletConnectSign/Engine/Common/ApproveEngine.swift b/Sources/WalletConnectSign/Engine/Common/ApproveEngine.swift index 0c8d7530b..1b2dc96d4 100644 --- a/Sources/WalletConnectSign/Engine/Common/ApproveEngine.swift +++ b/Sources/WalletConnectSign/Engine/Common/ApproveEngine.swift @@ -149,23 +149,25 @@ final class ApproveEngine { pairingTopic: pairingTopic ) - do { - _ = try await proposeResponseTask - eventsClient.saveEvent(SessionApproveExecutionTraceEvents.responseApproveSent) - } catch { - eventsClient.saveEvent(ApproveSessionTraceErrorEvents.sessionSettleFailure) - throw error - } - do { let session: WCSession = try await settleRequestTask + eventsClient.saveEvent(SessionApproveExecutionTraceEvents.sessionSettleSuccess) + logger.debug("Session settle request has been successfully processed") + + do { + _ = try await proposeResponseTask + eventsClient.saveEvent(SessionApproveExecutionTraceEvents.responseApproveSent) + } catch { + eventsClient.saveEvent(ApproveSessionTraceErrorEvents.sessionSettleFailure) + throw error + } + sessionStore.setSession(session) + Task { removePairing(pairingTopic: pairingTopic) } onSessionSettle?(session.publicRepresentation()) - eventsClient.saveEvent(SessionApproveExecutionTraceEvents.sessionSettleSuccess) - logger.debug("Session proposal response and settle request have been sent") proposalPayloadsStore.delete(forKey: proposerPubKey) verifyContextStore.delete(forKey: proposerPubKey) From 794ed319c7bf8211965150375f653a19442b9d61 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Thu, 22 Aug 2024 07:54:20 +0200 Subject: [PATCH 2/2] remove comments --- Example/IntegrationTests/Sign/SignClientTests.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Example/IntegrationTests/Sign/SignClientTests.swift b/Example/IntegrationTests/Sign/SignClientTests.swift index 6cec32d42..4575da2db 100644 --- a/Example/IntegrationTests/Sign/SignClientTests.swift +++ b/Example/IntegrationTests/Sign/SignClientTests.swift @@ -89,7 +89,6 @@ final class SignClientTests: XCTestCase { } func testSessionPropose() async throws { - //start measuring here let dappSettlementExpectation = expectation(description: "Dapp expects to settle a session") let walletSettlementExpectation = expectation(description: "Wallet expects to settle a session") let requiredNamespaces = ProposalNamespace.stubRequired() @@ -105,7 +104,6 @@ final class SignClientTests: XCTestCase { } }.store(in: &publishers) dapp.sessionSettlePublisher.sink { _ in - //end measuring here dappSettlementExpectation.fulfill() }.store(in: &publishers) wallet.sessionSettlePublisher.sink { _ in