Skip to content

Commit

Permalink
import share tests fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu committed Oct 24, 2023
1 parent 99bc575 commit a957ebf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/helpers/nodeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ export async function retrieveOrImportShare(params: {
const verifierIdStr = `${verifier}${verifierParams.verifier_id}`;
const hashedVerifierId = keccak256(Buffer.from(verifierIdStr, "utf8"));
const proxyEndpointNum = parseInt(hashedVerifierId, 16) % endpoints.length;

const items: Record<string, unknown>[] = [];
for (let i = 0; i < endpoints.length; i += 1) {
const x = responses[i];
Expand Down Expand Up @@ -310,6 +309,7 @@ export async function retrieveOrImportShare(params: {
| undefined
>(promiseArrRequest, async (shareResponseResult, sharedState) => {
let shareResponses: (void | JRPCResponse<ShareRequestResult>)[] = [];
// for import shares case, where result is an array
if (shareResponseResult.length === 1 && shareResponseResult[0] && Array.isArray(shareResponseResult[0].result)) {
// this is for import shares
const importedSharesResult = shareResponseResult[0];
Expand Down
8 changes: 5 additions & 3 deletions test/sapphire_devnet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import TorusUtils from "../src/torus";
import { generateIdToken, lookupVerifier } from "./helpers";

const TORUS_TEST_EMAIL = "[email protected]";
const TORUS_IMPORT_EMAIL = "[email protected]";
const TORUS_IMPORT_EMAIL = "[email protected]";

const TORUS_EXTENDED_VERIFIER_EMAIL = "[email protected]";

Expand Down Expand Up @@ -286,7 +286,7 @@ describe("torus utils sapphire", function () {
});

it("should be able to key assign", async function () {
const email = faker.internet.email();
const email = `${faker.internet.email()}`;
const verifierDetails = { verifier: TORUS_TEST_VERIFIER, verifierId: email };
const nodeDetails = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const torusNodeEndpoints = nodeDetails.torusNodeSSSEndpoints;
Expand Down Expand Up @@ -396,8 +396,10 @@ describe("torus utils sapphire", function () {
privHex
);
expect(result.finalKeyData.privKey).to.be.equal(privHex);
const result1 = await torus.getPublicAddress(torusNodeEndpoints, nodeDetails.torusNodePub, { verifier: TORUS_TEST_VERIFIER, verifierId: email });
expect(result1.finalKeyData.evmAddress).to.be.equal(result.finalKeyData.evmAddress);
});
it.skip("should be able to import a key for a existing user", async function () {
it("should be able to import a key for a existing user", async function () {
let verifierDetails = { verifier: TORUS_TEST_VERIFIER, verifierId: TORUS_IMPORT_EMAIL };
const nodeDetails = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const torusNodeEndpoints = nodeDetails.torusNodeSSSEndpoints;
Expand Down
2 changes: 1 addition & 1 deletion test/sapphire_mainnet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("torus utils sapphire mainnet", function () {
});
});

it("should be able to import a key for a new user", async function () {
it.skip("should be able to import a key for a new user", async function () {
const email = faker.internet.email();
const token = generateIdToken(email, "ES256");
const privKeyBuffer = generatePrivate();
Expand Down

0 comments on commit a957ebf

Please sign in to comment.