From bbe6a41a7ddbff121fc86b0e3e1f7876a1ffc9b2 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Tue, 13 Feb 2024 14:22:38 -0500 Subject: [PATCH 1/7] add tests --- .../src/e2e_counter_contract.test.ts | 39 ++++++++++++++++++ .../src/e2e_private_voting_contract.test.ts | 41 +++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 yarn-project/end-to-end/src/e2e_counter_contract.test.ts create mode 100644 yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts diff --git a/yarn-project/end-to-end/src/e2e_counter_contract.test.ts b/yarn-project/end-to-end/src/e2e_counter_contract.test.ts new file mode 100644 index 00000000000..7e4c64fa4a5 --- /dev/null +++ b/yarn-project/end-to-end/src/e2e_counter_contract.test.ts @@ -0,0 +1,39 @@ +import { AccountWallet, AztecAddress, CompleteAddress, DebugLogger, Fr, TxStatus } from '@aztec/aztec.js'; +import { CounterContract } from '@aztec/noir-contracts.js/Counter'; + +import { setup } from './fixtures/utils.js'; + +describe('e2e_counter_contract', () => { + // let pxe: PXE; + let wallet: AccountWallet; + let accounts: CompleteAddress[]; + let logger: DebugLogger; + let teardown: () => Promise; + + let counterContract: CounterContract; + let owner: AztecAddress; + + beforeEach(async () => { + // Setup environment + ({ + teardown, + // pxe, + accounts, + wallets: [wallet], + logger, + } = await setup(1)); + owner = accounts[0].address; + + counterContract = await CounterContract.deploy(wallet, 0, owner).send().deployed(); + + logger(`Counter contract deployed at ${counterContract.address}`); + }, 100_000); + + afterEach(() => teardown(), 30_000); + + describe('increments', async () => { + const receipt = await counterContract.methods.increment(owner).send().wait(); + expect(receipt.status).toBe(TxStatus.MINED); + expect(await counterContract.methods.get_counter(owner).view()).toBe(1n); + }); +}); diff --git a/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts b/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts new file mode 100644 index 00000000000..b004877645a --- /dev/null +++ b/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts @@ -0,0 +1,41 @@ +import { AccountWallet, AztecAddress, CompleteAddress, DebugLogger, Fr, TxStatus } from '@aztec/aztec.js'; +import { EasyPrivateVotingContract } from '@aztec/noir-contracts.js/EasyPrivateVoting'; + +import { setup } from './fixtures/utils.js'; + +describe('e2e_voting_contract', () => { + // let pxe: PXE; + let wallet: AccountWallet; + let accounts: CompleteAddress[]; + let logger: DebugLogger; + let teardown: () => Promise; + + let votingContract: EasyPrivateVotingContract; + let owner: AztecAddress; + + beforeEach(async () => { + // Setup environment + ({ + teardown, + // pxe, + accounts, + wallets: [wallet], + logger, + } = await setup(1)); + owner = accounts[0].address; + + votingContract = await EasyPrivateVotingContract.deploy(wallet, owner).send().deployed(); + + logger(`Counter contract deployed at ${votingContract.address}`); + }, 100_000); + + afterEach(() => teardown(), 30_000); + + describe('it votes', async () => { + const candidate = new Fr(1); + const tx = await votingContract.methods.cast_vote(candidate).send(); + const receipt = await tx.wait(); + expect(receipt.status).toBe(TxStatus.MINED); + expect(await votingContract.methods.get_vote(candidate).view()).toBe(1n); + }); +}); From ed3eafd794396debe85632ab1044d3a6af52ede8 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Tue, 13 Feb 2024 14:27:49 -0500 Subject: [PATCH 2/7] rm unused code --- yarn-project/end-to-end/src/e2e_counter_contract.test.ts | 4 +--- .../end-to-end/src/e2e_private_voting_contract.test.ts | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_counter_contract.test.ts b/yarn-project/end-to-end/src/e2e_counter_contract.test.ts index 7e4c64fa4a5..7d2a170b137 100644 --- a/yarn-project/end-to-end/src/e2e_counter_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_counter_contract.test.ts @@ -1,10 +1,9 @@ -import { AccountWallet, AztecAddress, CompleteAddress, DebugLogger, Fr, TxStatus } from '@aztec/aztec.js'; +import { AccountWallet, AztecAddress, CompleteAddress, DebugLogger, TxStatus } from '@aztec/aztec.js'; import { CounterContract } from '@aztec/noir-contracts.js/Counter'; import { setup } from './fixtures/utils.js'; describe('e2e_counter_contract', () => { - // let pxe: PXE; let wallet: AccountWallet; let accounts: CompleteAddress[]; let logger: DebugLogger; @@ -17,7 +16,6 @@ describe('e2e_counter_contract', () => { // Setup environment ({ teardown, - // pxe, accounts, wallets: [wallet], logger, diff --git a/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts b/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts index b004877645a..17c2caf690b 100644 --- a/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts @@ -4,7 +4,6 @@ import { EasyPrivateVotingContract } from '@aztec/noir-contracts.js/EasyPrivateV import { setup } from './fixtures/utils.js'; describe('e2e_voting_contract', () => { - // let pxe: PXE; let wallet: AccountWallet; let accounts: CompleteAddress[]; let logger: DebugLogger; @@ -17,7 +16,6 @@ describe('e2e_voting_contract', () => { // Setup environment ({ teardown, - // pxe, accounts, wallets: [wallet], logger, From 10a2a3d5fa51db5f86bd3d142c9f9b4787d6e088 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Tue, 13 Feb 2024 14:36:43 -0500 Subject: [PATCH 3/7] fmt --- yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts b/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts index 17c2caf690b..44b65e183f6 100644 --- a/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts @@ -31,7 +31,7 @@ describe('e2e_voting_contract', () => { describe('it votes', async () => { const candidate = new Fr(1); - const tx = await votingContract.methods.cast_vote(candidate).send(); + const tx = votingContract.methods.cast_vote(candidate).send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); expect(await votingContract.methods.get_vote(candidate).view()).toBe(1n); From c31616ab43b6714711b224072cabd3b9d991e847 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Tue, 13 Feb 2024 14:52:41 -0500 Subject: [PATCH 4/7] add tests to ci --- .circleci/config.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9e8f705c529..4cf60ce2794 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -554,6 +554,28 @@ jobs: name: "Test" command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=e2e_note_getter.test.ts + e2e-counter: + docker: + - image: aztecprotocol/alpine-build-image + resource_class: small + steps: + - *checkout + - *setup_env + - run: + name: "Test" + command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=e2e_counter_contract.test.ts + + e2e-private-voting: + docker: + - image: aztecprotocol/alpine-build-image + resource_class: small + steps: + - *checkout + - *setup_env + - run: + name: "Test" + command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=e2e_private_voting_contract.test.ts + e2e-multiple-accounts-1-enc-key: docker: - image: aztecprotocol/alpine-build-image From aab70b3fe027a367d1519fc94bc06a6616b39dbe Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Tue, 13 Feb 2024 15:41:43 -0500 Subject: [PATCH 5/7] add tests to e2e --- .circleci/config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4cf60ce2794..d0f6a6629be 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1319,6 +1319,8 @@ workflows: - e2e-inclusion-proofs-contract: *e2e_test - e2e-pending-commitments-contract: *e2e_test - e2e-ordering: *e2e_test + - e2e-counter: *e2e_test + - e2e-private-voting: *e2e_test - uniswap-trade-on-l1-from-l2: *e2e_test - integration-l1-publisher: *e2e_test - integration-archiver-l1-to-l2: *e2e_test @@ -1358,6 +1360,8 @@ workflows: - e2e-inclusion-proofs-contract - e2e-pending-commitments-contract - e2e-ordering + - e2e-counter + - e2e-private-voting - uniswap-trade-on-l1-from-l2 - integration-l1-publisher - integration-archiver-l1-to-l2 From 637d72cc4efd128d5308ef2e4d06a1788f9c003a Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Tue, 13 Feb 2024 15:47:54 -0500 Subject: [PATCH 6/7] fix test structure --- .../end-to-end/src/e2e_counter_contract.test.ts | 10 ++++++---- .../src/e2e_private_voting_contract.test.ts | 14 ++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_counter_contract.test.ts b/yarn-project/end-to-end/src/e2e_counter_contract.test.ts index 7d2a170b137..96ffae2e3eb 100644 --- a/yarn-project/end-to-end/src/e2e_counter_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_counter_contract.test.ts @@ -29,9 +29,11 @@ describe('e2e_counter_contract', () => { afterEach(() => teardown(), 30_000); - describe('increments', async () => { - const receipt = await counterContract.methods.increment(owner).send().wait(); - expect(receipt.status).toBe(TxStatus.MINED); - expect(await counterContract.methods.get_counter(owner).view()).toBe(1n); + describe('increments', () => { + it('counts', async () => { + const receipt = await counterContract.methods.increment(owner).send().wait(); + expect(receipt.status).toBe(TxStatus.MINED); + expect(await counterContract.methods.get_counter(owner).view()).toBe(1n); + }); }); }); diff --git a/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts b/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts index 44b65e183f6..6353c83c846 100644 --- a/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts @@ -29,11 +29,13 @@ describe('e2e_voting_contract', () => { afterEach(() => teardown(), 30_000); - describe('it votes', async () => { - const candidate = new Fr(1); - const tx = votingContract.methods.cast_vote(candidate).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); - expect(await votingContract.methods.get_vote(candidate).view()).toBe(1n); + describe('votes', () => { + it('votes', async () => { + const candidate = new Fr(1); + const tx = votingContract.methods.cast_vote(candidate).send(); + const receipt = await tx.wait(); + expect(receipt.status).toBe(TxStatus.MINED); + expect(await votingContract.methods.get_vote(candidate).view()).toBe(1n); + }); }); }); From 7b40cce346cc885efd522884d32614978c835e61 Mon Sep 17 00:00:00 2001 From: Rahul Kothari Date: Wed, 14 Feb 2024 11:43:54 +0000 Subject: [PATCH 7/7] nits' --- yarn-project/end-to-end/src/e2e_counter_contract.test.ts | 6 +++--- .../end-to-end/src/e2e_private_voting_contract.test.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_counter_contract.test.ts b/yarn-project/end-to-end/src/e2e_counter_contract.test.ts index 96ffae2e3eb..f47c6ba8d20 100644 --- a/yarn-project/end-to-end/src/e2e_counter_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_counter_contract.test.ts @@ -12,7 +12,7 @@ describe('e2e_counter_contract', () => { let counterContract: CounterContract; let owner: AztecAddress; - beforeEach(async () => { + beforeAll(async () => { // Setup environment ({ teardown, @@ -25,9 +25,9 @@ describe('e2e_counter_contract', () => { counterContract = await CounterContract.deploy(wallet, 0, owner).send().deployed(); logger(`Counter contract deployed at ${counterContract.address}`); - }, 100_000); + }, 25_000); - afterEach(() => teardown(), 30_000); + afterAll(() => teardown()); describe('increments', () => { it('counts', async () => { diff --git a/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts b/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts index 6353c83c846..e76bd607092 100644 --- a/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts @@ -12,7 +12,7 @@ describe('e2e_voting_contract', () => { let votingContract: EasyPrivateVotingContract; let owner: AztecAddress; - beforeEach(async () => { + beforeAll(async () => { // Setup environment ({ teardown, @@ -25,9 +25,9 @@ describe('e2e_voting_contract', () => { votingContract = await EasyPrivateVotingContract.deploy(wallet, owner).send().deployed(); logger(`Counter contract deployed at ${votingContract.address}`); - }, 100_000); + }, 25_000); - afterEach(() => teardown(), 30_000); + afterAll(() => teardown()); describe('votes', () => { it('votes', async () => {