diff --git a/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts b/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts index e051154e67d..3045ae32b36 100644 --- a/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts +++ b/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts @@ -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 () => { diff --git a/yarn-project/aztec.js/src/contract/checker.test.ts b/yarn-project/aztec.js/src/contract/checker.test.ts index 9b4183cbba6..d2c945623f4 100644 --- a/yarn-project/aztec.js/src/contract/checker.test.ts +++ b/yarn-project/aztec.js/src/contract/checker.test.ts @@ -7,12 +7,12 @@ 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', () => { @@ -20,7 +20,7 @@ describe('abiChecker', () => { 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', () => { @@ -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', () => { @@ -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', () => { @@ -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', () => { @@ -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', () => { @@ -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', () => { diff --git a/yarn-project/aztec.js/src/contract/sent_tx.test.ts b/yarn-project/aztec.js/src/contract/sent_tx.test.ts index ff8c98fdc42..b9f2b78bea1 100644 --- a/yarn-project/aztec.js/src/contract/sent_tx.test.ts +++ b/yarn-project/aztec.js/src/contract/sent_tx.test.ts @@ -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 () => { @@ -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/); }); }); }); diff --git a/yarn-project/circuits.js/src/structs/complete_address.test.ts b/yarn-project/circuits.js/src/structs/complete_address.test.ts index c3047a267cb..afe57420f59 100644 --- a/yarn-project/circuits.js/src/structs/complete_address.test.ts +++ b/yarn-project/circuits.js/src/structs/complete_address.test.ts @@ -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/, ); }); diff --git a/yarn-project/cli/src/client.test.ts b/yarn-project/cli/src/client.test.ts index bcace613eeb..8e879f762ba 100644 --- a/yarn-project/cli/src/client.test.ts +++ b/yarn-project/cli/src/client.test.ts @@ -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/); }); }); }); diff --git a/yarn-project/end-to-end/src/e2e_account_contracts.test.ts b/yarn-project/end-to-end/src/e2e_account_contracts.test.ts index e3149ec793c..90807e53ee9 100644 --- a/yarn-project/end-to-end/src/e2e_account_contracts.test.ts +++ b/yarn-project/end-to-end/src/e2e_account_contracts.test.ts @@ -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.*/); }); }); } diff --git a/yarn-project/end-to-end/src/e2e_authwit.test.ts b/yarn-project/end-to-end/src/e2e_authwit.test.ts index 4eef8e659b2..bb45d12f586 100644 --- a/yarn-project/end-to-end/src/e2e_authwit.test.ts +++ b/yarn-project/end-to-end/src/e2e_authwit.test.ts @@ -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 '); }); }); }); @@ -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 '); }); }); }); diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts index 1b8647e16bf..7d8f1bf9b24 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts @@ -279,11 +279,11 @@ describe('e2e_blacklist_token_contract', () => { await wallets[3].addCapsule( getMembershipCapsule(await getMembershipProof(accounts[3].address.toBigInt(), false)), ); - await expect( - asset.withWallet(wallets[3]).methods.update_roles(account, newRoles).simulate(), - ).rejects.toThrowError("Assertion failed: caller is not admin 'caller_roles.is_admin'"); + await expect(asset.withWallet(wallets[3]).methods.update_roles(account, newRoles).simulate()).rejects.toThrow( + "Assertion failed: caller is not admin 'caller_roles.is_admin'", + ); - /* await expect(asset.methods.set_admin(accounts[0].address).simulate()).rejects.toThrowError( + /* await expect(asset.methods.set_admin(accounts[0].address).simulate()).rejects.toThrow( 'Assertion failed: caller is not admin', );*/ }); @@ -302,9 +302,9 @@ describe('e2e_blacklist_token_contract', () => { ); await expect( asset.withWallet(wallets[3]).methods.update_roles(adminAccount, newRoles).simulate(), - ).rejects.toThrowError("Assertion failed: caller is not admin 'caller_roles.is_admin'"); + ).rejects.toThrow("Assertion failed: caller is not admin 'caller_roles.is_admin'"); - /* await expect(asset.methods.set_minter(accounts[0].address, false).simulate()).rejects.toThrowError( + /* await expect(asset.methods.set_minter(accounts[0].address, false).simulate()).rejects.toThrow( 'Assertion failed: caller is not admin', );*/ }); @@ -329,26 +329,26 @@ describe('e2e_blacklist_token_contract', () => { const amount = 10000n; await expect( asset.withWallet(wallets[1]).methods.mint_public(accounts[0].address, amount).simulate(), - ).rejects.toThrowError('Assertion failed: caller is not minter'); + ).rejects.toThrow('Assertion failed: caller is not minter'); }); it('mint >u128 tokens to overflow', async () => { const amount = 2n ** 128n; // U128::max() + 1; - await expect(asset.methods.mint_public(accounts[0].address, amount).simulate()).rejects.toThrowError( + await expect(asset.methods.mint_public(accounts[0].address, amount).simulate()).rejects.toThrow( BITSIZE_TOO_BIG_ERROR, ); }); it('mint u128', async () => { const amount = 2n ** 128n - tokenSim.balanceOfPublic(accounts[0].address); - await expect(asset.methods.mint_public(accounts[0].address, amount).simulate()).rejects.toThrowError( + await expect(asset.methods.mint_public(accounts[0].address, amount).simulate()).rejects.toThrow( U128_OVERFLOW_ERROR, ); }); it('mint u128', async () => { const amount = 2n ** 128n - tokenSim.balanceOfPublic(accounts[0].address); - await expect(asset.methods.mint_public(accounts[1].address, amount).simulate()).rejects.toThrowError( + await expect(asset.methods.mint_public(accounts[1].address, amount).simulate()).rejects.toThrow( U128_OVERFLOW_ERROR, ); }); @@ -356,7 +356,7 @@ describe('e2e_blacklist_token_contract', () => { it('mint to blacklisted entity', async () => { await expect( asset.withWallet(wallets[1]).methods.mint_public(accounts[3].address, 1n).simulate(), - ).rejects.toThrowError("Assertion failed: Blacklisted: Recipient '!to_roles.is_blacklisted'"); + ).rejects.toThrow("Assertion failed: Blacklisted: Recipient '!to_roles.is_blacklisted'"); }); }); }); @@ -397,26 +397,26 @@ describe('e2e_blacklist_token_contract', () => { describe('failure cases', () => { it('try to redeem as recipient (double-spend) [REVERTS]', async () => { - await expect(addPendingShieldNoteToPXE(0, amount, secretHash, txHash)).rejects.toThrowError( + await expect(addPendingShieldNoteToPXE(0, amount, secretHash, txHash)).rejects.toThrow( 'The note has been destroyed.', ); await wallets[0].addCapsule( getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true)), ); - await expect( - asset.methods.redeem_shield(accounts[0].address, amount, secret).simulate(), - ).rejects.toThrowError('Can only remove a note that has been read from the set.'); + await expect(asset.methods.redeem_shield(accounts[0].address, amount, secret).simulate()).rejects.toThrow( + 'Can only remove a note that has been read from the set.', + ); }); it('mint_private as non-minter', async () => { await expect( asset.withWallet(wallets[1]).methods.mint_private(amount, secretHash).simulate(), - ).rejects.toThrowError('Assertion failed: caller is not minter'); + ).rejects.toThrow('Assertion failed: caller is not minter'); }); it('mint >u128 tokens to overflow', async () => { const amount = 2n ** 128n; // U128::max() + 1; - await expect(asset.methods.mint_private(amount, secretHash).simulate()).rejects.toThrowError( + await expect(asset.methods.mint_private(amount, secretHash).simulate()).rejects.toThrow( BITSIZE_TOO_BIG_ERROR, ); }); @@ -425,25 +425,21 @@ describe('e2e_blacklist_token_contract', () => { // @todo @LHerskind this one don't make sense. It fails because of total supply overflowing. const amount = 2n ** 128n - tokenSim.balanceOfPrivate(accounts[0].address); expect(amount).toBeLessThan(2n ** 128n); - await expect(asset.methods.mint_private(amount, secretHash).simulate()).rejects.toThrowError( - U128_OVERFLOW_ERROR, - ); + await expect(asset.methods.mint_private(amount, secretHash).simulate()).rejects.toThrow(U128_OVERFLOW_ERROR); }); it('mint u128', async () => { const amount = 2n ** 128n - tokenSim.totalSupply; - await expect(asset.methods.mint_private(amount, secretHash).simulate()).rejects.toThrowError( - U128_OVERFLOW_ERROR, - ); + await expect(asset.methods.mint_private(amount, secretHash).simulate()).rejects.toThrow(U128_OVERFLOW_ERROR); }); it('mint and try to redeem at blacklist', async () => { await wallets[3].addCapsule( getMembershipCapsule(await getMembershipProof(accounts[3].address.toBigInt(), true)), ); - await expect( - asset.methods.redeem_shield(accounts[3].address, amount, secret).simulate(), - ).rejects.toThrowError("Assertion failed: Blacklisted: Recipient '!to_roles.is_blacklisted'"); + await expect(asset.methods.redeem_shield(accounts[3].address, amount, secret).simulate()).rejects.toThrow( + "Assertion failed: Blacklisted: Recipient '!to_roles.is_blacklisted'", + ); }); }); }); @@ -494,7 +490,7 @@ describe('e2e_blacklist_token_contract', () => { .withWallet(wallets[1]) .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce) .send(); - await expect(txReplay.wait()).rejects.toThrowError('Transaction '); + await expect(txReplay.wait()).rejects.toThrow('Transaction '); }); describe('failure cases', () => { @@ -504,7 +500,7 @@ describe('e2e_blacklist_token_contract', () => { const nonce = 0; await expect( asset.methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce).simulate(), - ).rejects.toThrowError(U128_UNDERFLOW_ERROR); + ).rejects.toThrow(U128_UNDERFLOW_ERROR); }); it('transfer on behalf of self with non-zero nonce', async () => { @@ -513,7 +509,7 @@ describe('e2e_blacklist_token_contract', () => { const nonce = 1; await expect( asset.methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce).simulate(), - ).rejects.toThrowError('Assertion failed: invalid nonce'); + ).rejects.toThrow('Assertion failed: invalid nonce'); }); it('transfer on behalf of other without "approval"', async () => { @@ -525,7 +521,7 @@ describe('e2e_blacklist_token_contract', () => { .withWallet(wallets[1]) .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce) .simulate(), - ).rejects.toThrowError('Assertion failed: Message not authorized by account'); + ).rejects.toThrow('Assertion failed: Message not authorized by account'); }); it('transfer more than balance on behalf of other', async () => { @@ -544,7 +540,7 @@ describe('e2e_blacklist_token_contract', () => { await wallets[0].setPublicAuth(messageHash, true).send().wait(); // Perform the transfer - await expect(action.simulate()).rejects.toThrowError(U128_UNDERFLOW_ERROR); + await expect(action.simulate()).rejects.toThrow(U128_UNDERFLOW_ERROR); expect(await asset.methods.balance_of_public(accounts[0].address).view()).toEqual(balance0); expect(await asset.methods.balance_of_public(accounts[1].address).view()).toEqual(balance1); @@ -566,7 +562,7 @@ describe('e2e_blacklist_token_contract', () => { await wallets[0].setPublicAuth(messageHash, true).send().wait(); // Perform the transfer - await expect(action.simulate()).rejects.toThrowError('Assertion failed: Message not authorized by account'); + await expect(action.simulate()).rejects.toThrow('Assertion failed: Message not authorized by account'); expect(await asset.methods.balance_of_public(accounts[0].address).view()).toEqual(balance0); expect(await asset.methods.balance_of_public(accounts[1].address).view()).toEqual(balance1); @@ -587,7 +583,7 @@ describe('e2e_blacklist_token_contract', () => { await wallets[0].setPublicAuth(messageHash, true).send().wait(); // Perform the transfer - await expect(action.simulate()).rejects.toThrowError('Assertion failed: Message not authorized by account'); + await expect(action.simulate()).rejects.toThrow('Assertion failed: Message not authorized by account'); expect(await asset.methods.balance_of_public(accounts[0].address).view()).toEqual(balance0); expect(await asset.methods.balance_of_public(accounts[1].address).view()).toEqual(balance1); @@ -603,13 +599,13 @@ describe('e2e_blacklist_token_contract', () => { it('transfer from a blacklisted account', async () => { await expect( asset.methods.transfer_public(accounts[3].address, accounts[0].address, 1n, 0n).simulate(), - ).rejects.toThrowError("Assertion failed: Blacklisted: Sender '!from_roles.is_blacklisted'"); + ).rejects.toThrow("Assertion failed: Blacklisted: Sender '!from_roles.is_blacklisted'"); }); it('transfer to a blacklisted account', async () => { await expect( asset.methods.transfer_public(accounts[0].address, accounts[3].address, 1n, 0n).simulate(), - ).rejects.toThrowError("Assertion failed: Blacklisted: Recipient '!to_roles.is_blacklisted'"); + ).rejects.toThrow("Assertion failed: Blacklisted: Recipient '!to_roles.is_blacklisted'"); }); }); }); @@ -684,7 +680,7 @@ describe('e2e_blacklist_token_contract', () => { .withWallet(wallets[1]) .methods.transfer(accounts[0].address, accounts[1].address, amount, nonce) .send(); - await expect(txReplay.wait()).rejects.toThrowError('Transaction '); + await expect(txReplay.wait()).rejects.toThrow('Transaction '); }); describe('failure cases', () => { @@ -700,7 +696,7 @@ describe('e2e_blacklist_token_contract', () => { ); await expect( asset.methods.transfer(accounts[0].address, accounts[1].address, amount, 0).simulate(), - ).rejects.toThrowError('Assertion failed: Balance too low'); + ).rejects.toThrow('Assertion failed: Balance too low'); }); it('transfer on behalf of self with non-zero nonce', async () => { @@ -715,7 +711,7 @@ describe('e2e_blacklist_token_contract', () => { ); await expect( asset.methods.transfer(accounts[0].address, accounts[1].address, amount, 1).simulate(), - ).rejects.toThrowError('Assertion failed: invalid nonce'); + ).rejects.toThrow('Assertion failed: invalid nonce'); }); it('transfer more than balance on behalf of other', async () => { @@ -744,7 +740,7 @@ describe('e2e_blacklist_token_contract', () => { ); // Perform the transfer - await expect(action.simulate()).rejects.toThrowError('Assertion failed: Balance too low'); + await expect(action.simulate()).rejects.toThrow('Assertion failed: Balance too low'); expect(await asset.methods.balance_of_private(accounts[0].address).view()).toEqual(balance0); expect(await asset.methods.balance_of_private(accounts[1].address).view()).toEqual(balance1); }); @@ -774,7 +770,7 @@ describe('e2e_blacklist_token_contract', () => { getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true)), ); - await expect(action.simulate()).rejects.toThrowError( + await expect(action.simulate()).rejects.toThrow( `Unknown auth witness for message hash ${messageHash.toString()}`, ); }); @@ -801,7 +797,7 @@ describe('e2e_blacklist_token_contract', () => { getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true)), ); - await expect(action.simulate()).rejects.toThrowError( + await expect(action.simulate()).rejects.toThrow( `Unknown auth witness for message hash ${expectedMessageHash.toString()}`, ); expect(await asset.methods.balance_of_private(accounts[0].address).view()).toEqual(balance0); @@ -816,7 +812,7 @@ describe('e2e_blacklist_token_contract', () => { ); await expect( asset.methods.transfer(accounts[3].address, accounts[0].address, 1n, 0).simulate(), - ).rejects.toThrowError("Assertion failed: Blacklisted: Sender '!from_roles.is_blacklisted'"); + ).rejects.toThrow("Assertion failed: Blacklisted: Sender '!from_roles.is_blacklisted'"); }); it('transfer to a blacklisted account', async () => { @@ -828,7 +824,7 @@ describe('e2e_blacklist_token_contract', () => { ); await expect( asset.methods.transfer(accounts[0].address, accounts[3].address, 1n, 0).simulate(), - ).rejects.toThrowError("Assertion failed: Blacklisted: Recipient '!to_roles.is_blacklisted'"); + ).rejects.toThrow("Assertion failed: Blacklisted: Recipient '!to_roles.is_blacklisted'"); }); }); }); @@ -881,7 +877,7 @@ describe('e2e_blacklist_token_contract', () => { .withWallet(wallets[1]) .methods.shield(accounts[0].address, amount, secretHash, nonce) .send(); - await expect(txReplay.wait()).rejects.toThrowError('Transaction '); + await expect(txReplay.wait()).rejects.toThrow('Transaction '); // Redeem it await addPendingShieldNoteToPXE(0, amount, secretHash, receipt.txHash); @@ -897,7 +893,7 @@ describe('e2e_blacklist_token_contract', () => { const amount = balancePub + 1n; expect(amount).toBeGreaterThan(0n); - await expect(asset.methods.shield(accounts[0].address, amount, secretHash, 0).simulate()).rejects.toThrowError( + await expect(asset.methods.shield(accounts[0].address, amount, secretHash, 0).simulate()).rejects.toThrow( U128_UNDERFLOW_ERROR, ); }); @@ -907,7 +903,7 @@ describe('e2e_blacklist_token_contract', () => { const amount = balancePub + 1n; expect(amount).toBeGreaterThan(0n); - await expect(asset.methods.shield(accounts[0].address, amount, secretHash, 1).simulate()).rejects.toThrowError( + await expect(asset.methods.shield(accounts[0].address, amount, secretHash, 1).simulate()).rejects.toThrow( 'Assertion failed: invalid nonce', ); }); @@ -923,7 +919,7 @@ describe('e2e_blacklist_token_contract', () => { const messageHash = computeAuthWitMessageHash(accounts[1].address, action.request()); await wallets[0].setPublicAuth(messageHash, true).send().wait(); - await expect(action.simulate()).rejects.toThrowError(U128_UNDERFLOW_ERROR); + await expect(action.simulate()).rejects.toThrow(U128_UNDERFLOW_ERROR); }); it('on behalf of other (wrong designated caller)', async () => { @@ -937,7 +933,7 @@ describe('e2e_blacklist_token_contract', () => { const messageHash = computeAuthWitMessageHash(accounts[1].address, action.request()); await wallets[0].setPublicAuth(messageHash, true).send().wait(); - await expect(action.simulate()).rejects.toThrowError('Assertion failed: Message not authorized by account'); + await expect(action.simulate()).rejects.toThrow('Assertion failed: Message not authorized by account'); }); it('on behalf of other (without approval)', async () => { @@ -948,7 +944,7 @@ describe('e2e_blacklist_token_contract', () => { await expect( asset.withWallet(wallets[1]).methods.shield(accounts[0].address, amount, secretHash, nonce).simulate(), - ).rejects.toThrowError(`Assertion failed: Message not authorized by account`); + ).rejects.toThrow(`Assertion failed: Message not authorized by account`); }); it('shielding from blacklisted account', async () => { @@ -957,7 +953,7 @@ describe('e2e_blacklist_token_contract', () => { ); await expect( asset.withWallet(wallets[3]).methods.shield(accounts[3].address, 1n, secretHash, 0).simulate(), - ).rejects.toThrowError("Assertion failed: Blacklisted: Sender '!from_roles.is_blacklisted'"); + ).rejects.toThrow("Assertion failed: Blacklisted: Sender '!from_roles.is_blacklisted'"); }); }); }); @@ -1005,7 +1001,7 @@ describe('e2e_blacklist_token_contract', () => { .withWallet(wallets[1]) .methods.unshield(accounts[0].address, accounts[1].address, amount, nonce) .send(); - await expect(txReplay.wait()).rejects.toThrowError('Transaction '); + await expect(txReplay.wait()).rejects.toThrow('Transaction '); // @todo @LHerskind This error is weird? }); @@ -1024,7 +1020,7 @@ describe('e2e_blacklist_token_contract', () => { await expect( asset.methods.unshield(accounts[0].address, accounts[0].address, amount, 0).simulate(), - ).rejects.toThrowError('Assertion failed: Balance too low'); + ).rejects.toThrow('Assertion failed: Balance too low'); }); it('on behalf of self (invalid nonce)', async () => { @@ -1041,7 +1037,7 @@ describe('e2e_blacklist_token_contract', () => { await expect( asset.methods.unshield(accounts[0].address, accounts[0].address, amount, 1).simulate(), - ).rejects.toThrowError('Assertion failed: invalid nonce'); + ).rejects.toThrow('Assertion failed: invalid nonce'); }); it('on behalf of other (more than balance)', async () => { @@ -1068,7 +1064,7 @@ describe('e2e_blacklist_token_contract', () => { getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true)), ); - await expect(action.simulate()).rejects.toThrowError('Assertion failed: Balance too low'); + await expect(action.simulate()).rejects.toThrow('Assertion failed: Balance too low'); }); it('on behalf of other (invalid designated caller)', async () => { @@ -1096,7 +1092,7 @@ describe('e2e_blacklist_token_contract', () => { getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true)), ); - await expect(action.simulate()).rejects.toThrowError( + await expect(action.simulate()).rejects.toThrow( `Unknown auth witness for message hash ${expectedMessageHash.toString()}`, ); }); @@ -1110,7 +1106,7 @@ describe('e2e_blacklist_token_contract', () => { ); await expect( asset.methods.unshield(accounts[3].address, accounts[0].address, 1n, 0).simulate(), - ).rejects.toThrowError("Assertion failed: Blacklisted: Sender '!from_roles.is_blacklisted'"); + ).rejects.toThrow("Assertion failed: Blacklisted: Sender '!from_roles.is_blacklisted'"); }); it('unshield to blacklisted account', async () => { @@ -1122,7 +1118,7 @@ describe('e2e_blacklist_token_contract', () => { ); await expect( asset.methods.unshield(accounts[0].address, accounts[3].address, 1n, 0).simulate(), - ).rejects.toThrowError("Assertion failed: Blacklisted: Recipient '!to_roles.is_blacklisted'"); + ).rejects.toThrow("Assertion failed: Blacklisted: Recipient '!to_roles.is_blacklisted'"); }); }); }); @@ -1155,7 +1151,7 @@ describe('e2e_blacklist_token_contract', () => { // Check that the message hash is no longer valid. Need to try to send since nullifiers are handled by sequencer. const txReplay = asset.withWallet(wallets[1]).methods.burn_public(accounts[0].address, amount, nonce).send(); - await expect(txReplay.wait()).rejects.toThrowError('Transaction '); + await expect(txReplay.wait()).rejects.toThrow('Transaction '); }); describe('failure cases', () => { @@ -1163,7 +1159,7 @@ describe('e2e_blacklist_token_contract', () => { const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance0 + 1n; const nonce = 0; - await expect(asset.methods.burn_public(accounts[0].address, amount, nonce).simulate()).rejects.toThrowError( + await expect(asset.methods.burn_public(accounts[0].address, amount, nonce).simulate()).rejects.toThrow( U128_UNDERFLOW_ERROR, ); }); @@ -1173,7 +1169,7 @@ describe('e2e_blacklist_token_contract', () => { const amount = balance0 - 1n; expect(amount).toBeGreaterThan(0n); const nonce = 1; - await expect(asset.methods.burn_public(accounts[0].address, amount, nonce).simulate()).rejects.toThrowError( + await expect(asset.methods.burn_public(accounts[0].address, amount, nonce).simulate()).rejects.toThrow( 'Assertion failed: invalid nonce', ); }); @@ -1184,7 +1180,7 @@ describe('e2e_blacklist_token_contract', () => { const nonce = Fr.random(); await expect( asset.withWallet(wallets[1]).methods.burn_public(accounts[0].address, amount, nonce).simulate(), - ).rejects.toThrowError('Assertion failed: Message not authorized by account'); + ).rejects.toThrow('Assertion failed: Message not authorized by account'); }); it('burn more than balance on behalf of other', async () => { @@ -1198,7 +1194,7 @@ describe('e2e_blacklist_token_contract', () => { const messageHash = computeAuthWitMessageHash(accounts[1].address, action.request()); await wallets[0].setPublicAuth(messageHash, true).send().wait(); - await expect(action.simulate()).rejects.toThrowError(U128_UNDERFLOW_ERROR); + await expect(action.simulate()).rejects.toThrow(U128_UNDERFLOW_ERROR); }); it('burn on behalf of other, wrong designated caller', async () => { @@ -1214,11 +1210,11 @@ describe('e2e_blacklist_token_contract', () => { await expect( asset.withWallet(wallets[1]).methods.burn_public(accounts[0].address, amount, nonce).simulate(), - ).rejects.toThrowError('Assertion failed: Message not authorized by account'); + ).rejects.toThrow('Assertion failed: Message not authorized by account'); }); it('burn from blacklisted account', async () => { - await expect(asset.methods.burn_public(accounts[3].address, 1n, 0).simulate()).rejects.toThrowError( + await expect(asset.methods.burn_public(accounts[3].address, 1n, 0).simulate()).rejects.toThrow( "Assertion failed: Blacklisted: Sender '!from_roles.is_blacklisted'", ); }); @@ -1264,7 +1260,7 @@ describe('e2e_blacklist_token_contract', () => { getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true)), ); const txReplay = asset.withWallet(wallets[1]).methods.burn(accounts[0].address, amount, nonce).send(); - await expect(txReplay.wait()).rejects.toThrowError('Transaction '); + await expect(txReplay.wait()).rejects.toThrow('Transaction '); }); describe('failure cases', () => { @@ -1275,7 +1271,7 @@ describe('e2e_blacklist_token_contract', () => { await wallets[0].addCapsule( getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true)), ); - await expect(asset.methods.burn(accounts[0].address, amount, 0).simulate()).rejects.toThrowError( + await expect(asset.methods.burn(accounts[0].address, amount, 0).simulate()).rejects.toThrow( 'Assertion failed: Balance too low', ); }); @@ -1287,7 +1283,7 @@ describe('e2e_blacklist_token_contract', () => { await wallets[0].addCapsule( getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true)), ); - await expect(asset.methods.burn(accounts[0].address, amount, 1).simulate()).rejects.toThrowError( + await expect(asset.methods.burn(accounts[0].address, amount, 1).simulate()).rejects.toThrow( 'Assertion failed: invalid nonce', ); }); @@ -1311,7 +1307,7 @@ describe('e2e_blacklist_token_contract', () => { getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true)), ); - await expect(action.simulate()).rejects.toThrowError('Assertion failed: Balance too low'); + await expect(action.simulate()).rejects.toThrow('Assertion failed: Balance too low'); }); it('burn on behalf of other without approval', async () => { @@ -1327,7 +1323,7 @@ describe('e2e_blacklist_token_contract', () => { const action = asset.withWallet(wallets[1]).methods.burn(accounts[0].address, amount, nonce); const messageHash = computeAuthWitMessageHash(accounts[1].address, action.request()); - await expect(action.simulate()).rejects.toThrowError( + await expect(action.simulate()).rejects.toThrow( `Unknown auth witness for message hash ${messageHash.toString()}`, ); }); @@ -1349,7 +1345,7 @@ describe('e2e_blacklist_token_contract', () => { const witness = await wallets[0].createAuthWitness(messageHash); await wallets[2].addAuthWitness(witness); - await expect(action.simulate()).rejects.toThrowError( + await expect(action.simulate()).rejects.toThrow( `Unknown auth witness for message hash ${expectedMessageHash.toString()}`, ); }); @@ -1358,7 +1354,7 @@ describe('e2e_blacklist_token_contract', () => { await wallets[0].addCapsule( getMembershipCapsule(await getMembershipProof(accounts[3].address.toBigInt(), true)), ); - await expect(asset.methods.burn(accounts[3].address, 1n, 0).simulate()).rejects.toThrowError( + await expect(asset.methods.burn(accounts[3].address, 1n, 0).simulate()).rejects.toThrow( "Assertion failed: Blacklisted: Sender '!from_roles.is_blacklisted'", ); }); diff --git a/yarn-project/end-to-end/src/e2e_block_building.test.ts b/yarn-project/end-to-end/src/e2e_block_building.test.ts index 99551f7df9a..33fb95fafec 100644 --- a/yarn-project/end-to-end/src/e2e_block_building.test.ts +++ b/yarn-project/end-to-end/src/e2e_block_building.test.ts @@ -146,7 +146,7 @@ describe('e2e_block_building', () => { it('drops tx with two equal nullifiers', async () => { const nullifier = Fr.random(); const calls = times(2, () => contract.methods.emit_nullifier(nullifier).request()); - await expect(new BatchCall(owner, calls).send().wait()).rejects.toThrowError(/dropped/); + await expect(new BatchCall(owner, calls).send().wait()).rejects.toThrow(/dropped/); }, 30_000); it('drops tx with private nullifier already emitted from public on the same block', async () => { diff --git a/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts b/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts index 4b27b58e103..047e57674e4 100644 --- a/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts @@ -111,7 +111,7 @@ describe('e2e_escrow_contract', () => { it('refuses to withdraw funds as a non-owner', async () => { await expect( escrowContract.withWallet(recipientWallet).methods.withdraw(token.address, 30, recipient).simulate(), - ).rejects.toThrowError(); + ).rejects.toThrow(); }, 60_000); it('moves funds using multiple keys on the same tx (#1010)', async () => { diff --git a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts index c9784cff810..753c7d7ae38 100644 --- a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts @@ -181,7 +181,7 @@ describe('e2e_public_cross_chain_messaging', () => { .withWallet(user1Wallet) .methods.exit_to_l1_public(ethAccount, withdrawAmount, EthAddress.ZERO, nonce) .simulate(), - ).rejects.toThrowError('Assertion failed: Message not authorized by account'); + ).rejects.toThrow('Assertion failed: Message not authorized by account'); }, 60_000); it("can't claim funds privately which were intended for public deposit from the token portal", async () => { @@ -212,9 +212,7 @@ describe('e2e_public_cross_chain_messaging', () => { await expect( l2Bridge.withWallet(user2Wallet).methods.claim_private(secretHash, bridgeAmount, secret).simulate(), - ).rejects.toThrowError( - `L1 to L2 message index not found in the store for message ${wrongMessage.hash().toString()}`, - ); + ).rejects.toThrow(`L1 to L2 message index not found in the store for message ${wrongMessage.hash().toString()}`); }, 60_000); // Note: We register one portal address when deploying contract but that address is no-longer the only address diff --git a/yarn-project/end-to-end/src/e2e_slow_tree.test.ts b/yarn-project/end-to-end/src/e2e_slow_tree.test.ts index 748101acea7..ffc41d35586 100644 --- a/yarn-project/end-to-end/src/e2e_slow_tree.test.ts +++ b/yarn-project/end-to-end/src/e2e_slow_tree.test.ts @@ -128,7 +128,7 @@ describe('e2e_slow_tree', () => { `Tries to "read" tree[${zeroProof.index}] from the tree, but is rejected as value is not ${zeroProof.value}`, ); await wallet.addCapsule(getMembershipCapsule({ ...zeroProof, value: new Fr(0) })); - await expect(contract.methods.read_at(key).simulate()).rejects.toThrowError( + await expect(contract.methods.read_at(key).simulate()).rejects.toThrow( /Assertion failed: Root does not match expected/, ); diff --git a/yarn-project/end-to-end/src/e2e_state_vars.test.ts b/yarn-project/end-to-end/src/e2e_state_vars.test.ts index 1b7327ce6a9..8aebff15752 100644 --- a/yarn-project/end-to-end/src/e2e_state_vars.test.ts +++ b/yarn-project/end-to-end/src/e2e_state_vars.test.ts @@ -37,7 +37,7 @@ describe('e2e_state_vars', () => { it('initializing SharedImmutable the second time should fail', async () => { // Jest executes the tests sequentially and the first call to initialize_shared_immutable was executed // in the previous test, so the call bellow should fail. - await expect(contract.methods.initialize_shared_immutable(1).send().wait()).rejects.toThrowError( + await expect(contract.methods.initialize_shared_immutable(1).send().wait()).rejects.toThrow( "Assertion failed: SharedImmutable already initialized 'fields_read[0] == 0'", ); }, 100_000); @@ -57,7 +57,7 @@ describe('e2e_state_vars', () => { it('initializing PublicImmutable the second time should fail', async () => { // Jest executes the tests sequentially and the first call to initialize_public_immutable was executed // in the previous test, so the call bellow should fail. - await expect(contract.methods.initialize_public_immutable(1).send().wait()).rejects.toThrowError( + await expect(contract.methods.initialize_public_immutable(1).send().wait()).rejects.toThrow( "Assertion failed: PublicImmutable already initialized 'fields_read[0] == 0'", ); }, 100_000); @@ -66,7 +66,7 @@ describe('e2e_state_vars', () => { describe('PrivateMutable', () => { it('fail to read uninitialized PrivateMutable', async () => { expect(await contract.methods.is_legendary_initialized().view()).toEqual(false); - await expect(contract.methods.get_legendary_card().view()).rejects.toThrowError(); + await expect(contract.methods.get_legendary_card().view()).rejects.toThrow(); }); it('initialize PrivateMutable', async () => { @@ -81,7 +81,7 @@ describe('e2e_state_vars', () => { it('fail to reinitialize', async () => { expect(await contract.methods.is_legendary_initialized().view()).toEqual(true); - await expect(contract.methods.initialize_private(RANDOMNESS, POINTS).send().wait()).rejects.toThrowError(); + await expect(contract.methods.initialize_private(RANDOMNESS, POINTS).send().wait()).rejects.toThrow(); expect(await contract.methods.is_legendary_initialized().view()).toEqual(true); }); @@ -150,7 +150,7 @@ describe('e2e_state_vars', () => { describe('PrivateImmutable', () => { it('fail to read uninitialized PrivateImmutable', async () => { expect(await contract.methods.is_priv_imm_initialized().view()).toEqual(false); - await expect(contract.methods.view_imm_card().view()).rejects.toThrowError(); + await expect(contract.methods.view_imm_card().view()).rejects.toThrow(); }); it('initialize PrivateImmutable', async () => { @@ -168,9 +168,7 @@ describe('e2e_state_vars', () => { it('fail to reinitialize', async () => { expect(await contract.methods.is_priv_imm_initialized().view()).toEqual(true); - await expect( - contract.methods.initialize_private_immutable(RANDOMNESS, POINTS).send().wait(), - ).rejects.toThrowError(); + await expect(contract.methods.initialize_private_immutable(RANDOMNESS, POINTS).send().wait()).rejects.toThrow(); expect(await contract.methods.is_priv_imm_initialized().view()).toEqual(true); }); diff --git a/yarn-project/end-to-end/src/e2e_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_token_contract.test.ts index 4cfb50b756c..742a91b4be5 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract.test.ts @@ -123,9 +123,9 @@ describe('e2e_token_contract', () => { await reader.methods.check_symbol_private(asset.address, TOKEN_SYMBOL).send().wait(); - await expect( - reader.methods.check_symbol_private(asset.address, 'WRONG_SYMBOL').simulate(), - ).rejects.toThrowError("Cannot satisfy constraint 'symbol.is_eq(_what)'"); + await expect(reader.methods.check_symbol_private(asset.address, 'WRONG_SYMBOL').simulate()).rejects.toThrow( + "Cannot satisfy constraint 'symbol.is_eq(_what)'", + ); }); it('public', async () => { const t = toString(await asset.methods.un_get_symbol().view()); @@ -133,7 +133,7 @@ describe('e2e_token_contract', () => { await reader.methods.check_symbol_public(asset.address, TOKEN_SYMBOL).send().wait(); - await expect(reader.methods.check_symbol_public(asset.address, 'WRONG_SYMBOL').simulate()).rejects.toThrowError( + await expect(reader.methods.check_symbol_public(asset.address, 'WRONG_SYMBOL').simulate()).rejects.toThrow( "Failed to solve brillig function, reason: explicit trap hit in brillig 'symbol.is_eq(_what)'", ); }); @@ -146,7 +146,7 @@ describe('e2e_token_contract', () => { await reader.methods.check_decimals_private(asset.address, TOKEN_DECIMALS).send().wait(); - await expect(reader.methods.check_decimals_private(asset.address, 99).simulate()).rejects.toThrowError( + await expect(reader.methods.check_decimals_private(asset.address, 99).simulate()).rejects.toThrow( "Cannot satisfy constraint 'ret[0] as u8 == what'", ); }); @@ -157,7 +157,7 @@ describe('e2e_token_contract', () => { await reader.methods.check_decimals_public(asset.address, TOKEN_DECIMALS).send().wait(); - await expect(reader.methods.check_decimals_public(asset.address, 99).simulate()).rejects.toThrowError( + await expect(reader.methods.check_decimals_public(asset.address, 99).simulate()).rejects.toThrow( "Failed to solve brillig function, reason: explicit trap hit in brillig 'ret[0] as u8 == what'", ); }); @@ -182,12 +182,12 @@ describe('e2e_token_contract', () => { describe('failure cases', () => { it('Set admin (not admin)', async () => { - await expect(asset.methods.set_admin(accounts[0].address).simulate()).rejects.toThrowError( + await expect(asset.methods.set_admin(accounts[0].address).simulate()).rejects.toThrow( 'Assertion failed: caller is not admin', ); }); it('Revoke minter not as admin', async () => { - await expect(asset.methods.set_minter(accounts[0].address, false).simulate()).rejects.toThrowError( + await expect(asset.methods.set_minter(accounts[0].address, false).simulate()).rejects.toThrow( 'Assertion failed: caller is not admin', ); }); @@ -212,26 +212,26 @@ describe('e2e_token_contract', () => { const amount = 10000n; await expect( asset.withWallet(wallets[1]).methods.mint_public(accounts[0].address, amount).simulate(), - ).rejects.toThrowError('Assertion failed: caller is not minter'); + ).rejects.toThrow('Assertion failed: caller is not minter'); }); it('mint >u128 tokens to overflow', async () => { const amount = 2n ** 128n; // U128::max() + 1; - await expect(asset.methods.mint_public(accounts[0].address, amount).simulate()).rejects.toThrowError( + await expect(asset.methods.mint_public(accounts[0].address, amount).simulate()).rejects.toThrow( BITSIZE_TOO_BIG_ERROR, ); }); it('mint u128', async () => { const amount = 2n ** 128n - tokenSim.balanceOfPublic(accounts[0].address); - await expect(asset.methods.mint_public(accounts[0].address, amount).simulate()).rejects.toThrowError( + await expect(asset.methods.mint_public(accounts[0].address, amount).simulate()).rejects.toThrow( U128_OVERFLOW_ERROR, ); }); it('mint u128', async () => { const amount = 2n ** 128n - tokenSim.balanceOfPublic(accounts[0].address); - await expect(asset.methods.mint_public(accounts[1].address, amount).simulate()).rejects.toThrowError( + await expect(asset.methods.mint_public(accounts[1].address, amount).simulate()).rejects.toThrow( U128_OVERFLOW_ERROR, ); }); @@ -271,23 +271,23 @@ describe('e2e_token_contract', () => { describe('failure cases', () => { it('try to redeem as recipient (double-spend) [REVERTS]', async () => { - await expect(addPendingShieldNoteToPXE(0, amount, secretHash, txHash)).rejects.toThrowError( + await expect(addPendingShieldNoteToPXE(0, amount, secretHash, txHash)).rejects.toThrow( 'The note has been destroyed.', ); - await expect( - asset.methods.redeem_shield(accounts[0].address, amount, secret).simulate(), - ).rejects.toThrowError('Can only remove a note that has been read from the set.'); + await expect(asset.methods.redeem_shield(accounts[0].address, amount, secret).simulate()).rejects.toThrow( + 'Can only remove a note that has been read from the set.', + ); }); it('mint_private as non-minter', async () => { await expect( asset.withWallet(wallets[1]).methods.mint_private(amount, secretHash).simulate(), - ).rejects.toThrowError('Assertion failed: caller is not minter'); + ).rejects.toThrow('Assertion failed: caller is not minter'); }); it('mint >u128 tokens to overflow', async () => { const amount = 2n ** 128n; // U128::max() + 1; - await expect(asset.methods.mint_private(amount, secretHash).simulate()).rejects.toThrowError( + await expect(asset.methods.mint_private(amount, secretHash).simulate()).rejects.toThrow( BITSIZE_TOO_BIG_ERROR, ); }); @@ -295,16 +295,12 @@ describe('e2e_token_contract', () => { it('mint u128', async () => { const amount = 2n ** 128n - tokenSim.balanceOfPrivate(accounts[0].address); expect(amount).toBeLessThan(2n ** 128n); - await expect(asset.methods.mint_private(amount, secretHash).simulate()).rejects.toThrowError( - U128_OVERFLOW_ERROR, - ); + await expect(asset.methods.mint_private(amount, secretHash).simulate()).rejects.toThrow(U128_OVERFLOW_ERROR); }); it('mint u128', async () => { const amount = 2n ** 128n - tokenSim.totalSupply; - await expect(asset.methods.mint_private(amount, secretHash).simulate()).rejects.toThrowError( - U128_OVERFLOW_ERROR, - ); + await expect(asset.methods.mint_private(amount, secretHash).simulate()).rejects.toThrow(U128_OVERFLOW_ERROR); }); }); }); @@ -355,7 +351,7 @@ describe('e2e_token_contract', () => { .withWallet(wallets[1]) .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce) .send(); - await expect(txReplay.wait()).rejects.toThrowError('Transaction '); + await expect(txReplay.wait()).rejects.toThrow('Transaction '); }); describe('failure cases', () => { @@ -365,7 +361,7 @@ describe('e2e_token_contract', () => { const nonce = 0; await expect( asset.methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce).simulate(), - ).rejects.toThrowError(U128_UNDERFLOW_ERROR); + ).rejects.toThrow(U128_UNDERFLOW_ERROR); }); it('transfer on behalf of self with non-zero nonce', async () => { @@ -374,7 +370,7 @@ describe('e2e_token_contract', () => { const nonce = 1; await expect( asset.methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce).simulate(), - ).rejects.toThrowError('Assertion failed: invalid nonce'); + ).rejects.toThrow('Assertion failed: invalid nonce'); }); it('transfer on behalf of other without "approval"', async () => { @@ -386,7 +382,7 @@ describe('e2e_token_contract', () => { .withWallet(wallets[1]) .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce) .simulate(), - ).rejects.toThrowError('Assertion failed: Message not authorized by account'); + ).rejects.toThrow('Assertion failed: Message not authorized by account'); }); it('transfer more than balance on behalf of other', async () => { @@ -405,7 +401,7 @@ describe('e2e_token_contract', () => { await wallets[0].setPublicAuth(messageHash, true).send().wait(); // Perform the transfer - await expect(action.simulate()).rejects.toThrowError(U128_UNDERFLOW_ERROR); + await expect(action.simulate()).rejects.toThrow(U128_UNDERFLOW_ERROR); expect(await asset.methods.balance_of_public(accounts[0].address).view()).toEqual(balance0); expect(await asset.methods.balance_of_public(accounts[1].address).view()).toEqual(balance1); @@ -427,7 +423,7 @@ describe('e2e_token_contract', () => { await wallets[0].setPublicAuth(messageHash, true).send().wait(); // Perform the transfer - await expect(action.simulate()).rejects.toThrowError('Assertion failed: Message not authorized by account'); + await expect(action.simulate()).rejects.toThrow('Assertion failed: Message not authorized by account'); expect(await asset.methods.balance_of_public(accounts[0].address).view()).toEqual(balance0); expect(await asset.methods.balance_of_public(accounts[1].address).view()).toEqual(balance1); @@ -448,7 +444,7 @@ describe('e2e_token_contract', () => { await wallets[0].setPublicAuth(messageHash, true).send().wait(); // Perform the transfer - await expect(action.simulate()).rejects.toThrowError('Assertion failed: Message not authorized by account'); + await expect(action.simulate()).rejects.toThrow('Assertion failed: Message not authorized by account'); expect(await asset.methods.balance_of_public(accounts[0].address).view()).toEqual(balance0); expect(await asset.methods.balance_of_public(accounts[1].address).view()).toEqual(balance1); @@ -474,7 +470,7 @@ describe('e2e_token_contract', () => { .withWallet(wallets[1]) .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce) .send(); - await expect(txCancelledAuthwit.wait()).rejects.toThrowError('Transaction '); + await expect(txCancelledAuthwit.wait()).rejects.toThrow('Transaction '); }); it('transfer on behalf of other, invalid spend_public_authwit on "from"', async () => { @@ -485,7 +481,7 @@ describe('e2e_token_contract', () => { .withWallet(wallets[1]) .methods.transfer_public(badAccount.address, accounts[1].address, 0, nonce) .send(); - await expect(txCancelledAuthwit.wait()).rejects.toThrowError( + await expect(txCancelledAuthwit.wait()).rejects.toThrow( "Assertion failed: Message not authorized by account 'result == IS_VALID_SELECTOR'", ); }); @@ -544,7 +540,7 @@ describe('e2e_token_contract', () => { .withWallet(wallets[1]) .methods.transfer(accounts[0].address, accounts[1].address, amount, nonce) .send(); - await expect(txReplay.wait()).rejects.toThrowError('Transaction '); + await expect(txReplay.wait()).rejects.toThrow('Transaction '); }); describe('failure cases', () => { @@ -554,7 +550,7 @@ describe('e2e_token_contract', () => { expect(amount).toBeGreaterThan(0n); await expect( asset.methods.transfer(accounts[0].address, accounts[1].address, amount, 0).simulate(), - ).rejects.toThrowError('Assertion failed: Balance too low'); + ).rejects.toThrow('Assertion failed: Balance too low'); }); it('transfer on behalf of self with non-zero nonce', async () => { @@ -563,7 +559,7 @@ describe('e2e_token_contract', () => { expect(amount).toBeGreaterThan(0n); await expect( asset.methods.transfer(accounts[0].address, accounts[1].address, amount, 1).simulate(), - ).rejects.toThrowError('Assertion failed: invalid nonce'); + ).rejects.toThrow('Assertion failed: invalid nonce'); }); it('transfer more than balance on behalf of other', async () => { @@ -586,7 +582,7 @@ describe('e2e_token_contract', () => { await wallets[1].addAuthWitness(witness); // Perform the transfer - await expect(action.simulate()).rejects.toThrowError('Assertion failed: Balance too low'); + await expect(action.simulate()).rejects.toThrow('Assertion failed: Balance too low'); expect(await asset.methods.balance_of_private(accounts[0].address).view()).toEqual(balance0); expect(await asset.methods.balance_of_private(accounts[1].address).view()).toEqual(balance1); }); @@ -610,7 +606,7 @@ describe('e2e_token_contract', () => { .methods.transfer(accounts[0].address, accounts[1].address, amount, nonce); const messageHash = computeAuthWitMessageHash(accounts[1].address, action.request()); - await expect(action.simulate()).rejects.toThrowError( + await expect(action.simulate()).rejects.toThrow( `Unknown auth witness for message hash ${messageHash.toString()}`, ); }); @@ -631,7 +627,7 @@ describe('e2e_token_contract', () => { const witness = await wallets[0].createAuthWitness(messageHash); await wallets[2].addAuthWitness(witness); - await expect(action.simulate()).rejects.toThrowError( + await expect(action.simulate()).rejects.toThrow( `Unknown auth witness for message hash ${expectedMessageHash.toString()}`, ); expect(await asset.methods.balance_of_private(accounts[0].address).view()).toEqual(balance0); @@ -659,7 +655,7 @@ describe('e2e_token_contract', () => { .withWallet(wallets[1]) .methods.transfer(accounts[0].address, accounts[1].address, amount, nonce) .send(); - await expect(txCancelledAuthwit.wait()).rejects.toThrowError('Transaction '); + await expect(txCancelledAuthwit.wait()).rejects.toThrow('Transaction '); }); it('transfer on behalf of other, invalid spend_private_authwit on "from"', async () => { @@ -670,7 +666,7 @@ describe('e2e_token_contract', () => { .withWallet(wallets[1]) .methods.transfer(badAccount.address, accounts[1].address, 0, nonce) .send(); - await expect(txCancelledAuthwit.wait()).rejects.toThrowError( + await expect(txCancelledAuthwit.wait()).rejects.toThrow( "Assertion failed: Message not authorized by account 'result == IS_VALID_SELECTOR'", ); }); @@ -724,7 +720,7 @@ describe('e2e_token_contract', () => { .withWallet(wallets[1]) .methods.shield(accounts[0].address, amount, secretHash, nonce) .send(); - await expect(txReplay.wait()).rejects.toThrowError('Transaction '); + await expect(txReplay.wait()).rejects.toThrow('Transaction '); // Redeem it await addPendingShieldNoteToPXE(0, amount, secretHash, receipt.txHash); @@ -739,7 +735,7 @@ describe('e2e_token_contract', () => { const amount = balancePub + 1n; expect(amount).toBeGreaterThan(0n); - await expect(asset.methods.shield(accounts[0].address, amount, secretHash, 0).simulate()).rejects.toThrowError( + await expect(asset.methods.shield(accounts[0].address, amount, secretHash, 0).simulate()).rejects.toThrow( U128_UNDERFLOW_ERROR, ); }); @@ -749,7 +745,7 @@ describe('e2e_token_contract', () => { const amount = balancePub + 1n; expect(amount).toBeGreaterThan(0n); - await expect(asset.methods.shield(accounts[0].address, amount, secretHash, 1).simulate()).rejects.toThrowError( + await expect(asset.methods.shield(accounts[0].address, amount, secretHash, 1).simulate()).rejects.toThrow( 'Assertion failed: invalid nonce', ); }); @@ -765,7 +761,7 @@ describe('e2e_token_contract', () => { const messageHash = computeAuthWitMessageHash(accounts[1].address, action.request()); await wallets[0].setPublicAuth(messageHash, true).send().wait(); - await expect(action.simulate()).rejects.toThrowError(U128_UNDERFLOW_ERROR); + await expect(action.simulate()).rejects.toThrow(U128_UNDERFLOW_ERROR); }); it('on behalf of other (wrong designated caller)', async () => { @@ -779,7 +775,7 @@ describe('e2e_token_contract', () => { const messageHash = computeAuthWitMessageHash(accounts[1].address, action.request()); await wallets[0].setPublicAuth(messageHash, true).send().wait(); - await expect(action.simulate()).rejects.toThrowError('Assertion failed: Message not authorized by account'); + await expect(action.simulate()).rejects.toThrow('Assertion failed: Message not authorized by account'); }); it('on behalf of other (without approval)', async () => { @@ -790,7 +786,7 @@ describe('e2e_token_contract', () => { await expect( asset.withWallet(wallets[1]).methods.shield(accounts[0].address, amount, secretHash, nonce).simulate(), - ).rejects.toThrowError(`Assertion failed: Message not authorized by account`); + ).rejects.toThrow(`Assertion failed: Message not authorized by account`); }); }); }); @@ -832,7 +828,7 @@ describe('e2e_token_contract', () => { .withWallet(wallets[1]) .methods.unshield(accounts[0].address, accounts[1].address, amount, nonce) .send(); - await expect(txReplay.wait()).rejects.toThrowError('Transaction '); + await expect(txReplay.wait()).rejects.toThrow('Transaction '); }); describe('failure cases', () => { @@ -843,7 +839,7 @@ describe('e2e_token_contract', () => { await expect( asset.methods.unshield(accounts[0].address, accounts[0].address, amount, 0).simulate(), - ).rejects.toThrowError('Assertion failed: Balance too low'); + ).rejects.toThrow('Assertion failed: Balance too low'); }); it('on behalf of self (invalid nonce)', async () => { @@ -853,7 +849,7 @@ describe('e2e_token_contract', () => { await expect( asset.methods.unshield(accounts[0].address, accounts[0].address, amount, 1).simulate(), - ).rejects.toThrowError('Assertion failed: invalid nonce'); + ).rejects.toThrow('Assertion failed: invalid nonce'); }); it('on behalf of other (more than balance)', async () => { @@ -874,7 +870,7 @@ describe('e2e_token_contract', () => { const witness = await wallets[0].createAuthWitness(messageHash); await wallets[1].addAuthWitness(witness); - await expect(action.simulate()).rejects.toThrowError('Assertion failed: Balance too low'); + await expect(action.simulate()).rejects.toThrow('Assertion failed: Balance too low'); }); it('on behalf of other (invalid designated caller)', async () => { @@ -896,7 +892,7 @@ describe('e2e_token_contract', () => { const witness = await wallets[0].createAuthWitness(messageHash); await wallets[2].addAuthWitness(witness); - await expect(action.simulate()).rejects.toThrowError( + await expect(action.simulate()).rejects.toThrow( `Unknown auth witness for message hash ${expectedMessageHash.toString()}`, ); }); @@ -931,7 +927,7 @@ describe('e2e_token_contract', () => { // Check that the message hash is no longer valid. Need to try to send since nullifiers are handled by sequencer. const txReplay = asset.withWallet(wallets[1]).methods.burn_public(accounts[0].address, amount, nonce).send(); - await expect(txReplay.wait()).rejects.toThrowError('Transaction '); + await expect(txReplay.wait()).rejects.toThrow('Transaction '); }); describe('failure cases', () => { @@ -939,7 +935,7 @@ describe('e2e_token_contract', () => { const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance0 + 1n; const nonce = 0; - await expect(asset.methods.burn_public(accounts[0].address, amount, nonce).simulate()).rejects.toThrowError( + await expect(asset.methods.burn_public(accounts[0].address, amount, nonce).simulate()).rejects.toThrow( U128_UNDERFLOW_ERROR, ); }); @@ -949,7 +945,7 @@ describe('e2e_token_contract', () => { const amount = balance0 - 1n; expect(amount).toBeGreaterThan(0n); const nonce = 1; - await expect(asset.methods.burn_public(accounts[0].address, amount, nonce).simulate()).rejects.toThrowError( + await expect(asset.methods.burn_public(accounts[0].address, amount, nonce).simulate()).rejects.toThrow( 'Assertion failed: invalid nonce', ); }); @@ -960,7 +956,7 @@ describe('e2e_token_contract', () => { const nonce = Fr.random(); await expect( asset.withWallet(wallets[1]).methods.burn_public(accounts[0].address, amount, nonce).simulate(), - ).rejects.toThrowError('Assertion failed: Message not authorized by account'); + ).rejects.toThrow('Assertion failed: Message not authorized by account'); }); it('burn more than balance on behalf of other', async () => { @@ -974,7 +970,7 @@ describe('e2e_token_contract', () => { const messageHash = computeAuthWitMessageHash(accounts[1].address, action.request()); await wallets[0].setPublicAuth(messageHash, true).send().wait(); - await expect(action.simulate()).rejects.toThrowError(U128_UNDERFLOW_ERROR); + await expect(action.simulate()).rejects.toThrow(U128_UNDERFLOW_ERROR); }); it('burn on behalf of other, wrong designated caller', async () => { @@ -990,7 +986,7 @@ describe('e2e_token_contract', () => { await expect( asset.withWallet(wallets[1]).methods.burn_public(accounts[0].address, amount, nonce).simulate(), - ).rejects.toThrowError('Assertion failed: Message not authorized by account'); + ).rejects.toThrow('Assertion failed: Message not authorized by account'); }); }); }); @@ -1025,7 +1021,7 @@ describe('e2e_token_contract', () => { // Perform the transfer again, should fail const txReplay = asset.withWallet(wallets[1]).methods.burn(accounts[0].address, amount, nonce).send(); - await expect(txReplay.wait()).rejects.toThrowError('Transaction '); + await expect(txReplay.wait()).rejects.toThrow('Transaction '); }); describe('failure cases', () => { @@ -1033,7 +1029,7 @@ describe('e2e_token_contract', () => { const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balance0 + 1n; expect(amount).toBeGreaterThan(0n); - await expect(asset.methods.burn(accounts[0].address, amount, 0).simulate()).rejects.toThrowError( + await expect(asset.methods.burn(accounts[0].address, amount, 0).simulate()).rejects.toThrow( 'Assertion failed: Balance too low', ); }); @@ -1042,7 +1038,7 @@ describe('e2e_token_contract', () => { const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balance0 - 1n; expect(amount).toBeGreaterThan(0n); - await expect(asset.methods.burn(accounts[0].address, amount, 1).simulate()).rejects.toThrowError( + await expect(asset.methods.burn(accounts[0].address, amount, 1).simulate()).rejects.toThrow( 'Assertion failed: invalid nonce', ); }); @@ -1063,7 +1059,7 @@ describe('e2e_token_contract', () => { const witness = await wallets[0].createAuthWitness(messageHash); await wallets[1].addAuthWitness(witness); - await expect(action.simulate()).rejects.toThrowError('Assertion failed: Balance too low'); + await expect(action.simulate()).rejects.toThrow('Assertion failed: Balance too low'); }); it('burn on behalf of other without approval', async () => { @@ -1076,7 +1072,7 @@ describe('e2e_token_contract', () => { const action = asset.withWallet(wallets[1]).methods.burn(accounts[0].address, amount, nonce); const messageHash = computeAuthWitMessageHash(accounts[1].address, action.request()); - await expect(action.simulate()).rejects.toThrowError( + await expect(action.simulate()).rejects.toThrow( `Unknown auth witness for message hash ${messageHash.toString()}`, ); }); @@ -1095,7 +1091,7 @@ describe('e2e_token_contract', () => { const witness = await wallets[0].createAuthWitness(messageHash); await wallets[2].addAuthWitness(witness); - await expect(action.simulate()).rejects.toThrowError( + await expect(action.simulate()).rejects.toThrow( `Unknown auth witness for message hash ${expectedMessageHash.toString()}`, ); }); diff --git a/yarn-project/end-to-end/src/guides/dapp_testing.test.ts b/yarn-project/end-to-end/src/guides/dapp_testing.test.ts index 34decec01e9..40e4571ae94 100644 --- a/yarn-project/end-to-end/src/guides/dapp_testing.test.ts +++ b/yarn-project/end-to-end/src/guides/dapp_testing.test.ts @@ -219,14 +219,14 @@ describe('guides/dapp/testing', () => { it('asserts a local transaction simulation fails by calling simulate', async () => { // docs:start:local-tx-fails const call = token.methods.transfer(owner.getAddress(), recipient.getAddress(), 200n, 0); - await expect(call.simulate()).rejects.toThrowError(/Balance too low/); + await expect(call.simulate()).rejects.toThrow(/Balance too low/); // docs:end:local-tx-fails }, 30_000); it('asserts a local transaction simulation fails by calling send', async () => { // docs:start:local-tx-fails-send const call = token.methods.transfer(owner.getAddress(), recipient.getAddress(), 200n, 0); - await expect(call.send().wait()).rejects.toThrowError(/Balance too low/); + await expect(call.send().wait()).rejects.toThrow(/Balance too low/); // docs:end:local-tx-fails-send }, 30_000); @@ -239,14 +239,14 @@ describe('guides/dapp/testing', () => { await call2.simulate(); await call1.send().wait(); - await expect(call2.send().wait()).rejects.toThrowError(/dropped/); + await expect(call2.send().wait()).rejects.toThrow(/dropped/); // docs:end:tx-dropped }, 30_000); it('asserts a simulation for a public function call fails', async () => { // docs:start:local-pub-fails const call = token.methods.transfer_public(owner.getAddress(), recipient.getAddress(), 1000n, 0); - await expect(call.simulate()).rejects.toThrowError(U128_UNDERFLOW_ERROR); + await expect(call.simulate()).rejects.toThrow(U128_UNDERFLOW_ERROR); // docs:end:local-pub-fails }, 30_000); diff --git a/yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts b/yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts index e8030397e6b..740006650e5 100644 --- a/yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts +++ b/yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts @@ -475,7 +475,7 @@ export const uniswapL1L2TestSuite = ( ownerEthAddress, ) .simulate(), - ).rejects.toThrowError(`Unknown auth witness for message hash ${expectedMessageHash.toString()}`); + ).rejects.toThrow(`Unknown auth witness for message hash ${expectedMessageHash.toString()}`); }); it("can't swap if user passes a token different to what the bridge tracks", async () => { @@ -513,7 +513,7 @@ export const uniswapL1L2TestSuite = ( ownerEthAddress, ) .simulate(), - ).rejects.toThrowError('Assertion failed: input_asset address is not the same as seen in the bridge contract'); + ).rejects.toThrow('Assertion failed: input_asset address is not the same as seen in the bridge contract'); }); // edge cases for public flow: @@ -614,7 +614,7 @@ export const uniswapL1L2TestSuite = ( Fr.ZERO, ) .simulate(), - ).rejects.toThrowError(`Assertion failed: Message not authorized by account 'is_valid == true'`); + ).rejects.toThrow(`Assertion failed: Message not authorized by account 'is_valid == true'`); }); // tests when trying to mix private and public flows: @@ -676,7 +676,7 @@ export const uniswapL1L2TestSuite = ( uniswapPortal.simulate.swapPublic(swapArgs, { account: ownerEthAddress.toString(), } as any), - ).rejects.toThrowError('The contract function "swapPublic" reverted.'); + ).rejects.toThrow('The contract function "swapPublic" reverted.'); }); it("can't call swap_private on L1 if called swap_public on L2", async () => { @@ -731,7 +731,7 @@ export const uniswapL1L2TestSuite = ( uniswapPortal.simulate.swapPrivate(swapArgs, { account: ownerEthAddress.toString(), } as any), - ).rejects.toThrowError('The contract function "swapPrivate" reverted.'); + ).rejects.toThrow('The contract function "swapPrivate" reverted.'); }); }); }; diff --git a/yarn-project/foundation/src/abi/encoder.test.ts b/yarn-project/foundation/src/abi/encoder.test.ts index a85c2454236..a234bc04758 100644 --- a/yarn-project/foundation/src/abi/encoder.test.ts +++ b/yarn-project/foundation/src/abi/encoder.test.ts @@ -161,7 +161,7 @@ describe('abi/encoder', () => { }; const args = ['garbage']; - expect(() => encodeArguments(testFunctionAbi, args)).toThrowError('Invalid argument "garbage" of type field'); + expect(() => encodeArguments(testFunctionAbi, args)).toThrow('Invalid argument "garbage" of type field'); }); it('throws when passing string argument as integer', () => { @@ -184,7 +184,7 @@ describe('abi/encoder', () => { returnTypes: [], }; const args = ['garbage']; - expect(() => encodeArguments(testFunctionAbi, args)).toThrowError( + expect(() => encodeArguments(testFunctionAbi, args)).toThrow( `Type 'string' with value 'garbage' passed to BaseField ctor.`, ); }); @@ -212,8 +212,6 @@ describe('abi/encoder', () => { }, ]; - expect(() => encodeArguments(testFunctionAbi, args)).toThrowError( - 'Argument for owner cannot be serialized to a field', - ); + expect(() => encodeArguments(testFunctionAbi, args)).toThrow('Argument for owner cannot be serialized to a field'); }); }); diff --git a/yarn-project/foundation/src/bigint-buffer/bigint-buffer.test.ts b/yarn-project/foundation/src/bigint-buffer/bigint-buffer.test.ts index 6280eca4753..474c26fffb7 100644 --- a/yarn-project/foundation/src/bigint-buffer/bigint-buffer.test.ts +++ b/yarn-project/foundation/src/bigint-buffer/bigint-buffer.test.ts @@ -36,12 +36,12 @@ describe('bigint-buffer', () => { it('should throw an error for an invalid hex string', () => { const invalidHexString = '0x12345G'; - expect(() => fromHex(invalidHexString)).toThrowError('Invalid hex string: 0x12345G'); + expect(() => fromHex(invalidHexString)).toThrow('Invalid hex string: 0x12345G'); }); it('should throw an error for an odd-length hex string', () => { const oddLengthHexString = '0x1234567'; - expect(() => fromHex(oddLengthHexString)).toThrowError('Invalid hex string: 0x1234567'); + expect(() => fromHex(oddLengthHexString)).toThrow('Invalid hex string: 0x1234567'); }); it('should handle an empty hex string', () => { diff --git a/yarn-project/foundation/src/fields/fields.test.ts b/yarn-project/foundation/src/fields/fields.test.ts index 6095eb1c310..ff94978f0d1 100644 --- a/yarn-project/foundation/src/fields/fields.test.ts +++ b/yarn-project/foundation/src/fields/fields.test.ts @@ -168,7 +168,7 @@ describe('Bn254 arithmetic', () => { const a = new Fr(10); const b = Fr.ZERO; - expect(() => a.div(b)).toThrowError(); + expect(() => a.div(b)).toThrow(); }); }); diff --git a/yarn-project/foundation/src/json-rpc/convert.test.ts b/yarn-project/foundation/src/json-rpc/convert.test.ts index ba5eeaa9f98..25c8be3e1a8 100644 --- a/yarn-project/foundation/src/json-rpc/convert.test.ts +++ b/yarn-project/foundation/src/json-rpc/convert.test.ts @@ -67,11 +67,11 @@ it('converts a plain object', () => { it('refuses to convert to json an unknown class', () => { const cc = new ClassConverter(); - expect(() => convertToJsonObj(cc, { content: new ToStringClassA('a', 'b') })).toThrowError(/not registered/); + expect(() => convertToJsonObj(cc, { content: new ToStringClassA('a', 'b') })).toThrow(/not registered/); }); it('refuses to convert from json an unknown class', () => { const cc = new ClassConverter({ ToStringClass: ToStringClassA }); const serialized = convertToJsonObj(cc, { content: new ToStringClassA('a', 'b') }); - expect(() => convertFromJsonObj(new ClassConverter(), serialized)).toThrowError(/not registered/); + expect(() => convertFromJsonObj(new ClassConverter(), serialized)).toThrow(/not registered/); }); diff --git a/yarn-project/pxe/src/pxe_service/test/pxe_service.test.ts b/yarn-project/pxe/src/pxe_service/test/pxe_service.test.ts index 01588b0e3ba..57bef759a67 100644 --- a/yarn-project/pxe/src/pxe_service/test/pxe_service.test.ts +++ b/yarn-project/pxe/src/pxe_service/test/pxe_service.test.ts @@ -60,6 +60,6 @@ describe('PXEService', () => { node.getTxEffect.mockResolvedValue(settledTx); const pxe = new PXEService(keyStore, node, db, config); - await expect(pxe.sendTx(duplicateTx)).rejects.toThrowError(/A settled tx with equal hash/); + await expect(pxe.sendTx(duplicateTx)).rejects.toThrow(/A settled tx with equal hash/); }); }); diff --git a/yarn-project/simulator/src/avm/journal/nullifiers.test.ts b/yarn-project/simulator/src/avm/journal/nullifiers.test.ts index 81725755a6b..5a459823acc 100644 --- a/yarn-project/simulator/src/avm/journal/nullifiers.test.ts +++ b/yarn-project/simulator/src/avm/journal/nullifiers.test.ts @@ -74,7 +74,7 @@ describe('avm nullifier caching', () => { // Append a nullifier to cache await nullifiers.append(contractAddress, nullifier); // Can't append again - await expect(nullifiers.append(contractAddress, nullifier)).rejects.toThrowError( + await expect(nullifiers.append(contractAddress, nullifier)).rejects.toThrow( `Nullifier ${nullifier} at contract ${contractAddress} already exists in parent cache or host.`, ); }); @@ -86,7 +86,7 @@ describe('avm nullifier caching', () => { await nullifiers.append(contractAddress, nullifier); const childNullifiers = new Nullifiers(commitmentsDb, nullifiers); // Can't append again in child - await expect(childNullifiers.append(contractAddress, nullifier)).rejects.toThrowError( + await expect(childNullifiers.append(contractAddress, nullifier)).rejects.toThrow( `Nullifier ${nullifier} at contract ${contractAddress} already exists in parent cache or host.`, ); }); @@ -98,7 +98,7 @@ describe('avm nullifier caching', () => { // Nullifier exists in host commitmentsDb.getNullifierIndex.mockResolvedValue(Promise.resolve(storedLeafIndex)); // Can't append to cache - await expect(nullifiers.append(contractAddress, nullifier)).rejects.toThrowError( + await expect(nullifiers.append(contractAddress, nullifier)).rejects.toThrow( `Nullifier ${nullifier} at contract ${contractAddress} already exists in parent cache or host.`, ); }); @@ -139,7 +139,7 @@ describe('avm nullifier caching', () => { await childNullifiers.append(contractAddress, nullifier); // Parent accepts child's nullifiers - expect(() => nullifiers.acceptAndMerge(childNullifiers)).toThrowError( + expect(() => nullifiers.acceptAndMerge(childNullifiers)).toThrow( `Failed to accept child call's nullifiers. Nullifier ${nullifier.toBigInt()} already exists at contract ${contractAddress.toBigInt()}.`, ); }); diff --git a/yarn-project/simulator/src/avm/opcodes/accrued_substate.test.ts b/yarn-project/simulator/src/avm/opcodes/accrued_substate.test.ts index 41470dc95e5..3976c805a04 100644 --- a/yarn-project/simulator/src/avm/opcodes/accrued_substate.test.ts +++ b/yarn-project/simulator/src/avm/opcodes/accrued_substate.test.ts @@ -252,7 +252,7 @@ describe('Accrued Substate', () => { context.machineState.memory.set(0, value); await new EmitNullifier(/*indirect=*/ 0, /*offset=*/ 0).execute(context); - await expect(new EmitNullifier(/*indirect=*/ 0, /*offset=*/ 0).execute(context)).rejects.toThrowError( + await expect(new EmitNullifier(/*indirect=*/ 0, /*offset=*/ 0).execute(context)).rejects.toThrow( new InstructionExecutionError( `Attempted to emit duplicate nullifier ${value.toFr()} (storage address: ${ context.environment.storageAddress @@ -272,7 +272,7 @@ describe('Accrued Substate', () => { context = initContext({ persistableState: new AvmPersistableStateManager(hostStorage) }); context.machineState.memory.set(0, value); - await expect(new EmitNullifier(/*indirect=*/ 0, /*offset=*/ 0).execute(context)).rejects.toThrowError( + await expect(new EmitNullifier(/*indirect=*/ 0, /*offset=*/ 0).execute(context)).rejects.toThrow( new InstructionExecutionError( `Attempted to emit duplicate nullifier ${value.toFr()} (storage address: ${ context.environment.storageAddress diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index f2a0f1e8ccf..2abe169627f 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -603,7 +603,7 @@ describe('Private Execution test suite', () => { portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, txContext: { version: new Fr(1n), chainId: new Fr(1n) }, }), - ).rejects.toThrowError('Message not in state'); + ).rejects.toThrow('Message not in state'); }); it('Invalid recipient', async () => { @@ -625,7 +625,7 @@ describe('Private Execution test suite', () => { portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, txContext: { version: new Fr(1n), chainId: new Fr(1n) }, }), - ).rejects.toThrowError('Message not in state'); + ).rejects.toThrow('Message not in state'); }); it('Invalid sender', async () => { @@ -646,7 +646,7 @@ describe('Private Execution test suite', () => { portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, txContext: { version: new Fr(1n), chainId: new Fr(1n) }, }), - ).rejects.toThrowError('Message not in state'); + ).rejects.toThrow('Message not in state'); }); it('Invalid chainid', async () => { @@ -666,7 +666,7 @@ describe('Private Execution test suite', () => { portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, txContext: { version: new Fr(1n), chainId: new Fr(2n) }, }), - ).rejects.toThrowError('Message not in state'); + ).rejects.toThrow('Message not in state'); }); it('Invalid version', async () => { @@ -686,7 +686,7 @@ describe('Private Execution test suite', () => { portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, txContext: { version: new Fr(2n), chainId: new Fr(1n) }, }), - ).rejects.toThrowError('Message not in state'); + ).rejects.toThrow('Message not in state'); }); it('Invalid content', async () => { @@ -707,7 +707,7 @@ describe('Private Execution test suite', () => { portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, txContext: { version: new Fr(1n), chainId: new Fr(1n) }, }), - ).rejects.toThrowError('Message not in state'); + ).rejects.toThrow('Message not in state'); }); it('Invalid Secret', async () => { @@ -728,7 +728,7 @@ describe('Private Execution test suite', () => { portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, txContext: { version: new Fr(1n), chainId: new Fr(1n) }, }), - ).rejects.toThrowError('Message not in state'); + ).rejects.toThrow('Message not in state'); }); }); @@ -1136,7 +1136,7 @@ describe('Private Execution test suite', () => { const unexpectedChainId = Fr.random(); await expect( runSimulator({ artifact, msgSender: owner, args, txContext: { chainId: unexpectedChainId, version } }), - ).rejects.toThrowError('Invalid chain id'); + ).rejects.toThrow('Invalid chain id'); }); it('Throws when version is incorrectly set', async () => { @@ -1144,7 +1144,7 @@ describe('Private Execution test suite', () => { const unexpectedVersion = Fr.random(); await expect( runSimulator({ artifact, msgSender: owner, args, txContext: { chainId, version: unexpectedVersion } }), - ).rejects.toThrowError('Invalid version'); + ).rejects.toThrow('Invalid version'); }); }); @@ -1171,7 +1171,7 @@ describe('Private Execution test suite', () => { const unexpectedHeaderHash = Fr.random(); const args = [unexpectedHeaderHash]; - await expect(runSimulator({ artifact, msgSender: owner, args })).rejects.toThrowError('Invalid header hash'); + await expect(runSimulator({ artifact, msgSender: owner, args })).rejects.toThrow('Invalid header hash'); }); }); }); diff --git a/yarn-project/simulator/src/client/simulator.test.ts b/yarn-project/simulator/src/client/simulator.test.ts index cff1858a008..fe7e32cfdff 100644 --- a/yarn-project/simulator/src/client/simulator.test.ts +++ b/yarn-project/simulator/src/client/simulator.test.ts @@ -76,7 +76,7 @@ describe('Simulator', () => { const note = createNote(); await expect( simulator.computeNoteHashAndNullifier(contractAddress, nonce, storageSlot, noteTypeId, note), - ).rejects.toThrowError(/Mandatory implementation of "compute_note_hash_and_nullifier" missing/); + ).rejects.toThrow(/Mandatory implementation of "compute_note_hash_and_nullifier" missing/); }); it('throw if "compute_note_hash_and_nullifier" has the wrong number of parameters', async () => { @@ -90,7 +90,7 @@ describe('Simulator', () => { await expect( simulator.computeNoteHashAndNullifier(contractAddress, nonce, storageSlot, noteTypeId, note), - ).rejects.toThrowError( + ).rejects.toThrow( new RegExp( `Expected 5 parameters in mandatory implementation of "compute_note_hash_and_nullifier", but found 4 in noir contract ${contractAddress}.`, ), @@ -122,7 +122,7 @@ describe('Simulator', () => { await expect( simulator.computeNoteHashAndNullifier(contractAddress, nonce, storageSlot, noteTypeId, note), - ).rejects.toThrowError( + ).rejects.toThrow( new RegExp(`"compute_note_hash_and_nullifier" can only handle a maximum of ${wrongPreimageLength} fields`), ); });