Skip to content
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
Expand Up @@ -62,7 +62,7 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch
});

it('throws an error if limit is invalid', async () => {
await expect(store.getBlocks(1, 0)).rejects.toThrowError('Invalid limit: 0');
await expect(store.getBlocks(1, 0)).rejects.toThrow('Invalid limit: 0');
});

it('resets `from` to the first block if it is out of range', async () => {
Expand Down
16 changes: 8 additions & 8 deletions yarn-project/aztec.js/src/contract/checker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ describe('abiChecker', () => {
abi = {
name: 'TEST_ABI',
};
expect(() => abiChecker(abi)).toThrowError('artifact has no functions');
expect(() => abiChecker(abi)).toThrow('artifact has no functions');
abi = {
name: 'TEST_ABI',
functions: [],
};
expect(() => abiChecker(abi)).toThrowError('artifact has no functions');
expect(() => abiChecker(abi)).toThrow('artifact has no functions');
});

it('should error if ABI has no names', () => {
abi = {
name: 'TEST_ABI',
functions: [{ bytecode: '0af', parameters: [{ type: { kind: 'test' } }] }],
};
expect(() => abiChecker(abi)).toThrowError('ABI function has no name');
expect(() => abiChecker(abi)).toThrow('ABI function has no name');
});

it('should error if ABI function has unrecognized type', () => {
Expand All @@ -34,7 +34,7 @@ describe('abiChecker', () => {
},
],
};
expect(() => abiChecker(abi)).toThrowError('ABI function parameter has an unrecognized type');
expect(() => abiChecker(abi)).toThrow('ABI function parameter has an unrecognized type');
});

it('should error if integer is incorrectly formed', () => {
Expand All @@ -48,7 +48,7 @@ describe('abiChecker', () => {
},
],
};
expect(() => abiChecker(abi)).toThrowError('Unrecognized attribute on type integer');
expect(() => abiChecker(abi)).toThrow('Unrecognized attribute on type integer');
});

it('should error if string is incorrectly formed', () => {
Expand All @@ -62,7 +62,7 @@ describe('abiChecker', () => {
},
],
};
expect(() => abiChecker(abi)).toThrowError('Unrecognized attribute on type string');
expect(() => abiChecker(abi)).toThrow('Unrecognized attribute on type string');
});

it('should error if struct is incorrectly formed', () => {
Expand All @@ -82,7 +82,7 @@ describe('abiChecker', () => {
},
],
};
expect(() => abiChecker(abi)).toThrowError('Unrecognized attribute on type struct');
expect(() => abiChecker(abi)).toThrow('Unrecognized attribute on type struct');
});

it('should error if array is incorrectly formed', () => {
Expand Down Expand Up @@ -112,7 +112,7 @@ describe('abiChecker', () => {
},
],
};
expect(() => abiChecker(abi)).toThrowError('ABI function parameter has an incorrectly formed array');
expect(() => abiChecker(abi)).toThrow('ABI function parameter has an incorrectly formed array');
});

