Skip to content

Commit

Permalink
Merge pull request #188 from zama-ai/feat/improve-faucet
Browse files Browse the repository at this point in the history
Feat/improve faucet
  • Loading branch information
immortal-tofu authored Oct 2, 2023
2 parents 62e0c31 + 311812f commit 6c88c74
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 18 deletions.
4 changes: 2 additions & 2 deletions test/blindAuction/BlindAuction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { ethers } from 'hardhat';

import { deployEncryptedERC20Fixture } from '../encryptedERC20/EncryptedERC20.fixture';
import { createInstances } from '../instance';
import { faucetSigners, getSigners } from '../signers';
import { getSigners, initSigners } from '../signers';
import { deployBlindAuctionFixture } from './BlindAuction.fixture';

describe('BlindAuction', function () {
before(async function () {
await faucetSigners(3);
await initSigners(3);
this.signers = await getSigners();
});

Expand Down
4 changes: 2 additions & 2 deletions test/encryptedERC20/EncryptedERC20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { expect } from 'chai';
import { ethers } from 'hardhat';

import { createInstances } from '../instance';
import { faucetSigners, getSigners } from '../signers';
import { getSigners, initSigners } from '../signers';
import { deployEncryptedERC20Fixture } from './EncryptedERC20.fixture';

describe('EncryptedERC20', function () {
before(async function () {
await faucetSigners(2);
await initSigners(2);
this.signers = await getSigners();
});

Expand Down
4 changes: 2 additions & 2 deletions test/governor/Comp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { expect } from 'chai';
import { ethers } from 'hardhat';

import { createInstances } from '../instance';
import { faucetSigners, getSigners } from '../signers';
import { getSigners, initSigners } from '../signers';
import { deployCompFixture } from './Comp.fixture';

describe('Comp', function () {
before(async function () {
await faucetSigners(2);
await initSigners(2);
this.signers = await getSigners();
});

Expand Down
4 changes: 2 additions & 2 deletions test/governor/GovernorZama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { expect } from 'chai';
import { ethers } from 'hardhat';

import { createInstances } from '../instance';
import { faucetSigners, getSigners } from '../signers';
import { getSigners, initSigners } from '../signers';
import { createTransaction, waitForBlock } from '../utils';
import { deployCompFixture } from './Comp.fixture';
import { deployGovernorZamaFixture, deployTimelockFixture } from './GovernorZama.fixture';

describe('GovernorZama', function () {
before(async function () {
await faucetSigners(3);
await initSigners(3);
this.signers = await getSigners();
this.comp = await deployCompFixture();

Expand Down
4 changes: 2 additions & 2 deletions test/rand/Rand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { expect } from 'chai';
import { ethers } from 'hardhat';

import { createInstances } from '../instance';
import { faucetSigners, getSigners } from '../signers';
import { getSigners, initSigners } from '../signers';
import { deployRandFixture } from './Rand.fixture';

describe('Rand', function () {
before(async function () {
await faucetSigners(1);
await initSigners(1);
this.signers = await getSigners();
});

Expand Down
10 changes: 6 additions & 4 deletions test/signers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers';
import { exec as oldExec } from 'child_process';
import { HDNodeWallet } from 'ethers';
import { ethers } from 'hardhat';
import { config, ethers } from 'hardhat';
import { promisify } from 'util';

import { waitForBalance } from './utils';
Expand Down Expand Up @@ -32,23 +32,25 @@ const faucet = async (address: string) => {
await waitForBalance(address);
};

export const faucetSigners = async (quantity: number): Promise<void> => {
export const initSigners = async (quantity: number): Promise<void> => {
if (!signers) {
if (process.env.HARDHAT_PARALLEL) {
if (process.env.HARDHAT_PARALLEL && config.defaultNetwork === 'local') {
signers = {
alice: ethers.Wallet.createRandom().connect(ethers.provider),
bob: ethers.Wallet.createRandom().connect(ethers.provider),
dave: ethers.Wallet.createRandom().connect(ethers.provider),
carol: ethers.Wallet.createRandom().connect(ethers.provider),
};
} else {
} else if (!process.env.HARDHAT_PARALLEL) {
const eSigners = await ethers.getSigners();
signers = {
alice: eSigners[0],
bob: eSigners[1],
carol: eSigners[2],
dave: eSigners[3],
};
} else {
throw new Error("Can't run parallel mode if network is not 'local'");
}

const q = Math.min(quantity, 4);
Expand Down
4 changes: 2 additions & 2 deletions test/tfheOperations/manual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ethers } from 'hardhat';

import type { TFHEManualTestSuite } from '../../types/contracts/tests/TFHEManualTestSuite';
import { createInstances } from '../instance';
import { faucetSigners, getSigners } from '../signers';
import { getSigners, initSigners } from '../signers';

async function deployTfheManualTestFixture(): Promise<TFHEManualTestSuite> {
const signers = await getSigners();
Expand All @@ -18,7 +18,7 @@ async function deployTfheManualTestFixture(): Promise<TFHEManualTestSuite> {

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

const contract = await deployTfheManualTestFixture();
Expand Down
4 changes: 2 additions & 2 deletions test/tfheOperations/tfheOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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 { faucetSigners, getSigners } from '../signers';
import { getSigners, initSigners } from '../signers';

async function deployTfheTestFixture1(): Promise<TFHETestSuite1> {
const signers = await getSigners();
Expand Down Expand Up @@ -42,7 +42,7 @@ async function deployTfheTestFixture3(): Promise<TFHETestSuite3> {

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

const contract1 = await deployTfheTestFixture1();
Expand Down

0 comments on commit 6c88c74

Please sign in to comment.