Skip to content

Commit

Permalink
Merge pull request #201 from zama-ai/tests/parallel-signers
Browse files Browse the repository at this point in the history
tests() use signers to allow parallel execution
  • Loading branch information
immortal-tofu authored Oct 18, 2023
2 parents 057c504 + 0a8b016 commit 07f79cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
7 changes: 4 additions & 3 deletions codegen/testgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function generateTestCode(shards: OverloadShard[]): string {
import { expect } from 'chai';
import { ethers } from 'hardhat';
import { createInstances } from '../instance';
import { getSigners } from '../signers';
import { getSigners, initSigners } from '../signers';
`);

Expand All @@ -79,8 +79,8 @@ export function generateTestCode(shards: OverloadShard[]): string {
shards.forEach((os) => {
res.push(`
async function deployTfheTestFixture${os.shardNumber}(): Promise<TFHETestSuite${os.shardNumber}> {
const signers = await ethers.getSigners();
const admin = signers[0];
const signers = await getSigners();
const admin = signers.alice;
const contractFactory = await ethers.getContractFactory('TFHETestSuite${os.shardNumber}');
const contract = await contractFactory.connect(admin).deploy();
Expand All @@ -94,6 +94,7 @@ async function deployTfheTestFixture${os.shardNumber}(): Promise<TFHETestSuite${
res.push(`
describe('TFHE operations', function () {
before(async function () {
await initSigners(1);
this.signers = await getSigners();
`);
Expand Down
15 changes: 8 additions & 7 deletions test/tfheOperations/tfheOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import type { TFHETestSuite1 } from '../../types/contracts/tests/TFHETestSuite1'
import type { TFHETestSuite2 } from '../../types/contracts/tests/TFHETestSuite2';
import type { TFHETestSuite3 } from '../../types/contracts/tests/TFHETestSuite3';
import { createInstances } from '../instance';
import { getSigners } from '../signers';
import { getSigners, initSigners } from '../signers';

async function deployTfheTestFixture1(): Promise<TFHETestSuite1> {
const signers = await ethers.getSigners();
const admin = signers[0];
const signers = await getSigners();
const admin = signers.alice;

const contractFactory = await ethers.getContractFactory('TFHETestSuite1');
const contract = await contractFactory.connect(admin).deploy();
Expand All @@ -19,8 +19,8 @@ async function deployTfheTestFixture1(): Promise<TFHETestSuite1> {
}

async function deployTfheTestFixture2(): Promise<TFHETestSuite2> {
const signers = await ethers.getSigners();
const admin = signers[0];
const signers = await getSigners();
const admin = signers.alice;

const contractFactory = await ethers.getContractFactory('TFHETestSuite2');
const contract = await contractFactory.connect(admin).deploy();
Expand All @@ -30,8 +30,8 @@ async function deployTfheTestFixture2(): Promise<TFHETestSuite2> {
}

async function deployTfheTestFixture3(): Promise<TFHETestSuite3> {
const signers = await ethers.getSigners();
const admin = signers[0];
const signers = await getSigners();
const admin = signers.alice;

const contractFactory = await ethers.getContractFactory('TFHETestSuite3');
const contract = await contractFactory.connect(admin).deploy();
Expand All @@ -42,6 +42,7 @@ async function deployTfheTestFixture3(): Promise<TFHETestSuite3> {

describe('TFHE operations', function () {
before(async function () {
await initSigners(1);
this.signers = await getSigners();

const contract1 = await deployTfheTestFixture1();
Expand Down

0 comments on commit 07f79cf

Please sign in to comment.