Skip to content
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

chore(tests): Add counter and private voting tests #4592

Merged
merged 7 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1297,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
Expand Down Expand Up @@ -1336,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
Expand Down
39 changes: 39 additions & 0 deletions yarn-project/end-to-end/src/e2e_counter_contract.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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 wallet: AccountWallet;
let accounts: CompleteAddress[];
let logger: DebugLogger;
let teardown: () => Promise<void>;

let counterContract: CounterContract;
let owner: AztecAddress;

beforeEach(async () => {
// Setup environment
({
teardown,
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', () => {
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);
});
});
});
41 changes: 41 additions & 0 deletions yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts
Original file line number Diff line number Diff line change
@@ -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 wallet: AccountWallet;
let accounts: CompleteAddress[];
let logger: DebugLogger;
let teardown: () => Promise<void>;

let votingContract: EasyPrivateVotingContract;
let owner: AztecAddress;

beforeEach(async () => {
// Setup environment
({
teardown,
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('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);
});
});
});
Loading