Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tests] #250: Re-enable session delete integration test #318

Merged
merged 1 commit into from
Jul 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 26 additions & 18 deletions Example/IntegrationTests/Sign/SignClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,32 @@ final class SignClientTests: XCTestCase {
wait(for: [sessionRejectExpectation], timeout: defaultTimeout)
}

func testSessionDelete() async throws {
let dapp = proposer!
let wallet = responder!
let sessionDeleteExpectation = expectation(description: "Wallet expects session to be deleted")
let requiredNamespaces = ProposalNamespace.stubRequired()
let sessionNamespaces = SessionNamespace.make(toRespond: requiredNamespaces)

wallet.onSessionProposal = { proposal in
Task(priority: .high) {
do { try await wallet.client.approve(proposalId: proposal.id, namespaces: sessionNamespaces) } catch { XCTFail("\(error)") }
}
}
dapp.onSessionSettled = { settledSession in
Task(priority: .high) {
try await dapp.client.disconnect(topic: settledSession.topic, reason: Reason(code: 5900, message: "User disconnected session"))
}
}
wallet.onSessionDelete = {
sessionDeleteExpectation.fulfill()
}

let uri = try await dapp.client.connect(requiredNamespaces: requiredNamespaces)
try await wallet.client.pair(uri: uri!)
wait(for: [sessionDeleteExpectation], timeout: defaultTimeout)
}

func testNewPairingPing() async throws {
let dapp = proposer!
let wallet = responder!
Expand Down Expand Up @@ -160,24 +186,6 @@ final class SignClientTests: XCTestCase {
// wait(for: [proposerSettlesSessionExpectation, responderSettlesSessionExpectation], timeout: defaultTimeout)
// }
//
// func testDeleteSession() async {
// await waitClientsConnected()
// let sessionDeleteExpectation = expectation(description: "Responder is notified on session deletion")
// let uri = try! await proposer.client.connect(namespaces: [Namespace.stub()])!
// _ = try! await responder.client.pair(uri: uri)
// responder.onSessionProposal = {[unowned self] proposal in
// try? self.responder.client.approve(proposalId: proposal.id, accounts: [], namespaces: [])
// }
// proposer.onSessionSettled = {[unowned self] settledSession in
// Task {
// try await self.proposer.client.disconnect(topic: settledSession.topic, reason: Reason(code: 5900, message: "User disconnected session"))
// }
// }
// responder.onSessionDelete = {
// sessionDeleteExpectation.fulfill()
// }
// wait(for: [sessionDeleteExpectation], timeout: defaultTimeout)
// }
//
// func testProposerRequestSessionRequest() async {
// await waitClientsConnected()
Expand Down