Skip to content

Commit

Permalink
Fix e2e deploy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spalladino committed Mar 13, 2024
1 parent 117da5d commit 44af89e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions yarn-project/aztec.js/src/contract/deploy_method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
*/
public async create(options: DeployOptions = {}): Promise<TxExecutionRequest> {
if (!this.txRequest) {
const calls = await this.request(options);
if (calls.length === 0) {
throw new Error(`No function calls needed to deploy contract ${this.artifact.name}`);
}
this.txRequest = await this.wallet.createTxExecutionRequest(await this.request(options));
// TODO: Should we add the contracts to the DB here, or once the tx has been sent or mined?
await this.pxe.addContracts([{ artifact: this.artifact, instance: this.instance! }]);
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/end-to-end/src/e2e_deploy_contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,13 +503,13 @@ describe('e2e_deploy_contract', () => {
logger.debug(`Call a public function to check that it was publicly deployed`);
const receipt = await contract.methods.emit_unencrypted(42).send().wait();
const logs = await pxe.getUnencryptedLogs({ txHash: receipt.txHash });
expect(logs.logs[0].log.data.toString('hex')).toEqual('2a');
expect(logs.logs[0].log.data.toString('hex').replace(/^0+/, '')).toEqual('2a');
});

it('deploys a contract with no constructor and no public deployment as a noop', async () => {
it('refuses to deploy a contract with no constructor and no public deployment', async () => {
logger.debug(`Deploying contract with no constructor and skipping public deploy`);
const opts = { skipPublicDeployment: true, skipClassRegistration: true };
await TestContract.deploy(wallet).send(opts).deployed();
await expect(TestContract.deploy(wallet).simulate(opts)).rejects.toThrow(/no function calls needed/i);
});

it.skip('publicly deploys and calls a public function in the same batched call', async () => {
Expand Down

0 comments on commit 44af89e

Please sign in to comment.