Skip to content

Commit

Permalink
feat: updated ethermint and added CI
Browse files Browse the repository at this point in the history
fix: typo workflows
  • Loading branch information
jatZama committed Mar 6, 2024
1 parent fe0f841 commit 5a65a2a
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 29 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Pull request tests

on:
pull_request:
branches:
- main

jobs:
build:
runs-on: large_ubuntu_16
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: cp .env.example .env
- run: npm ci
- run: npm run prettier:check
- name: "npm CI test"
run: |
# sometimes not created and is not tailed
touch fhevm.log
npm run fhevm:start &> fhevm.log &
tail -f fhevm.log | sed '/Starting JSON WebSocket server/ q'
npm run test
npm run fhevm:stop || true
25 changes: 25 additions & 0 deletions .github/workflows/testmock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Pull request tests with mocks

on:
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: cp .env.example .env
- run: npm ci
- name: "npm CI test"
run: |
# sometimes not created and is not tailed
npm run test:mock
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"ethers": "^6.8.0",
"fhevm": "0.4.0-0",
"fhevmjs": "^0.4.0-4",
"fhevm": "0.4.0-2",
"fhevmjs": "^0.4.0-6",
"fs-extra": "^10.1.0",
"hardhat": "^2.19.4",
"hardhat-deploy": "^0.11.29",
Expand Down Expand Up @@ -84,7 +84,7 @@
"task:mint": "hardhat task:mint",
"task:deployERC20": "hardhat task:deployERC20",
"task:accounts": "hardhat task:accounts",
"fhevm:start": "docker run -i -p 8545:8545 -p 8546:8546 --rm --name fhevm ghcr.io/zama-ai/ethermint-dev-node:v0.3.0-0",
"fhevm:start": "docker run -i -p 8545:8545 -p 8546:8546 --rm --name fhevm ghcr.io/zama-ai/ethermint-dev-node:v0.3.0-5",
"fhevm:stop": "docker rm -f fhevm",
"fhevm:restart": "fhevm:stop && fhevm:start",
"fhevm:faucet": "npm run fhevm:faucet:alice && sleep 5 && npm run fhevm:faucet:bob && sleep 5 && npm run fhevm:faucet:carol && sleep 5 && npm run fhevm:faucet:dave && sleep 5 && npm run fhevm:faucet:eve",
Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions test/dao/GovernorZama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { deployGovernorZamaFixture, deployTimelockFixture } from "./GovernorZama

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

Expand Down Expand Up @@ -88,14 +88,14 @@ describe("GovernorZama", function () {
}
await waitForBlock(proposals.startBlock + 1n);
// Cast some votes
const encryptedSupportBob = this.instances.bob.encrypt8(1);
const encryptedSupportBob = this.instances.bob.encryptBool(true);
const txVoteBob = await createTransaction(
this.governor.connect(this.signers.bob)["castVote(uint256,bytes)"],
proposalId,
encryptedSupportBob,
);

const encryptedSupportCarol = this.instances.carol.encrypt8(1);
const encryptedSupportCarol = this.instances.carol.encryptBool(true);
const txVoteCarol = await createTransaction(
this.governor.connect(this.signers.carol)["castVote(uint256,bytes)"],
proposalId,
Expand Down Expand Up @@ -135,14 +135,14 @@ describe("GovernorZama", function () {
await waitForBlock(proposals.startBlock + 1n);

// Cast some votes
const encryptedSupportBob = this.instances.bob.encrypt8(0);
const encryptedSupportBob = this.instances.bob.encryptBool(false);
const txVoteBob = await createTransaction(
this.governor.connect(this.signers.bob)["castVote(uint256,bytes)"],
proposalId,
encryptedSupportBob,
);

const encryptedSupportCarol = this.instances.carol.encrypt8(0);
const encryptedSupportCarol = this.instances.carol.encryptBool(true);
const txVoteCarol = await createTransaction(
this.governor.connect(this.signers.carol)["castVote(uint256,bytes)"],
proposalId,
Expand Down
4 changes: 3 additions & 1 deletion test/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export const createInstance = async (contractAddress: string, account: Signer, e
const instance = await fhevmjs.createInstance({ chainId, publicKey });

if (HARDHAT_NETWORK === "hardhat") {
instance.encryptBool = createUintToUint8ArrayFunction(1);
instance.encrypt4 = createUintToUint8ArrayFunction(4);
instance.encrypt8 = createUintToUint8ArrayFunction(8);
instance.encrypt16 = createUintToUint8ArrayFunction(16);
instance.encrypt32 = createUintToUint8ArrayFunction(32);
Expand Down Expand Up @@ -81,7 +83,7 @@ const generatePublicKey = async (contractAddress: string, signer: Signer, instan

function createUintToUint8ArrayFunction(numBits: number) {
const numBytes = Math.ceil(numBits / 8);
return function (uint: number | bigint) {
return function (uint: number | bigint | boolean) {
const buffer = toBufferBE(BigInt(uint), numBytes);
return buffer;
};
Expand Down
12 changes: 0 additions & 12 deletions test/types.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
import type { FhevmInstance } from "fhevmjs";

import { EncryptedERC20 } from "../types";
import type { Signers } from "./signers";

declare module "mocha" {
export interface Context {
signers: Signers;
contractAddress: string;
instances: FhevmInstances;
erc20: EncryptedERC20;
}
}

export interface FhevmInstances {
alice: FhevmInstance;
bob: FhevmInstance;
Expand Down

0 comments on commit 5a65a2a

Please sign in to comment.