From d6d570fff20b921986c88d14fb23186129e18ce2 Mon Sep 17 00:00:00 2001 From: metalurgical <97008724+metalurgical@users.noreply.github.com> Date: Tue, 21 May 2024 10:36:09 +0200 Subject: [PATCH] extend import share test --- Tests/TorusUtilsTests/SapphireDevnetTest.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Tests/TorusUtilsTests/SapphireDevnetTest.swift b/Tests/TorusUtilsTests/SapphireDevnetTest.swift index e7f2aa8e..c85f57c6 100644 --- a/Tests/TorusUtilsTests/SapphireDevnetTest.swift +++ b/Tests/TorusUtilsTests/SapphireDevnetTest.swift @@ -48,7 +48,7 @@ final class SapphireDevnetTest: XCTestCase { func test_should_be_able_to_import_key_for_a_new_user() async throws { let fakeEmail = generateRandomEmail(of: 6) - let jwt = try generateIdToken(email: fakeEmail) + var jwt = try generateIdToken(email: fakeEmail) let privateKey = try KeyUtils.generateSecret() let verifier = TORUS_TEST_VERIFIER @@ -59,8 +59,16 @@ final class SapphireDevnetTest: XCTestCase { let verifierParams = VerifierParams(verifier_id: verifierID) let val = try await torus.importPrivateKey(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), nodeIndexes: nodeDetails.getTorusIndexes(), nodePubKeys: nodeDetails.getTorusNodePub(), verifier: verifier, verifierParams: verifierParams, idToken: jwt, newPrivateKey: privateKey) - XCTAssertEqual(val.finalKeyData.privKey, privateKey) + + jwt = try generateIdToken(email: fakeEmail) + let shareRetrieval = try await torus.retrieveShares(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), indexes: nodeDetails.getTorusIndexes(), verifier: verifier, verifierParams: verifierParams, idToken: jwt) + XCTAssertEqual(shareRetrieval.finalKeyData.privKey, privateKey) + + let addressRetrieval = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) + let publicAddress = try SecretKey(hex: privateKey).toPublic().serialize(compressed: false) + let retrievedAddress = KeyUtils.getPublicKeyFromCoords(pubKeyX: addressRetrieval.finalKeyData!.X, pubKeyY: addressRetrieval.finalKeyData!.Y) + XCTAssertEqual(publicAddress, retrievedAddress) } func test_should_be_able_to_key_assign() async throws {