From 9ebef6e04d8ddd25649a325f5b3692b42699629e Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Wed, 4 Oct 2023 14:43:23 +0200 Subject: [PATCH] test: check that portal address is saved (#2641) This PR adds a test for a change made in https://github.com/AztecProtocol/aztec-packages/pull/2549/commits/64d5e877c95300a2f0e5d619724801377074d61c to check that after a contract is deployed with a portal contract address the portal is saved both in `ContractData` and `ExtendedContractData` by the Archiver. # Checklist: Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge. - [ ] If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag. - [x] I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code. - [x] Every change is related to the PR description. - [ ] I have [linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) this pull request to relevant issues (if any exist). --- .../src/e2e_deploy_contract.test.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts index b1b4196fbe8..f23e0cf52de 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts @@ -1,4 +1,4 @@ -import { AztecAddress, Contract, ContractDeployer, Fr, Wallet, isContractDeployed } from '@aztec/aztec.js'; +import { AztecAddress, Contract, ContractDeployer, EthAddress, Fr, Wallet, isContractDeployed } from '@aztec/aztec.js'; import { CompleteAddress, getContractDeploymentInfo } from '@aztec/circuits.js'; import { DebugLogger } from '@aztec/foundation/log'; import { TestContractAbi } from '@aztec/noir-contracts/artifacts'; @@ -111,4 +111,21 @@ describe('e2e_deploy_contract', () => { ); } }, 30_000); + + it('should deploy a contract connected to a portal contract', async () => { + const deployer = new ContractDeployer(TestContractAbi, wallet); + const portalContract = EthAddress.random(); + + const txReceipt = await deployer.deploy().send({ portalContract }).wait(); + + expect(txReceipt.status).toBe(TxStatus.MINED); + const contractAddress = txReceipt.contractAddress!; + + expect((await pxe.getContractData(contractAddress))?.portalContractAddress.toString()).toEqual( + portalContract.toString(), + ); + expect((await pxe.getExtendedContractData(contractAddress))?.contractData.portalContractAddress.toString()).toEqual( + portalContract.toString(), + ); + }); });