From 9000025c5f8ef59522e396c92794cd229ffeb60e Mon Sep 17 00:00:00 2001 From: Aurora Poppyseed <30662672+poppyseedDev@users.noreply.github.com> Date: Sat, 14 Dec 2024 13:23:22 -0300 Subject: [PATCH] passes all reencryption tests --- hardhat/test/decIdentity/diploma.ts | 27 ++++++++------------------ hardhat/test/decIdentity/passportID.ts | 13 +++++++++---- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/hardhat/test/decIdentity/diploma.ts b/hardhat/test/decIdentity/diploma.ts index c17ce7d..c05cd45 100644 --- a/hardhat/test/decIdentity/diploma.ts +++ b/hardhat/test/decIdentity/diploma.ts @@ -83,17 +83,6 @@ describe("Diploma", function () { ); } - // /** - // * Helper function to setup reencryption - // */ - // async function setupReencryption(instance: FhevmInstance, signer: HardhatEthersSigner, contractAddress: string) { - // const { publicKey, privateKey } = instance.generateKeypair(); - // const eip712 = instance.createEIP712(publicKey, contractAddress); - // const signature = await signer.signTypedData(eip712.domain, { Reencrypt: eip712.types.Reencrypt }, eip712.message); - - // return { publicKey, privateKey, signature: signature.replace("0x", "") }; - // } - /** * Helper function to register identity */ @@ -184,10 +173,10 @@ describe("Diploma", function () { this.signers.alice, this.instances, degreeClaim, - this.diplomaAddress, + this.employerClaimAddress, ); - expect(reencryptedDegreeClaim).to.equal(0); + expect(reencryptedDegreeClaim).to.equal(false); }); it("should generate both degree and adult claims", async function () { @@ -228,18 +217,18 @@ describe("Diploma", function () { this.signers.alice, this.instances, degreeClaim, - this.diplomaAddress, + this.employerClaimAddress, ); const reencryptedAdultClaim = await reencryptEbool( this.signers.alice, this.instances, adultClaim, - this.diplomaAddress, + this.employerClaimAddress, ); - expect(reencryptedDegreeClaim).to.equal(1); - expect(reencryptedAdultClaim).to.equal(1); + expect(reencryptedDegreeClaim).to.equal(true); + expect(reencryptedAdultClaim).to.equal(true); await employerClaim.verifyClaims(userId, latestAdultClaimUserId, latestDegreeClaimUserId); const verifyResult = await employerClaim.getVerifyClaim(userId); @@ -248,10 +237,10 @@ describe("Diploma", function () { this.signers.alice, this.instances, verifyResult, - this.diplomaAddress, + this.employerClaimAddress, ); - expect(reencryptedVerifyResult).to.equal(1); + expect(reencryptedVerifyResult).to.equal(true); }); it("should not allow generating claims without a registered ID", async function () { diff --git a/hardhat/test/decIdentity/passportID.ts b/hardhat/test/decIdentity/passportID.ts index 06fed9f..3300c20 100644 --- a/hardhat/test/decIdentity/passportID.ts +++ b/hardhat/test/decIdentity/passportID.ts @@ -98,7 +98,7 @@ describe("PassportID", function () { }); // Test case: Retrieve the registered identity - it.only("should retrieve the registered identity", async function () { + it("should retrieve the registered identity", async function () { await idMapping.connect(this.signers.alice).generateId(); const userId = await idMapping.getId(this.signers.alice); @@ -110,7 +110,7 @@ describe("PassportID", function () { this.signers.alice, this.instances, firstnameHandleAlice, - this.diplomaAddress, + this.passportIDAddress, ); expect(reencryptedFirstname).to.equal(8); @@ -131,9 +131,14 @@ describe("PassportID", function () { const latestClaimUserId = await employerClaim.lastClaimId(); const adultsClaim = await employerClaim.getAdultClaim(latestClaimUserId); - const reencrypted = await reencryptEbool(this.signers.bob, this.instances, adultsClaim, this.diplomaAddress); + const reencrypted = await reencryptEbool( + this.signers.alice, + this.instances, + adultsClaim, + this.employerClaimAddress, + ); - expect(reencrypted).to.equal(1); + expect(reencrypted).to.equal(true); }); // Test case: Should fail verification with invalid claim IDs