-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(tests): Add counter and private voting tests (#4592)
The Counter contract and the EasyPrivateVoting contracts did not have e2e tests. Now they do. closes #4585 --------- Co-authored-by: Rahul Kothari <[email protected]>
- Loading branch information
1 parent
730e73a
commit d3be5cc
Showing
3 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
beforeAll(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}`); | ||
}, 25_000); | ||
|
||
afterAll(() => teardown()); | ||
|
||
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
41
yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
beforeAll(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}`); | ||
}, 25_000); | ||
|
||
afterAll(() => teardown()); | ||
|
||
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); | ||
}); | ||
}); | ||
}); |