diff --git a/src/helpers/nodeUtils.ts b/src/helpers/nodeUtils.ts index 5a1e85f..cba9486 100644 --- a/src/helpers/nodeUtils.ts +++ b/src/helpers/nodeUtils.ts @@ -88,7 +88,7 @@ export const GetPubKeyOrKeyAssign = async (params: { }); const errorResult = thresholdSame( - lookupPubKeys.map((x2) => x2 && x2.error), + lookupResults.map((x2) => x2 && x2.error), minThreshold ); @@ -191,7 +191,7 @@ export const VerifierLookupRequest = async (params: { }); const errorResult = thresholdSame( - lookupPubKeys.map((x2) => x2 && x2.error), + lookupResults.map((x2) => x2 && x2.error), minThreshold ); @@ -283,19 +283,21 @@ export async function retrieveOrImportShare(params: { } finalImportedShares = newImportedShares; } else if (!useDkg) { - // TODO: why use getrandombytes here? const bufferKey = keyType === KEY_TYPE.SECP256K1 ? generatePrivateKey(ecCurve, Buffer) : await getRandomBytes(32); const generatedShares = await generateShares(ecCurve, keyType, serverTimeOffset, indexes, nodePubkeys, Buffer.from(bufferKey)); finalImportedShares = [...finalImportedShares, ...generatedShares]; } let existingPubKey; - // can only import shares if override existing key is allowed or for new non dkg registration + // can only import new shares if override existing key is allowed or when doing a new non dkg registration if (finalImportedShares.length > 0) { - // in case not allowed to overide existing key for import request + // in case not allowed to override existing key for import request // check if key exists if (!overrideExistingKey) { const keyLookupResult = await VerifierLookupRequest({ endpoints, verifier, verifierId: verifierParams.verifier_id, keyType }); - if (keyLookupResult.errorResult) { + if ( + keyLookupResult.errorResult && + !(keyLookupResult.errorResult?.data as string)?.includes("Verifier + VerifierID has not yet been assigned") + ) { throw new Error( `node results do not match at first lookup ${JSON.stringify(keyLookupResult.keyResult || {})}, ${JSON.stringify(keyLookupResult.errorResult || {})}` ); diff --git a/test/sapphire_devnet.test.ts b/test/sapphire_devnet.test.ts index 7a96e50..3f324a2 100644 --- a/test/sapphire_devnet.test.ts +++ b/test/sapphire_devnet.test.ts @@ -74,7 +74,7 @@ describe.only("torus utils sapphire devnet", function () { }); }); - it.only("should be able to login a v1 user", async function () { + it("should be able to login a v1 user", async function () { const email = "himanshu@tor.us"; const verifier = "google-lrc"; const token = generateIdToken(email, "ES256"); @@ -122,11 +122,6 @@ describe.only("torus utils sapphire devnet", function () { }, nodesData: retrieveSharesResponse.nodesData, }); - const retrieveSharesResponse1 = await legacyTorus.retrieveShares( - getRetrieveSharesParams(torusNodeEndpoints, torusIndexes, TORUS_TEST_VERIFIER, { verifier_id: email }, token, torusNodePub) - ); - // eslint-disable-next-line no-console - console.log("retrieveSharesResponse1", retrieveSharesResponse1); }); it("should fetch user type and public address of legacy v2 user", async function () { diff --git a/test/testnet.test.ts b/test/testnet.test.ts index e495699..258a89e 100644 --- a/test/testnet.test.ts +++ b/test/testnet.test.ts @@ -14,7 +14,7 @@ const TORUS_TEST_EMAIL = "archit1@tor.us"; const TORUS_TEST_VERIFIER = "torus-test-health"; const TORUS_TEST_AGGREGATE_VERIFIER = "torus-test-health-aggregate"; -describe("torus utils migrated testnet on sapphire", function () { +describe.only("torus utils migrated testnet on sapphire", function () { let torus: TorusUtils; let TORUS_NODE_MANAGER: NodeDetailManager;