-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(test-suite): implement test for paused gateway contracts #1353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5ce68e8
1a7fa23
ba35c22
fdf13ed
085ffb5
098d0a1
e181d8e
a62d990
443accd
33712b7
44b8c1f
4d5fc43
3355df6
870a177
f7cfe64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import { expect } from 'chai'; | ||
| import { ethers } from 'hardhat'; | ||
|
|
||
| import { createInstances } from '../instance'; | ||
| import { getSigners, initSigners } from '../signers'; | ||
| import { userDecryptSingleHandle } from '../utils'; | ||
|
|
||
| describe('Paused gateway', function () { | ||
| before(async function () { | ||
| await initSigners(2); | ||
| this.signers = await getSigners(); | ||
| this.instances = await createInstances(this.signers); | ||
|
|
||
| // Initialize TestInput contract. | ||
| const testInputContractFactory = await ethers.getContractFactory('TestInput'); | ||
| this.testInputContract = await testInputContractFactory.connect(this.signers.alice).deploy(); | ||
| this.testInputContractAddress = await this.testInputContract.getAddress(); | ||
| await this.testInputContract.waitForDeployment(); | ||
|
|
||
| // Initialize UserDecrypt contract. | ||
| const userDecryptContractFactory = await ethers.getContractFactory('UserDecrypt'); | ||
| this.userDecryptContract = await userDecryptContractFactory.connect(this.signers.alice).deploy(); | ||
| await this.userDecryptContract.waitForDeployment(); | ||
| this.userDecryptContractAddress = await this.userDecryptContract.getAddress(); | ||
|
|
||
| // Initialize HTTPPublicDecrypt contract. | ||
| const httpPublicDecryptContractFactory = await ethers.getContractFactory('HTTPPublicDecrypt'); | ||
| this.httpPublicDecryptContract = await httpPublicDecryptContractFactory.connect(this.signers.alice).deploy(); | ||
| await this.httpPublicDecryptContract.waitForDeployment(); | ||
| }); | ||
|
|
||
| // InputVerification tests. | ||
| it('test paused gateway user input uint64 (non-trivial)', async function () { | ||
| const inputAlice = this.instances.alice.createEncryptedInput( | ||
| this.testInputContractAddress, | ||
| this.signers.alice.address, | ||
| ); | ||
| inputAlice.add64(18446744073709550042n); | ||
|
|
||
| await expect(inputAlice.encrypt()).to.be.rejectedWith(new RegExp('Input request failed')); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is not way to make sure the revert is coming from |
||
| }); | ||
|
|
||
| // UserDecryption tests. | ||
| it('test paused gateway user decrypt', async function () { | ||
| const handle = await this.userDecryptContract.xBool(); | ||
| const { publicKey, privateKey } = this.instances.alice.generateKeypair(); | ||
| await expect( | ||
| userDecryptSingleHandle( | ||
| handle, | ||
| this.userDecryptContractAddress, | ||
| this.instances.alice, | ||
| this.signers.alice, | ||
| privateKey, | ||
| publicKey, | ||
| ), | ||
| ).to.be.rejectedWith(new RegExp('User decrypt failed')); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
| }); | ||
|
|
||
| // PublicDecryption tests. | ||
| it('test paused gateway HTTPPublicDecrypt', async function () { | ||
| const handleBool = await this.httpPublicDecryptContract.xBool(); | ||
| const handleAddress = await this.httpPublicDecryptContract.xAddress(); | ||
| const handle32 = await this.httpPublicDecryptContract.xUint32(); | ||
| await expect(this.instances.alice.publicDecrypt([handleAddress, handle32, handleBool])).to.be.rejectedWith( | ||
| new RegExp('Public decrypt failed'), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
| ); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| services: | ||
| gateway-sc-pause: | ||
| container_name: gateway-sc-pause | ||
| image: ghcr.io/zama-ai/fhevm/gateway-contracts:${GATEWAY_VERSION} | ||
| build: | ||
| context: ../../../gateway-contracts | ||
| dockerfile: Dockerfile | ||
| cache_from: | ||
| - type=gha | ||
| cache_to: | ||
| - type=gha,mode=max | ||
| env_file: | ||
| - ../env/staging/.env.gateway-sc.local | ||
| command: | ||
| - npx hardhat compile && npx hardhat task:pauseAllGatewayContracts | ||
| volumes: | ||
| - addresses-volume:/app/addresses # workdir in gateway's Dockerfile is /app | ||
|
|
||
| volumes: | ||
| addresses-volume: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| services: | ||
| gateway-sc-unpause: | ||
| container_name: gateway-sc-unpause | ||
| image: ghcr.io/zama-ai/fhevm/gateway-contracts:${GATEWAY_VERSION} | ||
| build: | ||
| context: ../../../gateway-contracts | ||
| dockerfile: Dockerfile | ||
| cache_from: | ||
| - type=gha | ||
| cache_to: | ||
| - type=gha,mode=max | ||
| env_file: | ||
| - ../env/staging/.env.gateway-sc.local | ||
| command: | ||
| - npx hardhat compile && npx hardhat task:unpauseAllGatewayContracts | ||
| volumes: | ||
| - addresses-volume:/app/addresses # workdir in gateway's Dockerfile is /app | ||
|
|
||
| volumes: | ||
| addresses-volume: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is great as it will make e2e tests much longer, maybe we could instead start with the pausing tests and then run the usual tests after unpausing the contracts ?