it('valid matrix should pass checker', () => {
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/aztec.js/src/contract/sent_tx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('SentTx', () => {

it('fails if an account is not synced', async () => {
pxe.getSyncStatus.mockResolvedValue({ blocks: 25, notes: { '0x1': 19, '0x2': 20 } });
await expect(sentTx.wait({ timeout: 1, interval: 0.4 })).rejects.toThrowError(/timeout/i);
await expect(sentTx.wait({ timeout: 1, interval: 0.4 })).rejects.toThrow(/timeout/i);
});

it('does not wait for notes sync', async () => {
Expand All @@ -46,7 +46,7 @@ describe('SentTx', () => {
it('throws if tx is dropped', async () => {
pxe.getTxReceipt.mockResolvedValue({ ...txReceipt, status: TxStatus.DROPPED } as TxReceipt);
pxe.getSyncStatus.mockResolvedValue({ blocks: 19, notes: { '0x1': 19, '0x2': 19 } });
await expect(sentTx.wait({ timeout: 1, interval: 0.4 })).rejects.toThrowError(/dropped/);
await expect(sentTx.wait({ timeout: 1, interval: 0.4 })).rejects.toThrow(/dropped/);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CompleteAddress } from './complete_address.js';

describe('CompleteAddress', () => {
it('refuses to add an account with incorrect address for given partial address and pubkey', () => {
expect(() => CompleteAddress.create(AztecAddress.random(), Point.random(), Fr.random())).toThrowError(
expect(() => CompleteAddress.create(AztecAddress.random(), Point.random(), Fr.random())).toThrow(
/cannot be derived/,
);
});
Expand Down
8 changes: 2 additions & 6 deletions yarn-project/cli/src/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,12 @@ describe('client', () => {

it('reports mismatch on older pxe version', async () => {
pxe.getNodeInfo.mockResolvedValue({ nodeVersion: '0.1.0-alpha47' } as NodeInfo);
await expect(checkServerVersion(pxe, '0.1.0-alpha48')).rejects.toThrowError(
/is older than the expected by this CLI/,
);
await expect(checkServerVersion(pxe, '0.1.0-alpha48')).rejects.toThrow(/is older than the expected by this CLI/);
});

it('reports mismatch on newer pxe version', async () => {
pxe.getNodeInfo.mockResolvedValue({ nodeVersion: '0.1.0-alpha48' } as NodeInfo);
await expect(checkServerVersion(pxe, '0.1.0-alpha47')).rejects.toThrowError(
/is newer than the expected by this CLI/,
);
await expect(checkServerVersion(pxe, '0.1.0-alpha47')).rejects.toThrow(/is newer than the expected by this CLI/);
});
});
});
24 changes: 5 additions & 19 deletions yarn-project/end-to-end/src/e2e_2_pxes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
GrumpkinScalar,
Note,
PXE,
TxStatus,
Wallet,
computeMessageSecretHash,
retryUntil,
Expand Down Expand Up @@ -106,7 +105,6 @@ describe('e2e_2_pxes', () => {
const secretHash = computeMessageSecretHash(secret);

const receipt = await contract.methods.mint_private(balance, secretHash).send().wait();
expect(receipt.status).toEqual(TxStatus.MINED);

const storageSlot = new Fr(5);
const noteTypeId = new Fr(84114971101151129711410111011678111116101n); // TransparentNote
Expand All @@ -115,9 +113,7 @@ describe('e2e_2_pxes', () => {
const extendedNote = new ExtendedNote(note, recipient, contract.address, storageSlot, noteTypeId, receipt.txHash);
await pxe.addNote(extendedNote);

expect((await contract.methods.redeem_shield(recipient, balance, secret).send().wait()).status).toEqual(
TxStatus.MINED,
);
await contract.methods.redeem_shield(recipient, balance, secret).send().wait();
};

it('transfers funds from user A to B via PXE A followed by transfer from B to A via PXE B', async () => {
Expand Down Expand Up @@ -148,11 +144,7 @@ describe('e2e_2_pxes', () => {

// Transfer funds from A to B via PXE A
const contractWithWalletA = await TokenContract.at(tokenAddress, walletA);
const receiptAToB = await contractWithWalletA.methods
.transfer(userA.address, userB.address, transferAmount1, 0)
.send()
.wait();
expect(receiptAToB.status).toBe(TxStatus.MINED);
await contractWithWalletA.methods.transfer(userA.address, userB.address, transferAmount1, 0).send().wait();

// Check balances and logs are as expected
await expectTokenBalance(walletA, tokenAddress, userA.address, initialBalance - transferAmount1);
Expand Down Expand Up @@ -292,11 +284,7 @@ describe('e2e_2_pxes', () => {

// Transfer funds from A to B via PXE A
const contractWithWalletA = await TokenContract.at(tokenAddress, walletA);
const receiptAToB = await contractWithWalletA.methods
.transfer(userA.address, userB.address, transferAmount1, 0)
.send()
.wait();
expect(receiptAToB.status).toBe(TxStatus.MINED);
await contractWithWalletA.methods.transfer(userA.address, userB.address, transferAmount1, 0).send().wait();

// now add the contract and check balances
await pxeB.addContracts([
Expand Down Expand Up @@ -333,19 +321,17 @@ describe('e2e_2_pxes', () => {

// Transfer funds from A to Shared Wallet via PXE A
const contractWithWalletA = await TokenContract.at(tokenAddress, walletA);
const receiptAToShared = await contractWithWalletA.methods
await contractWithWalletA.methods
.transfer(userA.address, sharedAccountAddress.address, transferAmount1, 0)
.send()
.wait();
expect(receiptAToShared.status).toBe(TxStatus.MINED);

// Now send funds from Shared Wallet to B via PXE A
const contractWithSharedWalletA = await TokenContract.at(tokenAddress, sharedWalletOnA);
const receiptSharedToB = await contractWithSharedWalletA.methods
await contractWithSharedWalletA.methods
.transfer(sharedAccountAddress.address, userB.address, transferAmount2, 0)
.send()
.wait();
expect(receiptSharedToB.status).toBe(TxStatus.MINED);

// check balances from PXE-A's perspective
await expectTokenBalance(walletA, tokenAddress, userA.address, initialBalance - transferAmount1);
Expand Down
4 changes: 1 addition & 3 deletions yarn-project/end-to-end/src/e2e_account_contracts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ function itShouldBehaveLikeAnAccountContract(
const accountAddress = wallet.getCompleteAddress();
const invalidWallet = await walletAt(context.pxe, getAccountContract(GrumpkinScalar.random()), accountAddress);
const childWithInvalidWallet = await ChildContract.at(child.address, invalidWallet);
await expect(childWithInvalidWallet.methods.value(42).simulate()).rejects.toThrowError(
/Cannot satisfy constraint.*/,
);
await expect(childWithInvalidWallet.methods.value(42).simulate()).rejects.toThrow(/Cannot satisfy constraint.*/);
});
});
}
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/end-to-end/src/e2e_authwit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('e2e_authwit_tests', () => {
const c = await SchnorrAccountContract.at(wallets[0].getAddress(), wallets[0]);
const txCancelledAuthwit = c.withWallet(wallets[1]).methods.spend_private_authwit(innerHash).send();
// The transaction should be dropped because of a cancelled authwit (duplicate nullifier)
await expect(txCancelledAuthwit.wait()).rejects.toThrowError('Transaction ');
await expect(txCancelledAuthwit.wait()).rejects.toThrow('Transaction ');
});
});
});
Expand Down Expand Up @@ -73,7 +73,7 @@ describe('e2e_authwit_tests', () => {
const c = await SchnorrAccountContract.at(wallets[0].getAddress(), wallets[0]);
const txCancelledAuthwit = c.withWallet(wallets[1]).methods.spend_public_authwit(innerHash).send();
// The transaction should be dropped because of a cancelled authwit (duplicate nullifier)
await expect(txCancelledAuthwit.wait()).rejects.toThrowError('Transaction ');
await expect(txCancelledAuthwit.wait()).rejects.toThrow('Transaction ');
});
});
});
Expand Down
Loading