Skip to content

Commit 30ca244

Browse files
committed
fix: update tests
1 parent feb8b87 commit 30ca244

File tree

4 files changed

+3
-23
lines changed

4 files changed

+3
-23
lines changed

packages/rln/.mocharc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if (process.env.CI) {
2222
};
2323
// Exclude integration tests in CI (they require RPC access)
2424
console.log("Excluding integration tests in CI environment");
25-
config.ignore = 'src/**/*.integration.spec.ts';
25+
config.ignore = ['src/**/*.integration.spec.ts', 'src/**/*.browser.spec.ts'];
2626
} else {
2727
console.log("Running tests serially. To enable parallel execution update mocha config");
2828
}

packages/rln/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
"check:lint": "eslint \"src/!(resources)/**/*.{ts,js}\" *.js",
4040
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
4141
"test": "NODE_ENV=test run-s test:*",
42-
"test:unit": "NODE_ENV=test mocha 'src/**/*.spec.ts' --ignore 'src/**/*.integration.spec.ts'",
43-
"test:integration": "NODE_ENV=test mocha 'src/**/*.integration.spec.ts'",
4442
"test:browser": "karma start karma.conf.cjs",
4543
"watch:build": "tsc -p tsconfig.json -w",
4644
"watch:test": "mocha --watch",

packages/rln/src/contract/proof.integration.spec.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@ describe("RLN Proof Integration Tests", function () {
5050
// Use the known credential hash and password from the test data
5151
const credentialHash = TEST_KEYSTORE_DATA.credentialHash;
5252
const password = TEST_KEYSTORE_DATA.password;
53-
console.log(`Using credential hash: ${credentialHash}`);
5453
const credential = await keystore.readCredential(credentialHash, password);
5554
if (!credential) {
5655
throw new Error("Failed to unlock credential with provided password");
5756
}
5857

59-
// Extract the ID commitment from the credential
6058
const idCommitment = credential.identity.IDCommitmentBigInt;
61-
console.log(`ID Commitment from keystore: ${idCommitment.toString()}`);
6259

6360
const publicClient = createPublicClient({
6461
chain: lineaSepolia,
@@ -76,36 +73,25 @@ describe("RLN Proof Integration Tests", function () {
7673
walletClient: dummyWalletClient
7774
});
7875

79-
// First, get membership info to find the index
8076
const membershipInfo = await contract.getMembershipInfo(idCommitment);
8177

8278
if (!membershipInfo) {
83-
console.log(
79+
throw new Error(
8480
`ID commitment ${idCommitment.toString()} not found in membership set`
8581
);
86-
this.skip();
87-
return;
8882
}
8983

90-
console.log(`Found membership at index: ${membershipInfo.index}`);
91-
console.log(`Membership state: ${membershipInfo.state}`);
92-
93-
// Get the merkle proof for this member's index
9484
const merkleProof = await contract.getMerkleProof(membershipInfo.index);
9585

9686
expect(merkleProof).to.be.an("array");
9787
expect(merkleProof).to.have.lengthOf(MERKLE_TREE_DEPTH); // RLN uses fixed depth merkle tree
9888

99-
console.log(`Merkle proof for ID commitment ${idCommitment.toString()}:`);
100-
console.log(`Index: ${membershipInfo.index}`);
101-
console.log(`Proof elements (${merkleProof.length}):`);
10289
merkleProof.forEach((element, i) => {
10390
console.log(
10491
` [${i}]: ${element.toString()} (0x${element.toString(16)})`
10592
);
10693
});
10794

108-
// Verify all proof elements are valid bigints
10995
merkleProof.forEach((element, i) => {
11096
expect(element).to.be.a(
11197
"bigint",
@@ -115,7 +101,7 @@ describe("RLN Proof Integration Tests", function () {
115101
});
116102
});
117103

118-
it.only("should generate a valid RLN proof", async function () {
104+
it("should generate a valid RLN proof", async function () {
119105
const publicClient = createPublicClient({
120106
chain: lineaSepolia,
121107
transport: http(rpcUrl)
@@ -131,7 +117,6 @@ describe("RLN Proof Integration Tests", function () {
131117
publicClient,
132118
walletClient: dummyWalletClient
133119
});
134-
// get credential from keystore
135120
const keystore = Keystore.fromString(TEST_KEYSTORE_DATA.keystoreJson);
136121
if (!keystore) {
137122
throw new Error("Failed to load test keystore");
@@ -153,7 +138,6 @@ describe("RLN Proof Integration Tests", function () {
153138
const merkleRoot = await contract.getMerkleRoot();
154139
const rateCommitment = calculateRateCommitment(idCommitment, rateLimit);
155140

156-
// Get the array of indexes that correspond to each proof element
157141
const proofElementIndexes = extractPathDirectionsFromProof(
158142
merkleProof,
159143
rateCommitment,
@@ -163,10 +147,8 @@ describe("RLN Proof Integration Tests", function () {
163147
throw new Error("Failed to extract proof element indexes");
164148
}
165149

166-
// Verify the array has the correct length
167150
expect(proofElementIndexes).to.have.lengthOf(MERKLE_TREE_DEPTH);
168151

169-
// Verify that we can reconstruct the root using these indexes
170152
const reconstructedRoot = reconstructMerkleRoot(
171153
merkleProof as bigint[],
172154
BigInt(membershipInfo.index),
File renamed without changes.

0 commit comments

Comments
 (0)