Skip to content

Commit

Permalink
naming
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Nov 6, 2023
1 parent 964585b commit 0b51791
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
12 changes: 6 additions & 6 deletions yarn-project/aztec.js/src/contract/sent_tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ export type WaitOpts = {
* If false, then any queries that depend on state set by this transaction may return stale data. Defaults to true.
**/
waitForNotesSync?: boolean;
/** Whether to include information useful for testing in the receipt. */
test?: boolean;
/** Whether to include information useful for debugging/testing in the receipt. */
debug?: boolean;
};

const DefaultWaitOpts: WaitOpts = {
timeout: 60,
interval: 1,
waitForNotesSync: true,
test: false,
debug: false,
};

/**
Expand Down Expand Up @@ -61,17 +61,17 @@ export class SentTx {
* @returns The transaction receipt.
*/
public async wait(opts?: WaitOpts): Promise<FieldsOf<TxReceipt>> {
if (opts?.test && opts.waitForNotesSync === false) {
if (opts?.debug && opts.waitForNotesSync === false) {
throw new Error('Cannot set getNotes to true if waitForNotesSync is false');
}
const receipt = await this.waitForReceipt(opts);
if (receipt.status !== TxStatus.MINED)
throw new Error(`Transaction ${await this.getTxHash()} was ${receipt.status}`);
if (opts?.test) {
if (opts?.debug) {
const txHash = await this.getTxHash();
const tx = (await this.pxe.getTx(txHash))!;
const visibleNotes = await this.pxe.getNotes({ txHash });
receipt.testInfo = {
receipt.debugInfo = {
newCommitments: tx.newCommitments,
newNullifiers: tx.newNullifiers,
newPublicDataWrites: tx.newPublicDataWrites,
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/end-to-end/src/e2e_token_contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ describe('e2e_token_contract', () => {
it('redeem as recipient', async () => {
await addPendingShieldNoteToPXE(0, amount, secretHash, txHash);
const txClaim = asset.methods.redeem_shield(accounts[0].address, amount, secret).send();
const receiptClaim = await txClaim.wait({ test: true });
const receiptClaim = await txClaim.wait({ debug: true });
expect(receiptClaim.status).toBe(TxStatus.MINED);
tokenSim.redeemShield(accounts[0].address, amount);
// 1 note should be created containing `amount` of tokens
const { visibleNotes } = receiptClaim.testInfo!;
const { visibleNotes } = receiptClaim.debugInfo!;
expect(visibleNotes.length).toBe(1);
expect(visibleNotes[0].note.items[0].toBigInt()).toBe(amount);
});
Expand Down
7 changes: 4 additions & 3 deletions yarn-project/types/src/tx/tx_receipt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class TxReceipt {
/**
* Information useful for testing, set when test flag is set to true in `waitOpts`.
*/
public testInfo?: TestInfo,
public debugInfo?: DebugInfo,
) {}

/**
Expand Down Expand Up @@ -79,9 +79,10 @@ export class TxReceipt {
}

/**
* Information useful for testing purposes included in the receipt when the test flag is set to true in `WaitOpts`.
* Information useful for debugging/testing purposes included in the receipt when the debug flag is set to true
* in `WaitOpts`.
*/
interface TestInfo {
interface DebugInfo {
/**
* New commitments created by the transaction.
*/
Expand Down

0 comments on commit 0b51791

Please sign in to comment.