diff --git a/Example/WalletApp/PresentationLayer/Wallet/ConnectionDetails/ConnectionDetailsView.swift b/Example/WalletApp/PresentationLayer/Wallet/ConnectionDetails/ConnectionDetailsView.swift index 65a838b11..5174bc80e 100644 --- a/Example/WalletApp/PresentationLayer/Wallet/ConnectionDetails/ConnectionDetailsView.swift +++ b/Example/WalletApp/PresentationLayer/Wallet/ConnectionDetails/ConnectionDetailsView.swift @@ -2,7 +2,13 @@ import SwiftUI struct ConnectionDetailsView: View { @EnvironmentObject var presenter: ConnectionDetailsPresenter - + + private var dateFormatter: DateFormatter { + let formatter = DateFormatter() + formatter.dateFormat = "HH:mm:ss E, d MMM y" + return formatter + } + var body: some View { ZStack { Color.grey100 @@ -145,6 +151,39 @@ struct ConnectionDetailsView: View { .padding(.top, 30) } + VStack(alignment: .leading) { + Text("Expiry") + .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) + + VStack(spacing: 0) { + TagsView(items: [dateFormatter.string(from: presenter.session.expiryDate)]) { + 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) + } + .background(Color.whiteBackground) + .cornerRadius(20, corners: .allCorners) + .padding(.horizontal, 5) + .padding(.bottom, 5) + } + .background(Color("grey95")) + .cornerRadius(25, corners: .allCorners) + .padding(.horizontal, 20) + .padding(.top, 30) + Button { presenter.onDelete() } label: { diff --git a/Sources/WalletConnectSign/Engine/Common/SessionEngine.swift b/Sources/WalletConnectSign/Engine/Common/SessionEngine.swift index 3e6cec6bf..185d0d444 100644 --- a/Sources/WalletConnectSign/Engine/Common/SessionEngine.swift +++ b/Sources/WalletConnectSign/Engine/Common/SessionEngine.swift @@ -50,9 +50,9 @@ final class SessionEngine { func hasSession(for topic: String) -> Bool { return sessionStore.hasSession(forTopic: topic) } - + func getSessions() -> [Session] { - sessionStore.getAll().map {$0.publicRepresentation()} + sessionStore.getAll().map { $0.publicRepresentation() } } func request(_ request: Request) async throws { diff --git a/Sources/WalletConnectSign/Engine/Common/SessionExtendRequestSubscriber.swift b/Sources/WalletConnectSign/Engine/Common/SessionExtendRequestSubscriber.swift new file mode 100644 index 000000000..af291b26e --- /dev/null +++ b/Sources/WalletConnectSign/Engine/Common/SessionExtendRequestSubscriber.swift @@ -0,0 +1,66 @@ +import Foundation +import Combine + +final class SessionExtendRequestSubscriber { + var onExtend: ((String, Date) -> Void)? + + private let sessionStore: WCSessionStorage + private let networkingInteractor: NetworkInteracting + private var publishers = [AnyCancellable]() + private let logger: ConsoleLogging + + init( + networkingInteractor: NetworkInteracting, + sessionStore: WCSessionStorage, + logger: ConsoleLogging + ) { + self.networkingInteractor = networkingInteractor + self.sessionStore = sessionStore + self.logger = logger + + setupSubscriptions() + } +} + +// MARK: - Private functions +extension SessionExtendRequestSubscriber { + private func setupSubscriptions() { + networkingInteractor.requestSubscription(on: SessionExtendProtocolMethod()) + .sink { [unowned self] (payload: RequestSubscriptionPayload) in + onSessionUpdateExpiry(payload: payload, updateExpiryParams: payload.request) + }.store(in: &publishers) + } + + private func onSessionUpdateExpiry(payload: SubscriptionPayload, updateExpiryParams: SessionType.UpdateExpiryParams) { + let protocolMethod = SessionExtendProtocolMethod() + let topic = payload.topic + guard var session = sessionStore.getSession(forTopic: topic) else { + return respondError(payload: payload, reason: .noSessionForTopic, protocolMethod: protocolMethod) + } + guard session.peerIsController else { + return respondError(payload: payload, reason: .unauthorizedExtendRequest, protocolMethod: protocolMethod) + } + do { + try session.updateExpiry(to: updateExpiryParams.expiry) + } catch { + return respondError(payload: payload, reason: .invalidExtendRequest, protocolMethod: protocolMethod) + } + sessionStore.setSession(session) + + Task(priority: .high) { + try await networkingInteractor.respondSuccess(topic: payload.topic, requestId: payload.id, protocolMethod: protocolMethod) + } + + onExtend?(session.topic, session.expiryDate) + } + + private func respondError(payload: SubscriptionPayload, reason: SignReasonCode, protocolMethod: ProtocolMethod) { + Task(priority: .high) { + do { + try await networkingInteractor.respondError(topic: payload.topic, requestId: payload.id, protocolMethod: protocolMethod, reason: reason) + } catch { + logger.error("Respond Error failed with: \(error.localizedDescription)") + } + } + } +} diff --git a/Sources/WalletConnectSign/Engine/Common/SessionExtendRequester.swift b/Sources/WalletConnectSign/Engine/Common/SessionExtendRequester.swift new file mode 100644 index 000000000..5b815cb14 --- /dev/null +++ b/Sources/WalletConnectSign/Engine/Common/SessionExtendRequester.swift @@ -0,0 +1,27 @@ +import Foundation + +final class SessionExtendRequester { + private let sessionStore: WCSessionStorage + private let networkingInteractor: NetworkInteracting + + init( + sessionStore: WCSessionStorage, + networkingInteractor: NetworkInteracting + ) { + self.sessionStore = sessionStore + self.networkingInteractor = networkingInteractor + } + + func extend(topic: String, by ttl: Int64) async throws { + guard var session = sessionStore.getSession(forTopic: topic) else { + throw WalletConnectError.noSessionMatchingTopic(topic) + } + + let protocolMethod = SessionExtendProtocolMethod() + try session.updateExpiry(by: ttl) + let newExpiry = Int64(session.expiryDate.timeIntervalSince1970) + sessionStore.setSession(session) + let request = RPCRequest(method: protocolMethod.method, params: SessionType.UpdateExpiryParams(expiry: newExpiry)) + try await networkingInteractor.request(request, topic: topic, protocolMethod: protocolMethod) + } +} diff --git a/Sources/WalletConnectSign/Engine/Common/SessionExtendResponseSubscriber.swift b/Sources/WalletConnectSign/Engine/Common/SessionExtendResponseSubscriber.swift new file mode 100644 index 000000000..a802da680 --- /dev/null +++ b/Sources/WalletConnectSign/Engine/Common/SessionExtendResponseSubscriber.swift @@ -0,0 +1,48 @@ +import Foundation +import Combine + +final class SessionExtendResponseSubscriber { + var onExtend: ((String, Date) -> Void)? + + private let sessionStore: WCSessionStorage + private let networkingInteractor: NetworkInteracting + private var publishers = [AnyCancellable]() + private let logger: ConsoleLogging + + init( + networkingInteractor: NetworkInteracting, + sessionStore: WCSessionStorage, + logger: ConsoleLogging + ) { + self.networkingInteractor = networkingInteractor + self.sessionStore = sessionStore + self.logger = logger + + setupSubscriptions() + } + + // MARK: - Handle Response + private func setupSubscriptions() { + networkingInteractor.responseSubscription(on: SessionExtendProtocolMethod()) + .sink { [unowned self] (payload: ResponseSubscriptionPayload) in + handleUpdateExpiryResponse(payload: payload) + } + .store(in: &publishers) + } + + private func handleUpdateExpiryResponse(payload: ResponseSubscriptionPayload) { + guard var session = sessionStore.getSession(forTopic: payload.topic) else { return } + switch payload.response { + case .response: + do { + try session.updateExpiry(to: payload.request.expiry) + sessionStore.setSession(session) + onExtend?(session.topic, session.expiryDate) + } catch { + logger.error("Update expiry error: \(error.localizedDescription)") + } + case .error: + logger.error("Peer failed to extend session") + } + } +} diff --git a/Sources/WalletConnectSign/Engine/Controller/ControllerSessionStateMachine.swift b/Sources/WalletConnectSign/Engine/Controller/ControllerSessionStateMachine.swift index eb6becf93..d95a2b8b1 100644 --- a/Sources/WalletConnectSign/Engine/Controller/ControllerSessionStateMachine.swift +++ b/Sources/WalletConnectSign/Engine/Controller/ControllerSessionStateMachine.swift @@ -2,9 +2,7 @@ import Foundation import Combine final class ControllerSessionStateMachine { - var onNamespacesUpdate: ((String, [String: SessionNamespace]) -> Void)? - var onExtend: ((String, Date) -> Void)? private let sessionStore: WCSessionStorage private let networkingInteractor: NetworkInteracting @@ -35,31 +33,13 @@ final class ControllerSessionStateMachine { try await networkingInteractor.request(request, topic: topic, protocolMethod: protocolMethod) } - func extend(topic: String, by ttl: Int64) async throws { - var session = try getSession(for: topic) - let protocolMethod = SessionExtendProtocolMethod() - try validateController(session) - try session.updateExpiry(by: ttl) - let newExpiry = Int64(session.expiryDate.timeIntervalSince1970 ) - sessionStore.setSession(session) - let request = RPCRequest(method: protocolMethod.method, params: SessionType.UpdateExpiryParams(expiry: newExpiry)) - try await networkingInteractor.request(request, topic: topic, protocolMethod: protocolMethod) - } - // MARK: - Handle Response - private func setupSubscriptions() { networkingInteractor.responseSubscription(on: SessionUpdateProtocolMethod()) .sink { [unowned self] (payload: ResponseSubscriptionPayload) in handleUpdateResponse(payload: payload) } .store(in: &publishers) - - networkingInteractor.responseSubscription(on: SessionExtendProtocolMethod()) - .sink { [unowned self] (payload: ResponseSubscriptionPayload) in - handleUpdateExpiryResponse(payload: payload) - } - .store(in: &publishers) } private func handleUpdateResponse(payload: ResponseSubscriptionPayload) { @@ -80,22 +60,6 @@ final class ControllerSessionStateMachine { } } - private func handleUpdateExpiryResponse(payload: ResponseSubscriptionPayload) { - guard var session = sessionStore.getSession(forTopic: payload.topic) else { return } - switch payload.response { - case .response: - do { - try session.updateExpiry(to: payload.request.expiry) - sessionStore.setSession(session) - onExtend?(session.topic, session.expiryDate) - } catch { - logger.error("Update expiry error: \(error.localizedDescription)") - } - case .error: - logger.error("Peer failed to extend session") - } - } - // MARK: - Private private func getSession(for topic: String) throws -> WCSession { if let session = sessionStore.getSession(forTopic: topic) { diff --git a/Sources/WalletConnectSign/Engine/NonController/NonControllerSessionStateMachine.swift b/Sources/WalletConnectSign/Engine/NonController/NonControllerSessionStateMachine.swift index c7dba0e07..b371a579b 100644 --- a/Sources/WalletConnectSign/Engine/NonController/NonControllerSessionStateMachine.swift +++ b/Sources/WalletConnectSign/Engine/NonController/NonControllerSessionStateMachine.swift @@ -2,9 +2,7 @@ import Foundation import Combine final class NonControllerSessionStateMachine { - var onNamespacesUpdate: ((String, [String: SessionNamespace]) -> Void)? - var onExtend: ((String, Date) -> Void)? private let sessionStore: WCSessionStorage private let networkingInteractor: NetworkInteracting @@ -12,10 +10,12 @@ final class NonControllerSessionStateMachine { private var publishers = [AnyCancellable]() private let logger: ConsoleLogging - init(networkingInteractor: NetworkInteracting, - kms: KeyManagementServiceProtocol, - sessionStore: WCSessionStorage, - logger: ConsoleLogging) { + init( + networkingInteractor: NetworkInteracting, + kms: KeyManagementServiceProtocol, + sessionStore: WCSessionStorage, + logger: ConsoleLogging + ) { self.networkingInteractor = networkingInteractor self.kms = kms self.sessionStore = sessionStore @@ -28,11 +28,6 @@ final class NonControllerSessionStateMachine { .sink { [unowned self] (payload: RequestSubscriptionPayload) in onSessionUpdateNamespacesRequest(payload: payload, updateParams: payload.request) }.store(in: &publishers) - - networkingInteractor.requestSubscription(on: SessionExtendProtocolMethod()) - .sink { [unowned self] (payload: RequestSubscriptionPayload) in - onSessionUpdateExpiry(payload: payload, updateExpiryParams: payload.request) - }.store(in: &publishers) } private func respondError(payload: SubscriptionPayload, reason: SignReasonCode, protocolMethod: ProtocolMethod) { @@ -72,27 +67,4 @@ final class NonControllerSessionStateMachine { onNamespacesUpdate?(session.topic, updateParams.namespaces) } - - private func onSessionUpdateExpiry(payload: SubscriptionPayload, updateExpiryParams: SessionType.UpdateExpiryParams) { - let protocolMethod = SessionExtendProtocolMethod() - let topic = payload.topic - guard var session = sessionStore.getSession(forTopic: topic) else { - return respondError(payload: payload, reason: .noSessionForTopic, protocolMethod: protocolMethod) - } - guard session.peerIsController else { - return respondError(payload: payload, reason: .unauthorizedExtendRequest, protocolMethod: protocolMethod) - } - do { - try session.updateExpiry(to: updateExpiryParams.expiry) - } catch { - return respondError(payload: payload, reason: .invalidExtendRequest, protocolMethod: protocolMethod) - } - sessionStore.setSession(session) - - Task(priority: .high) { - try await networkingInteractor.respondSuccess(topic: payload.topic, requestId: payload.id, protocolMethod: protocolMethod) - } - - onExtend?(session.topic, session.expiryDate) - } } diff --git a/Sources/WalletConnectSign/Sign/SignClient.swift b/Sources/WalletConnectSign/Sign/SignClient.swift index 57dd897a2..1ea172041 100644 --- a/Sources/WalletConnectSign/Sign/SignClient.swift +++ b/Sources/WalletConnectSign/Sign/SignClient.swift @@ -109,6 +109,9 @@ public final class SignClient: SignClientProtocol { private let sessionPingService: SessionPingService private let nonControllerSessionStateMachine: NonControllerSessionStateMachine private let controllerSessionStateMachine: ControllerSessionStateMachine + private let sessionExtendRequester: SessionExtendRequester + private let sessionExtendRequestSubscriber: SessionExtendRequestSubscriber + private let sessionExtendResponseSubscriber: SessionExtendResponseSubscriber private let appProposeService: AppProposeService private let historyService: HistoryService private let cleanupService: SignCleanupService @@ -138,6 +141,9 @@ public final class SignClient: SignClientProtocol { sessionPingService: SessionPingService, nonControllerSessionStateMachine: NonControllerSessionStateMachine, controllerSessionStateMachine: ControllerSessionStateMachine, + sessionExtendRequester: SessionExtendRequester, + sessionExtendRequestSubscriber: SessionExtendRequestSubscriber, + sessionExtendResponseSubscriber: SessionExtendResponseSubscriber, appProposeService: AppProposeService, disconnectService: DisconnectService, historyService: HistoryService, @@ -152,6 +158,9 @@ public final class SignClient: SignClientProtocol { self.sessionPingService = sessionPingService self.nonControllerSessionStateMachine = nonControllerSessionStateMachine self.controllerSessionStateMachine = controllerSessionStateMachine + self.sessionExtendRequester = sessionExtendRequester + self.sessionExtendRequestSubscriber = sessionExtendRequestSubscriber + self.sessionExtendResponseSubscriber = sessionExtendResponseSubscriber self.appProposeService = appProposeService self.historyService = historyService self.cleanupService = cleanupService @@ -259,13 +268,13 @@ public final class SignClient: SignClientProtocol { try await controllerSessionStateMachine.update(topic: topic, namespaces: namespaces) } - /// For wallet to extend a session to 7 days + /// For dapp and wallet to extend a session to 7 days /// - Parameters: /// - topic: Topic of the session that is intended to be extended. public func extend(topic: String) async throws { let ttl: Int64 = Session.defaultTimeToLive if sessionEngine.hasSession(for: topic) { - try await controllerSessionStateMachine.extend(topic: topic, by: ttl) + try await sessionExtendRequester.extend(topic: topic, by: ttl) } } @@ -399,13 +408,13 @@ public final class SignClient: SignClientProtocol { controllerSessionStateMachine.onNamespacesUpdate = { [unowned self] topic, namespaces in sessionUpdatePublisherSubject.send((topic, namespaces)) } - controllerSessionStateMachine.onExtend = { [unowned self] topic, date in - sessionExtendPublisherSubject.send((topic, date)) - } nonControllerSessionStateMachine.onNamespacesUpdate = { [unowned self] topic, namespaces in sessionUpdatePublisherSubject.send((topic, namespaces)) } - nonControllerSessionStateMachine.onExtend = { [unowned self] topic, date in + sessionExtendRequestSubscriber.onExtend = { [unowned self] topic, date in + sessionExtendPublisherSubject.send((topic, date)) + } + sessionExtendResponseSubscriber.onExtend = { [unowned self] topic, date in sessionExtendPublisherSubject.send((topic, date)) } sessionEngine.onEventReceived = { [unowned self] topic, event, chainId in diff --git a/Sources/WalletConnectSign/Sign/SignClientFactory.swift b/Sources/WalletConnectSign/Sign/SignClientFactory.swift index a7903a01b..cfaaf355f 100644 --- a/Sources/WalletConnectSign/Sign/SignClientFactory.swift +++ b/Sources/WalletConnectSign/Sign/SignClientFactory.swift @@ -30,6 +30,9 @@ public struct SignClientFactory { let sessionEngine = SessionEngine(networkingInteractor: networkingClient, historyService: historyService, verifyContextStore: verifyContextStore, verifyClient: verifyClient, kms: kms, sessionStore: sessionStore, logger: logger) let nonControllerSessionStateMachine = NonControllerSessionStateMachine(networkingInteractor: networkingClient, kms: kms, sessionStore: sessionStore, logger: logger) let controllerSessionStateMachine = ControllerSessionStateMachine(networkingInteractor: networkingClient, kms: kms, sessionStore: sessionStore, logger: logger) + let sessionExtendRequester = SessionExtendRequester(sessionStore: sessionStore, networkingInteractor: networkingClient) + let sessionExtendRequestSubscriber = SessionExtendRequestSubscriber(networkingInteractor: networkingClient, sessionStore: sessionStore, logger: logger) + let sessionExtendResponseSubscriber = SessionExtendResponseSubscriber(networkingInteractor: networkingClient, sessionStore: sessionStore, logger: logger) let sessionTopicToProposal = CodableStore(defaults: RuntimeKeyValueStorage(), identifier: SignStorageIdentifiers.sessionTopicToProposal.rawValue) let approveEngine = ApproveEngine( networkingInteractor: networkingClient, @@ -60,6 +63,9 @@ public struct SignClientFactory { sessionPingService: sessionPingService, nonControllerSessionStateMachine: nonControllerSessionStateMachine, controllerSessionStateMachine: controllerSessionStateMachine, + sessionExtendRequester: sessionExtendRequester, + sessionExtendRequestSubscriber: sessionExtendRequestSubscriber, + sessionExtendResponseSubscriber: sessionExtendResponseSubscriber, appProposeService: appProposerService, disconnectService: disconnectService, historyService: historyService, diff --git a/Sources/WalletConnectSign/Types/Session/WCSession.swift b/Sources/WalletConnectSign/Types/Session/WCSession.swift index f9acf29e6..30d237a85 100644 --- a/Sources/WalletConnectSign/Types/Session/WCSession.swift +++ b/Sources/WalletConnectSign/Types/Session/WCSession.swift @@ -158,7 +158,7 @@ struct WCSession: SequenceObject, Equatable { mutating func updateExpiry(to expiry: Int64) throws { let newExpiryDate = Date(timeIntervalSince1970: TimeInterval(expiry)) let maxExpiryDate = Date(timeIntervalSinceNow: TimeInterval(WCSession.defaultTimeToLive)) - guard newExpiryDate >= expiryDate && newExpiryDate <= maxExpiryDate else { + guard newExpiryDate.millisecondsSince1970 >= (expiryDate.millisecondsSince1970 / 1000) && newExpiryDate <= maxExpiryDate else { throw WalletConnectError.invalidUpdateExpiryValue } self.expiryDate = newExpiryDate diff --git a/Tests/WalletConnectSignTests/ControllerSessionStateMachineTests.swift b/Tests/WalletConnectSignTests/ControllerSessionStateMachineTests.swift index 539b335ec..f2a2a1772 100644 --- a/Tests/WalletConnectSignTests/ControllerSessionStateMachineTests.swift +++ b/Tests/WalletConnectSignTests/ControllerSessionStateMachineTests.swift @@ -6,6 +6,7 @@ import WalletConnectKMS class ControllerSessionStateMachineTests: XCTestCase { var sut: ControllerSessionStateMachine! + var sessionExtendRequester: SessionExtendRequester! var networkingInteractor: NetworkingInteractorMock! var storageMock: WCSessionStorageMock! var cryptoMock: KeyManagementServiceMock! @@ -15,6 +16,7 @@ class ControllerSessionStateMachineTests: XCTestCase { storageMock = WCSessionStorageMock() cryptoMock = KeyManagementServiceMock() sut = ControllerSessionStateMachine(networkingInteractor: networkingInteractor, kms: cryptoMock, sessionStore: storageMock, logger: ConsoleLoggerMock()) + sessionExtendRequester = SessionExtendRequester(sessionStore: storageMock, networkingInteractor: networkingInteractor) } override func tearDown() { @@ -66,33 +68,17 @@ class ControllerSessionStateMachineTests: XCTestCase { let session = WCSession.stub(isSelfController: true, expiryDate: tomorrow) storageMock.setSession(session) let twoDays = 2*Time.day - await XCTAssertNoThrowAsync(try await sut.extend(topic: session.topic, by: Int64(twoDays))) + await XCTAssertNoThrowAsync(try await sessionExtendRequester.extend(topic: session.topic, by: Int64(twoDays))) let extendedSession = storageMock.getAll().first {$0.topic == session.topic}! XCTAssertEqual(extendedSession.expiryDate.timeIntervalSinceReferenceDate, TimeTraveler.dateByAdding(days: 2).timeIntervalSinceReferenceDate, accuracy: 1) } - func testUpdateExpirySessionNotSettled() async { - let tomorrow = TimeTraveler.dateByAdding(days: 1) - let session = WCSession.stub(isSelfController: false, expiryDate: tomorrow, acknowledged: false) - storageMock.setSession(session) - let twoDays = 2*Time.day - await XCTAssertThrowsErrorAsync(try await sut.extend(topic: session.topic, by: Int64(twoDays))) - } - - func testUpdateExpiryOnNonControllerClient() async { - let tomorrow = TimeTraveler.dateByAdding(days: 1) - let session = WCSession.stub(isSelfController: false, expiryDate: tomorrow) - storageMock.setSession(session) - let twoDays = 2*Time.day - await XCTAssertThrowsErrorAsync( try await sut.extend(topic: session.topic, by: Int64(twoDays))) - } - func testUpdateExpiryTtlTooHigh() async { let tomorrow = TimeTraveler.dateByAdding(days: 1) let session = WCSession.stub(isSelfController: true, expiryDate: tomorrow) storageMock.setSession(session) let tenDays = 10*Time.day - await XCTAssertThrowsErrorAsync( try await sut.extend(topic: session.topic, by: Int64(tenDays))) + await XCTAssertThrowsErrorAsync( try await sessionExtendRequester.extend(topic: session.topic, by: Int64(tenDays))) } func testUpdateExpiryTtlTooLow() async { @@ -100,6 +86,6 @@ class ControllerSessionStateMachineTests: XCTestCase { let session = WCSession.stub(isSelfController: true, expiryDate: dayAfterTommorow) storageMock.setSession(session) let oneDay = Int64(1*Time.day) - await XCTAssertThrowsErrorAsync( try await sut.extend(topic: session.topic, by: oneDay)) + await XCTAssertThrowsErrorAsync( try await sessionExtendRequester.extend(topic: session.topic, by: oneDay)) } } diff --git a/Tests/WalletConnectSignTests/NonControllerSessionStateMachineTests.swift b/Tests/WalletConnectSignTests/NonControllerSessionStateMachineTests.swift index aa4c917ca..7304ea2c8 100644 --- a/Tests/WalletConnectSignTests/NonControllerSessionStateMachineTests.swift +++ b/Tests/WalletConnectSignTests/NonControllerSessionStateMachineTests.swift @@ -67,20 +67,6 @@ class NonControllerSessionStateMachineTests: XCTestCase { } // MARK: - Update Expiry - - func testPeerUpdateExpirySuccess() { - let tomorrow = TimeTraveler.dateByAdding(days: 1) - let session = WCSession.stub(isSelfController: false, expiryDate: tomorrow) - storageMock.setSession(session) - let twoDaysFromNowTimestamp = Int64(TimeTraveler.dateByAdding(days: 2).timeIntervalSince1970) - - networkingInteractor.requestPublisherSubject.send((session.topic, RPCRequest.stubUpdateExpiry(expiry: twoDaysFromNowTimestamp), Data(), Date(), nil)) - let extendedSession = storageMock.getAll().first {$0.topic == session.topic}! - print(extendedSession.expiryDate) - - XCTAssertEqual(extendedSession.expiryDate.timeIntervalSince1970, TimeTraveler.dateByAdding(days: 2).timeIntervalSince1970, accuracy: 1) - } - func testPeerUpdateExpiryUnauthorized() { let tomorrow = TimeTraveler.dateByAdding(days: 1) let session = WCSession.stub(isSelfController: true, expiryDate: tomorrow)