From e1431dc3ccb663b6120b4eb211600d4f1f9052f7 Mon Sep 17 00:00:00 2001 From: ieow Date: Tue, 7 Jan 2025 13:30:48 +0800 Subject: [PATCH] add tests --- test/sapphire_devnet.test.ts | 31 ++++++++++++++++++++++++++++ test/sapphire_devnet_ed25519.test.ts | 31 ++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/test/sapphire_devnet.test.ts b/test/sapphire_devnet.test.ts index 8cc2e8f..003bab2 100644 --- a/test/sapphire_devnet.test.ts +++ b/test/sapphire_devnet.test.ts @@ -240,6 +240,37 @@ describe("torus utils sapphire devnet", function () { }); }); + it("should should fetch public address with keyType", async function () { + const verifierDetails = { verifier: TORUS_TEST_VERIFIER, verifierId: "Willa_Funk11@gmail.com" }; + const nodeDetails = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails); + const torusNodeEndpoints = nodeDetails.torusNodeSSSEndpoints; + const result = await torus.getPublicAddress(torusNodeEndpoints, nodeDetails.torusNodePub, { ...verifierDetails, keyType: "ed25519" }); + expect(result.finalKeyData.walletAddress).eql("HHmiJMCAwhyf9ZWNtj7FEKGXeeC2NjUjPobpDKm43yKs"); + delete result.metadata.serverTimeOffset; + expect(result).eql({ + oAuthKeyData: { + walletAddress: "49yLu8yLqpuCXchzjQSt1tpBz8AP2E9EzzP7a8QtxmTE", + X: "5d39eba90fafbce150b33b9a60b41e1cfdf9e2640b55bf96b787173d74f8e415", + Y: "099639b7da35c1f31a44da7399a29d7db8eaa9639582cf7ed80aa4f7216adf2e", + }, + finalKeyData: { + walletAddress: "HHmiJMCAwhyf9ZWNtj7FEKGXeeC2NjUjPobpDKm43yKs", + X: "575203523b34bcfa2c25c428871c421afd69dbcb7375833b52ef264aaa466a81", + Y: "26f0b1f5740088c2ecf676081b8e2fe5254f1cbb693947ae391af13500d706f2", + }, + metadata: { + pubNonce: { + X: "71bf997547c1ac3f0babee87ebac055e8542863ebb1ba66e8092499eacbffd22", + Y: "71a0a70c5ae06d7eeb45673d4081fdfc9f29c4acfbbb57bf52a33dd7630599b1", + }, + nonce: new BN("0", "hex"), + typeOfUser: "v2", + upgraded: false, + }, + nodesData: result.nodesData, + }); + }); + it("should fetch public address of imported user", async function () { const verifierDetails = { verifier: TORUS_TEST_VERIFIER, verifierId: TORUS_IMPORT_EMAIL }; const nodeDetails = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails); diff --git a/test/sapphire_devnet_ed25519.test.ts b/test/sapphire_devnet_ed25519.test.ts index ad77998..52e8343 100644 --- a/test/sapphire_devnet_ed25519.test.ts +++ b/test/sapphire_devnet_ed25519.test.ts @@ -65,6 +65,37 @@ describe("torus utils ed25519 sapphire devnet", function () { }); }); + it("should should fetch public address with keyType", async function () { + const verifierDetails = { verifier: TORUS_TEST_VERIFIER, verifierId: "Willa_Funk11@gmail.com" }; + const nodeDetails = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails); + const torusNodeEndpoints = nodeDetails.torusNodeSSSEndpoints; + const result = await torus.getPublicAddress(torusNodeEndpoints, nodeDetails.torusNodePub, { ...verifierDetails, keyType: "secp256k1" }); + expect(result.finalKeyData.walletAddress).eql("0xc53Df7C3Eb4990CfB8f903e4240dBB3BBa715A96"); + delete result.metadata.serverTimeOffset; + expect(result).eql({ + oAuthKeyData: { + walletAddress: "0x27890B4B87E5a39CA0510B32B2b2621d7D1eF7c0", + X: "d594a7c8368d37b2ca31b55be7db1b6a6bce9a3ddbcc573d5460bc7d630024e3", + Y: "09416f76bdbb88307900f748f0edc1cc345a9ba78c98508c8e29236d98b1d043", + }, + finalKeyData: { + walletAddress: "0xc53Df7C3Eb4990CfB8f903e4240dBB3BBa715A96", + X: "c60e9fbdb820c2ea430769fce86e2fd56ac4a4e5137346d54a914d57c56cab22", + Y: "02df3331a556d429baea94b0da05ec9438ea2ba9912af0fc4b76925531fc4629", + }, + metadata: { + pubNonce: { + X: "d3edb1a89af7db7a078e73cfdb59f9be82512e8121751934122f104b28b92074", + Y: "2a2700c2934c0a0b5cdfaeeca5a4e279fc9d46c6b6837de6f2e2f15ad39c51a3", + }, + nonce: new BN("0", "hex"), + typeOfUser: "v2", + upgraded: false, + }, + nodesData: result.nodesData, + }); + }); + it("should be able to import a key for a new user", async function () { const email = faker.internet.email(); const token = generateIdToken(email, "ES256");