Skip to content

Commit

Permalink
[Test] #250: Re-enable session reject integration test case (#269)
Browse files Browse the repository at this point in the history
Re-enable session rejection test

Co-authored-by: André Vants
  • Loading branch information
André Vants authored Jun 14, 2022
1 parent e3881c5 commit 2b8072a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Sources/WalletConnectSign/Session.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public struct Session {

extension Session {

public struct Proposal {
public struct Proposal: Equatable {
public var id: String
public let proposer: AppMetadata
public let requiredNamespaces: [String: ProposalNamespace]
Expand Down
38 changes: 22 additions & 16 deletions Tests/IntegrationTests/SignClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,28 @@ final class SignClientTests: XCTestCase {
try await wallet.client.pair(uri: uri!)
wait(for: [dappSettlementExpectation, walletSettlementExpectation], timeout: defaultTimeout)
}

func testSessionReject() async throws {
let dapp = proposer!
let wallet = responder!
let sessionRejectExpectation = expectation(description: "Proposer is notified on session rejection")
var rejectedProposal: Session.Proposal?

let uri = try await dapp.client.connect(requiredNamespaces: ProposalNamespace.stubRequired())
try await wallet.client.pair(uri: uri!)

wallet.onSessionProposal = { proposal in
do {
try wallet.client.reject(proposalId: proposal.id, reason: .disapprovedChains) // TODO: Review reason
rejectedProposal = proposal
} catch { XCTFail("\(error)") }
}
dapp.onSessionRejected = { proposal, _ in
XCTAssertEqual(rejectedProposal, proposal)
sessionRejectExpectation.fulfill() // TODO: Assert reason code
}
wait(for: [sessionRejectExpectation], timeout: defaultTimeout)
}
//
// func testNewPairingPing() async {
// let responderReceivesPingResponseExpectation = expectation(description: "Responder receives ping response")
Expand Down Expand Up @@ -123,22 +145,6 @@ final class SignClientTests: XCTestCase {
// wait(for: [proposerSettlesSessionExpectation, responderSettlesSessionExpectation], timeout: defaultTimeout)
// }
//
// func testResponderRejectsSession() async {
// await waitClientsConnected()
// let sessionRejectExpectation = expectation(description: "Proposer is notified on session rejection")
// let uri = try! await proposer.client.connect(namespaces: [Namespace.stub()])!
// _ = try! await responder.client.pair(uri: uri)
//
// responder.onSessionProposal = {[unowned self] proposal in
// self.responder.client.reject(proposal: proposal, reason: .disapprovedChains)
// }
// proposer.onSessionRejected = { _, reason in
// XCTAssertEqual(reason.code, 5000)
// sessionRejectExpectation.fulfill()
// }
// wait(for: [sessionRejectExpectation], timeout: defaultTimeout)
// }
//
// func testDeleteSession() async {
// await waitClientsConnected()
// let sessionDeleteExpectation = expectation(description: "Responder is notified on session deletion")
Expand Down

0 comments on commit 2b8072a

Please sign in to comment.