diff --git a/.github/scripts/update-readme-version.js b/.github/scripts/update-readme-version.js index 851ade53..423f26a9 100755 --- a/.github/scripts/update-readme-version.js +++ b/.github/scripts/update-readme-version.js @@ -1,6 +1,4 @@ import { readFileSync, writeFileSync } from 'fs'; -import { dirname } from 'path'; -import { fileURLToPath } from 'url'; // Read Nargo.toml const nargoContent = readFileSync('Nargo.toml', 'utf8'); @@ -24,4 +22,4 @@ const updatedContent = readmeContent.replace( // Write back to README writeFileSync(readmePath, updatedContent); -console.log(`Updated README.md with version ${version}`); \ No newline at end of file +console.log(`Updated README.md with version ${version}`); diff --git a/README.md b/README.md index e9bda61e..cda819d9 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This repo is meant to be a starting point for writing Aztec contracts and tests on the Aztec sandbox (local development environment). -You can find the **Easy Private Voting contract** in `./src/main.nr`. A simple integration test is in `./src/test/index.test.ts`. +You can find the **Easy Private Voting contract** in `./src/main.nr`. A simple integration test is in `./src/test/e2e/index.test.ts`. The corresponding tutorial can be found in the [Aztec docs here](https://docs.aztec.network/developers/tutorials/codealong/contract_tutorials/private_voting_contract). @@ -121,7 +121,7 @@ Then test with: yarn test ``` -Testing will run the **TypeScript tests** defined in `index.test.ts` inside `./src/test`, as well as the [Aztec Testing eXecution Environment (TXE)](https://docs.aztec.network/developers/guides/smart_contracts/testing) tests defined in [`first.nr`](./src/test/first.nr) (imported in the contract file with `mod test;`). +Testing will run the **TypeScript tests** defined in `index.test.ts` inside `./src/test/e2e`, as well as the [Aztec Testing eXecution Environment (TXE)](https://docs.aztec.network/developers/guides/smart_contracts/testing) tests defined in [`first.nr`](./src/test/first.nr) (imported in the contract file with `mod test;`). Note: The Typescript tests spawn an instance of the sandbox to test against, and close it once the TS tests are complete. @@ -131,8 +131,8 @@ Note: The Typescript tests spawn an instance of the sandbox to test against, and You can find a handful of scripts in the `./scripts` folder. -- `./scripts/deploy-accounts.ts` is an example of how to deploy a schnorr account. -- `./scripts/deploy.ts` is an example of how to deploy a contract. +- `./scripts/deploy_account.ts` is an example of how to deploy a schnorr account. +- `./scripts/deploy_contract.ts` is an example of how to deploy a contract. - `./scripts/fees.ts` is an example of how to pay for a contract deployment using various fee payment methods. - `./scripts/multiple_pxe.ts` is an example of how to deploy a contract from one PXE instance and interact with it from another. - `./scripts/profile_deploy.ts` shows how to profile a transaction and print the results. @@ -158,7 +158,7 @@ yarn update You may need to update permissions with: ```bash -chmod +x update_contract.sh +chmod +x .github/scripts/update_contract.sh ``` ### 💬 Join the Community: diff --git a/scripts/fees.ts b/scripts/fees.ts index 540d86fe..6832bc28 100644 --- a/scripts/fees.ts +++ b/scripts/fees.ts @@ -62,9 +62,9 @@ async function main() { logger.info(`Fee Juice minted to ${feeJuiceRecipient} on L2.`) // set up sponsored fee payments - const sponseredFPC = await getSponsoredFPCInstance(); - await pxe.registerContract({ instance: sponseredFPC, artifact: SponsoredFPCContract.artifact }); - const paymentMethod = new SponsoredFeePaymentMethod(sponseredFPC.address); + const sponsoredFPC = await getSponsoredFPCInstance(); + await pxe.registerContract({ instance: sponsoredFPC, artifact: SponsoredFPCContract.artifact }); + const paymentMethod = new SponsoredFeePaymentMethod(sponsoredFPC.address); // Two arbitrary txs to make the L1 message available on L2 const votingContract = await EasyPrivateVotingContract.deploy(wallet1, wallet1.getAddress()).send({ fee: { paymentMethod } }).deployed(); @@ -120,8 +120,8 @@ async function main() { // Sponsored Fee Payment // This method will only work in environments where there is a sponsored fee contract deployed - const deployedSponseredFPC = await getDeployedSponsoredFPCAddress(pxe); - const sponsoredPaymentMethod = new SponsoredFeePaymentMethod(deployedSponseredFPC); + const deployedSponsoredFPC = await getDeployedSponsoredFPCAddress(pxe); + const sponsoredPaymentMethod = new SponsoredFeePaymentMethod(deployedSponsoredFPC); await bananaCoin.withWallet(wallet2).methods.transfer_in_private(wallet2.getAddress(), wallet1.getAddress(), 10, 0).send({ fee: { paymentMethod: sponsoredPaymentMethod } }).wait() logger.info(`Transfer paid with fees from Sponsored FPC.`) } diff --git a/scripts/multiple_pxe.ts b/scripts/multiple_pxe.ts index 0b5cbbae..26348f1f 100644 --- a/scripts/multiple_pxe.ts +++ b/scripts/multiple_pxe.ts @@ -58,10 +58,10 @@ async function main() { const pxe1 = await setupPxe1(); const pxe2 = await setupPxe2(); - const sponseredFPC = await getSponsoredFPCInstance(); - await pxe1.registerContract({ instance: sponseredFPC, artifact: SponsoredFPCContract.artifact }); - await pxe2.registerContract({ instance: sponseredFPC, artifact: SponsoredFPCContract.artifact }); - const paymentMethod = new SponsoredFeePaymentMethod(sponseredFPC.address); + const sponsoredFPC = await getSponsoredFPCInstance(); + await pxe1.registerContract({ instance: sponsoredFPC, artifact: SponsoredFPCContract.artifact }); + await pxe2.registerContract({ instance: sponsoredFPC, artifact: SponsoredFPCContract.artifact }); + const paymentMethod = new SponsoredFeePaymentMethod(sponsoredFPC.address); // deploy token contract let secretKey = Fr.random(); @@ -74,7 +74,7 @@ async function main() { // setup account on 2nd pxe - pxe2.registerSender(ownerAddress) + await pxe2.registerSender(ownerAddress) let secretKey2 = Fr.random(); let salt2 = Fr.random(); @@ -83,7 +83,7 @@ async function main() { // deploy account on 2nd pxe let tx2 = await schnorrAccount2.deploy({ fee: { paymentMethod } }).wait(); let wallet2 = await schnorrAccount2.getWallet(); - wallet2.registerSender(ownerAddress) + await wallet2.registerSender(ownerAddress) // mint to account on 2nd pxe diff --git a/src/test/e2e/accounts.test.ts b/src/test/e2e/accounts.test.ts index bffa357f..bd00ff3b 100644 --- a/src/test/e2e/accounts.test.ts +++ b/src/test/e2e/accounts.test.ts @@ -122,7 +122,18 @@ describe("Accounts", () => { }); it("Deploys first unfunded account from first funded account", async () => { - const tx_acc = await randomAccountManagers[0].deploy({ fee: { paymentMethod: sponsoredPaymentMethod }, deployWallet: ownerWallet }).wait(); + const receipt = await randomAccountManagers[0] + .deploy({ fee: { paymentMethod: sponsoredPaymentMethod }, deployWallet: ownerWallet }) + .wait(); + + expect(receipt).toEqual( + expect.objectContaining({ + status: TxStatus.SUCCESS, + }), + ); + + const deployedWallet = await randomAccountManagers[0].getWallet(); + expect(deployedWallet.getAddress()).toEqual(randomAccountManagers[0].getAddress()); }); it("Sponsored contract deployment", async () => { diff --git a/src/test/first.nr b/src/test/first.nr index 60349fba..188d5760 100644 --- a/src/test/first.nr +++ b/src/test/first.nr @@ -11,7 +11,7 @@ unconstrained fn test_initializer() { let block_number = get_block_number(); let admin_slot = EasyPrivateVoting::storage_layout().admin.slot; let admin_storage_value = storage_read(voting_contract_address, admin_slot, block_number); - assert(admin_storage_value == admin, "Vote ended should be false"); + assert(admin_storage_value == admin, "Admin address mismatch"); } #[test]