From 47883f14c7e5a2706cba21227018b12f9210c9c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crist=C3=B3v=C3=A3o=20Honorato?= Date: Tue, 4 Jun 2024 12:42:08 +0200 Subject: [PATCH] Add committeePublicKey test --- packages/evm/test/Enclave.spec.ts | 30 ++++++++++++++++++- .../MockCyphernodeRegistry.fixture.ts | 3 +- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/packages/evm/test/Enclave.spec.ts b/packages/evm/test/Enclave.spec.ts index 07d46851..c4078fe2 100644 --- a/packages/evm/test/Enclave.spec.ts +++ b/packages/evm/test/Enclave.spec.ts @@ -588,7 +588,35 @@ describe("Enclave", function () { await enclave.setCyphernodeRegistry(prevRegistry); await expect(enclave.activate(0)).to.not.be.reverted; }); - it("sets committeePublicKey correctly"); + it("sets committeePublicKey correctly", async () => { + const { + enclave, + request, + mocks: { registry }, + } = await loadFixture(setup); + + await enclave.request( + request.pool, + request.threshold, + request.duration, + request.computationModule, + request.cMParams, + request.executionModule, + request.eMParams, + { value: 10 }, + ); + + const e3Id = 0; + const publicKey = await registry.getCommitteePublicKey(e3Id); + + let e3 = await enclave.getE3(e3Id); + expect(e3.committeePublicKey).to.not.equal(publicKey); + + await enclave.activate(e3Id); + + e3 = await enclave.getE3(e3Id); + expect(e3.committeePublicKey).to.equal(publicKey); + }); it("returns true if E3 is activated successfully"); it("emits E3Activated event"); }); diff --git a/packages/evm/test/fixtures/MockCyphernodeRegistry.fixture.ts b/packages/evm/test/fixtures/MockCyphernodeRegistry.fixture.ts index 73d87fbe..99b317df 100644 --- a/packages/evm/test/fixtures/MockCyphernodeRegistry.fixture.ts +++ b/packages/evm/test/fixtures/MockCyphernodeRegistry.fixture.ts @@ -3,7 +3,8 @@ import { ethers } from "hardhat"; import { MockCyphernodeRegistry__factory } from "../../types"; export async function deployCyphernodeRegistryFixture(name?: string) { + const [signer] = await ethers.getSigners(); const deployment = await (await ethers.getContractFactory(name || "MockCyphernodeRegistry")).deploy(); - return MockCyphernodeRegistry__factory.connect(await deployment.getAddress()); + return MockCyphernodeRegistry__factory.connect(await deployment.getAddress(), signer.provider); }