From 30ca244c3242eda6021a59cdf6f3d5afa696a422 Mon Sep 17 00:00:00 2001 From: Arseniy Klempner Date: Tue, 11 Nov 2025 10:15:12 -0800 Subject: [PATCH] fix: update tests --- packages/rln/.mocharc.cjs | 2 +- packages/rln/package.json | 2 -- .../src/contract/proof.integration.spec.ts | 22 ++----------------- ...erokit.spec.ts => zerokit.browser.spec.ts} | 0 4 files changed, 3 insertions(+), 23 deletions(-) rename packages/rln/src/{zerokit.spec.ts => zerokit.browser.spec.ts} (100%) diff --git a/packages/rln/.mocharc.cjs b/packages/rln/.mocharc.cjs index 2f663971cd..fb31453aed 100644 --- a/packages/rln/.mocharc.cjs +++ b/packages/rln/.mocharc.cjs @@ -22,7 +22,7 @@ if (process.env.CI) { }; // Exclude integration tests in CI (they require RPC access) console.log("Excluding integration tests in CI environment"); - config.ignore = 'src/**/*.integration.spec.ts'; + config.ignore = ['src/**/*.integration.spec.ts', 'src/**/*.browser.spec.ts']; } else { console.log("Running tests serially. To enable parallel execution update mocha config"); } diff --git a/packages/rln/package.json b/packages/rln/package.json index 211703506a..2b479d65e0 100644 --- a/packages/rln/package.json +++ b/packages/rln/package.json @@ -39,8 +39,6 @@ "check:lint": "eslint \"src/!(resources)/**/*.{ts,js}\" *.js", "check:spelling": "cspell \"{README.md,src/**/*.ts}\"", "test": "NODE_ENV=test run-s test:*", - "test:unit": "NODE_ENV=test mocha 'src/**/*.spec.ts' --ignore 'src/**/*.integration.spec.ts'", - "test:integration": "NODE_ENV=test mocha 'src/**/*.integration.spec.ts'", "test:browser": "karma start karma.conf.cjs", "watch:build": "tsc -p tsconfig.json -w", "watch:test": "mocha --watch", diff --git a/packages/rln/src/contract/proof.integration.spec.ts b/packages/rln/src/contract/proof.integration.spec.ts index 740dd55c0a..06746f4e6d 100644 --- a/packages/rln/src/contract/proof.integration.spec.ts +++ b/packages/rln/src/contract/proof.integration.spec.ts @@ -50,15 +50,12 @@ describe("RLN Proof Integration Tests", function () { // Use the known credential hash and password from the test data const credentialHash = TEST_KEYSTORE_DATA.credentialHash; const password = TEST_KEYSTORE_DATA.password; - console.log(`Using credential hash: ${credentialHash}`); const credential = await keystore.readCredential(credentialHash, password); if (!credential) { throw new Error("Failed to unlock credential with provided password"); } - // Extract the ID commitment from the credential const idCommitment = credential.identity.IDCommitmentBigInt; - console.log(`ID Commitment from keystore: ${idCommitment.toString()}`); const publicClient = createPublicClient({ chain: lineaSepolia, @@ -76,36 +73,25 @@ describe("RLN Proof Integration Tests", function () { walletClient: dummyWalletClient }); - // First, get membership info to find the index const membershipInfo = await contract.getMembershipInfo(idCommitment); if (!membershipInfo) { - console.log( + throw new Error( `ID commitment ${idCommitment.toString()} not found in membership set` ); - this.skip(); - return; } - console.log(`Found membership at index: ${membershipInfo.index}`); - console.log(`Membership state: ${membershipInfo.state}`); - - // Get the merkle proof for this member's index const merkleProof = await contract.getMerkleProof(membershipInfo.index); expect(merkleProof).to.be.an("array"); expect(merkleProof).to.have.lengthOf(MERKLE_TREE_DEPTH); // RLN uses fixed depth merkle tree - console.log(`Merkle proof for ID commitment ${idCommitment.toString()}:`); - console.log(`Index: ${membershipInfo.index}`); - console.log(`Proof elements (${merkleProof.length}):`); merkleProof.forEach((element, i) => { console.log( ` [${i}]: ${element.toString()} (0x${element.toString(16)})` ); }); - // Verify all proof elements are valid bigints merkleProof.forEach((element, i) => { expect(element).to.be.a( "bigint", @@ -115,7 +101,7 @@ describe("RLN Proof Integration Tests", function () { }); }); - it.only("should generate a valid RLN proof", async function () { + it("should generate a valid RLN proof", async function () { const publicClient = createPublicClient({ chain: lineaSepolia, transport: http(rpcUrl) @@ -131,7 +117,6 @@ describe("RLN Proof Integration Tests", function () { publicClient, walletClient: dummyWalletClient }); - // get credential from keystore const keystore = Keystore.fromString(TEST_KEYSTORE_DATA.keystoreJson); if (!keystore) { throw new Error("Failed to load test keystore"); @@ -153,7 +138,6 @@ describe("RLN Proof Integration Tests", function () { const merkleRoot = await contract.getMerkleRoot(); const rateCommitment = calculateRateCommitment(idCommitment, rateLimit); - // Get the array of indexes that correspond to each proof element const proofElementIndexes = extractPathDirectionsFromProof( merkleProof, rateCommitment, @@ -163,10 +147,8 @@ describe("RLN Proof Integration Tests", function () { throw new Error("Failed to extract proof element indexes"); } - // Verify the array has the correct length expect(proofElementIndexes).to.have.lengthOf(MERKLE_TREE_DEPTH); - // Verify that we can reconstruct the root using these indexes const reconstructedRoot = reconstructMerkleRoot( merkleProof as bigint[], BigInt(membershipInfo.index), diff --git a/packages/rln/src/zerokit.spec.ts b/packages/rln/src/zerokit.browser.spec.ts similarity index 100% rename from packages/rln/src/zerokit.spec.ts rename to packages/rln/src/zerokit.browser.spec.ts