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: new test that you can register, deploy, and call a public function all in one tx #11045

Merged
merged 2 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
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,5 +1,13 @@
import { getDeployedTestAccountsWallets } from '@aztec/accounts/testing';
import { AztecAddress, type Logger, type PXE, type Wallet, createPXEClient, makeFetch } from '@aztec/aztec.js';
import {
AztecAddress,
BatchCall,
type Logger,
type PXE,
type Wallet,
createPXEClient,
makeFetch,
} from '@aztec/aztec.js';
import { CounterContract } from '@aztec/noir-contracts.js/Counter';
import { StatefulTestContract } from '@aztec/noir-contracts.js/StatefulTest';
import { TestContract } from '@aztec/noir-contracts.js/Test';
Expand Down Expand Up @@ -89,9 +97,22 @@ describe('e2e_deploy_contract deploy method', () => {
await expect(TestContract.deploy(wallet).prove(opts)).rejects.toThrow(/no function calls needed/i);
});

it.skip('publicly deploys and calls a public function in the same batched call', async () => {
// TODO(@spalladino): Requires being able to read a nullifier on the same tx it was emitted.
});
it('publicly deploys and calls a public contract in the same batched call', async () => {
const owner = wallet.getAddress();
// Create a contract instance and make the PXE aware of it
logger.debug(`Initializing deploy method`);
dbanks12 marked this conversation as resolved.
Show resolved Hide resolved
const deployMethod = StatefulTestContract.deploy(wallet, owner, owner, 42);
logger.debug(`Creating request/calls to register and deploy contract`);
const deploy = await deployMethod.request();
logger.debug(`Getting an instance of the not-yet-deployed contract to batch calls to`);
const contract = await StatefulTestContract.at(deployMethod.getInstance().address, wallet);

// Batch registration, deployment, and public call into same TX
logger.debug(`Creating public calls to run in same batch as deployment`);
const init = contract.methods.increment_public_value(owner, 84).request();
logger.debug(`Deploying a contract and calling a public function in the same batched call`);
await new BatchCall(wallet, [...deploy.calls, init]).send().wait();
}, 300_000);

it.skip('publicly deploys and calls a public function in a tx in the same block', async () => {
// TODO(@spalladino): Requires being able to read a nullifier on the same block it was emitted.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function getNullifierMembershipWitnessResolver(oracle: ProvingDataOracle) {
return async (nullifier: Fr) => {
const res = await oracle.getNullifierMembershipWitness(nullifier);
if (!res) {
throw new Error(`Cannot find the leaf for nullifier ${nullifier.toBigInt()}.`);
throw new Error(`Cannot find the leaf for nullifier ${nullifier}.`);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hard to read a nullifier as a bigint

}

const { index, siblingPath, leafPreimage } = res;
Expand Down
Loading