Skip to content

Commit

Permalink
Update SapphireDevnetTest.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
metalurgical committed May 14, 2024
1 parent c01778a commit d3ba2f7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Tests/TorusUtilsTests/SapphireDevnetTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@ final class SapphireDevnetTest: XCTestCase {
torus = TorusUtils(params: TorusOptions(clientId: "YOUR_CLIENT_ID", network: .sapphire(.SAPPHIRE_DEVNET)))
}

func test_should_be_able_to_aggregate_login() async throws {
let email: String = generateRandomEmail(of: 6)
let jwt = try! generateIdToken(email: email)
let hashedIDToken = try KeyUtils.keccak256Data(jwt)
let verifierParams = VerifierParams(verifier_id: email)

let nodeDetails = try await fnd.getNodeDetails(verifier: TORUS_TEST_AGGREGATE_VERIFIER, verifierID: email)
let extraParams = [
"verify_params": [ShareRequestParams.ShareRequestVerifyParams(verifier_id: email, idtoken: jwt)],
"sub_verifier_ids": [TORUS_TEST_VERIFIER],
] as [String: Codable]
let data = try await torus.retrieveShares(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), indexes: nodeDetails.getTorusIndexes(), verifier: TORUS_TEST_AGGREGATE_VERIFIER, verifierParams: verifierParams, idToken: hashedIDToken, extraParams: extraParams)

XCTAssertLessThan(data.metadata.serverTimeOffset, 20)
XCTAssertNotNil(data.finalKeyData.privKey)
XCTAssertNotNil(data.oAuthKeyData.evmAddress)
XCTAssertEqual(data.metadata.typeOfUser, .v2)
}

// NB!!!
// Note: Some javascript tests are wrong, they should be using .sapphire(.SAPPHIRE_DEVNET)
// and not .legacy(.TESTNET)
Expand Down

0 comments on commit d3ba2f7

Please sign in to comment.