Skip to content
Merged
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type AztecNode, BatchCall, Fr, type Logger, type Wallet } from '@aztec/aztec.js';
import { DocsExampleContract } from '@aztec/noir-contracts.js/DocsExample';
import { StatefulTestContract } from '@aztec/noir-contracts.js/StatefulTest';
import { TestContract } from '@aztec/noir-contracts.js/Test';
import { siloNullifier } from '@aztec/stdlib/hash';
Expand All @@ -18,9 +19,10 @@ describe('e2e_deploy_contract private initialization', () => {

afterAll(() => t.teardown());

// Tests calling a private function in an uninitialized and undeployed contract. Note that
// it still requires registering the contract artifact and instance locally in the pxe.
it('executes a function in an undeployed contract from an account contract', async () => {
// Tests calling a private function in an uninitialized and undeployed contract.
// Requires registering the contract artifact and instance locally in the pxe.
// The function has a noinitcheck flag so it can be called without initialization.
it('executes a noinitcheck function in an uninitialized contract', async () => {
const contract = await t.registerContract(wallet, TestContract);
const receipt = await contract.methods.emit_nullifier(10).send().wait();
const txEffects = await aztecNode.getTxEffect(receipt.txHash);
Expand All @@ -29,6 +31,16 @@ describe('e2e_deploy_contract private initialization', () => {
expect(txEffects!.data.nullifiers).toContainEqual(expected);
});

// Tests calling a private function in an uninitialized and undeployed contract.
// Requires registering the contract artifact and instance locally in the pxe.
// This contract does not have a constructor, so the fn does not need the noinitcheck flag.
it('executes a function in a contract without initializer', async () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would update this comment with information that this test also relies on the contract not having an initializer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bigger issue is to abuse DocsExample in this way - we should have contracts with specific properties that we want to test.

Copy link
Copy Markdown
Contributor

@benesjan benesjan Apr 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I am already working on tests today I could do that change and clean up use of Test and DocsExample contracts.

const contract = await t.registerContract(wallet, DocsExampleContract);
await expect(contract.methods.is_legendary_initialized().simulate()).resolves.toEqual(false);
await contract.methods.initialize_private(0, 1).send().wait();
await expect(contract.methods.is_legendary_initialized().simulate()).resolves.toEqual(true);
});

// Tests privately initializing an undeployed contract. Also requires pxe registration in advance.
it('privately initializes an undeployed contract from an account contract', async () => {
const owner = await t.registerRandomAccount();
Expand Down