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 f6c669c0f0d2..2bb4badb706e 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 9b4183cbba66..d2c945623f42 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 ff8c98fdc423..b9f2b78bea1f 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 c3047a267cb7..afe57420f59c 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 bcace613eeb9..8e879f762bae 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_2_pxes.test.ts b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts index aaeb216120a3..5f34262853a3 100644 --- a/yarn-project/end-to-end/src/e2e_2_pxes.test.ts +++ b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts @@ -9,7 +9,6 @@ import { GrumpkinScalar, Note, PXE, - TxStatus, Wallet, computeMessageSecretHash, retryUntil, @@ -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 @@ -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 () => { @@ -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); @@ -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([ @@ -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); 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 e3149ec793cc..90807e53ee94 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 4eef8e659b27..bb45d12f5869 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 91d1a33619a3..2d5bd054fa57 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 @@ -9,7 +9,6 @@ import { FunctionSelector, Note, TxHash, - TxStatus, Wallet, computeAuthWitMessageHash, computeMessageSecretHash, @@ -174,8 +173,7 @@ describe('e2e_blacklist_token_contract', () => { getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), false)), ); - const tx = await asset.methods.update_roles(newMinter, newRoles).send().wait(); - expect(tx.status).toBe(TxStatus.MINED); + await asset.methods.update_roles(newMinter, newRoles).send().wait(); await slowUpdateTreeSimulator.commit(); const afterLeaf = await slowTree.methods.un_read_leaf_at(asset.address, newMinter).view(); @@ -185,11 +183,6 @@ describe('e2e_blacklist_token_contract', () => { const time = await cheatCodes.eth.timestamp(); await cheatCodes.aztec.warp(time + 200); - - /* const tx = asset.withWallet(wallets[1]).methods.set_minter(accounts[1].address, true).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); - expect(await asset.methods.is_minter(accounts[1].address).view()).toBe(true);*/ }); it('Make account[1] admin', async () => { @@ -205,8 +198,7 @@ describe('e2e_blacklist_token_contract', () => { getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), false)), ); - const tx = await asset.methods.update_roles(newAdmin, newRoles).send().wait(); - expect(tx.status).toBe(TxStatus.MINED); + await asset.methods.update_roles(newAdmin, newRoles).send().wait(); await slowUpdateTreeSimulator.commit(); v = await slowTree.methods.un_read_leaf_at(asset.address, newAdmin).view(); @@ -235,8 +227,7 @@ describe('e2e_blacklist_token_contract', () => { getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), false)), ); - const tx = await asset.methods.update_roles(actor, newRoles).send().wait(); - expect(tx.status).toBe(TxStatus.MINED); + await asset.methods.update_roles(actor, newRoles).send().wait(); await slowUpdateTreeSimulator.commit(); const afterLeaf = await slowTree.methods.un_read_leaf_at(asset.address, actor).view(); @@ -246,12 +237,6 @@ describe('e2e_blacklist_token_contract', () => { const time = await cheatCodes.eth.timestamp(); await cheatCodes.aztec.warp(time + 200); - - /* - const tx = asset.withWallet(wallets[1]).methods.set_minter(accounts[1].address, false).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); - expect(await asset.methods.is_minter(accounts[1].address).view()).toBe(false);*/ }); it('Add account[3] to blacklist', async () => { @@ -264,8 +249,7 @@ describe('e2e_blacklist_token_contract', () => { getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), false)), ); - const tx = await asset.methods.update_roles(accounts[3].address, 1n).send().wait(); - expect(tx.status).toBe(TxStatus.MINED); + await asset.methods.update_roles(accounts[3].address, 1n).send().wait(); await slowUpdateTreeSimulator.commit(); v = await slowTree.methods.un_read_leaf_at(asset.address, accounts[3].address).view(); @@ -288,13 +272,9 @@ 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.methods.set_admin(accounts[0].address).simulate()).rejects.toThrowError( - 'Assertion failed: caller is not 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'", + ); }); it('Revoke minter not as admin', async () => { @@ -311,11 +291,7 @@ 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'"); - - /* await expect(asset.methods.set_minter(accounts[0].address, false).simulate()).rejects.toThrowError( - 'Assertion failed: caller is not admin', - );*/ + ).rejects.toThrow("Assertion failed: caller is not admin 'caller_roles.is_admin'"); }); }); }); @@ -324,9 +300,7 @@ describe('e2e_blacklist_token_contract', () => { describe('Public', () => { it('as minter', async () => { const amount = 10000n; - const tx = asset.methods.mint_public(accounts[0].address, amount).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.methods.mint_public(accounts[0].address, amount).send().wait(); tokenSim.mintPublic(accounts[0].address, amount); expect(await asset.methods.balance_of_public(accounts[0].address).view()).toEqual( @@ -340,26 +314,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, ); }); @@ -367,7 +341,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'"); }); }); }); @@ -384,9 +358,7 @@ describe('e2e_blacklist_token_contract', () => { describe('Mint flow', () => { it('mint_private as minter', async () => { - const tx = asset.methods.mint_private(amount, secretHash).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + const receipt = await asset.methods.mint_private(amount, secretHash).send().wait(); tokenSim.mintPrivate(amount); txHash = receipt.txHash; }); @@ -396,9 +368,10 @@ describe('e2e_blacklist_token_contract', () => { await wallets[0].addCapsule( getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true)), ); - const txClaim = asset.methods.redeem_shield(accounts[0].address, amount, secret).send(); - const receiptClaim = await txClaim.wait({ debug: true }); - expect(receiptClaim.status).toBe(TxStatus.MINED); + const receiptClaim = await asset.methods + .redeem_shield(accounts[0].address, amount, secret) + .send() + .wait({ debug: true }); tokenSim.redeemShield(accounts[0].address, amount); // 1 note should be created containing `amount` of tokens const { visibleNotes } = receiptClaim.debugInfo!; @@ -409,26 +382,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, ); }); @@ -437,25 +410,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'", + ); }); }); }); @@ -467,9 +436,7 @@ describe('e2e_blacklist_token_contract', () => { const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance0 / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods.transfer_public(accounts[0].address, accounts[1].address, amount, 0).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.methods.transfer_public(accounts[0].address, accounts[1].address, amount, 0).send().wait(); tokenSim.transferPublic(accounts[0].address, accounts[1].address, amount); }); @@ -478,9 +445,7 @@ describe('e2e_blacklist_token_contract', () => { const balance = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods.transfer_public(accounts[0].address, accounts[0].address, amount, 0).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.methods.transfer_public(accounts[0].address, accounts[0].address, amount, 0).send().wait(); tokenSim.transferPublic(accounts[0].address, accounts[0].address, amount); }); @@ -501,9 +466,7 @@ describe('e2e_blacklist_token_contract', () => { // docs:end:authwit_public_transfer_example // Perform the transfer - const tx = action.send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await action.send().wait(); tokenSim.transferPublic(accounts[0].address, accounts[1].address, amount); @@ -512,7 +475,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', () => { @@ -522,7 +485,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 () => { @@ -531,7 +494,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 () => { @@ -543,7 +506,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 () => { @@ -562,7 +525,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); @@ -584,7 +547,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); @@ -605,7 +568,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); @@ -621,13 +584,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'"); }); }); }); @@ -643,9 +606,7 @@ describe('e2e_blacklist_token_contract', () => { await wallets[0].addCapsule( getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true)), ); - const tx = asset.methods.transfer(accounts[0].address, accounts[1].address, amount, 0).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.methods.transfer(accounts[0].address, accounts[1].address, amount, 0).send().wait(); tokenSim.transferPrivate(accounts[0].address, accounts[1].address, amount); }); @@ -659,9 +620,7 @@ describe('e2e_blacklist_token_contract', () => { await wallets[0].addCapsule( getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true)), ); - const tx = asset.methods.transfer(accounts[0].address, accounts[0].address, amount, 0).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.methods.transfer(accounts[0].address, accounts[0].address, amount, 0).send().wait(); tokenSim.transferPrivate(accounts[0].address, accounts[0].address, amount); }); @@ -691,9 +650,7 @@ describe('e2e_blacklist_token_contract', () => { ); // Perform the transfer - const tx = action.send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await action.send().wait(); tokenSim.transferPrivate(accounts[0].address, accounts[1].address, amount); await wallets[1].addCapsule( @@ -708,7 +665,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', () => { @@ -724,7 +681,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 () => { @@ -739,7 +696,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 () => { @@ -768,7 +725,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); }); @@ -798,7 +755,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()}`, ); }); @@ -825,7 +782,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); @@ -840,7 +797,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 () => { @@ -852,7 +809,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'"); }); }); }); @@ -871,9 +828,7 @@ describe('e2e_blacklist_token_contract', () => { const amount = balancePub / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods.shield(accounts[0].address, amount, secretHash, 0).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + const receipt = await asset.methods.shield(accounts[0].address, amount, secretHash, 0).send().wait(); tokenSim.shield(accounts[0].address, amount); await tokenSim.check(); @@ -881,9 +836,7 @@ describe('e2e_blacklist_token_contract', () => { // Redeem it await addPendingShieldNoteToPXE(0, amount, secretHash, receipt.txHash); await wallets[0].addCapsule(getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true))); - const txClaim = asset.methods.redeem_shield(accounts[0].address, amount, secret).send(); - const receiptClaim = await txClaim.wait(); - expect(receiptClaim.status).toBe(TxStatus.MINED); + await asset.methods.redeem_shield(accounts[0].address, amount, secret).send().wait(); tokenSim.redeemShield(accounts[0].address, amount); }); @@ -899,9 +852,7 @@ describe('e2e_blacklist_token_contract', () => { const messageHash = computeAuthWitMessageHash(accounts[1].address, action.request()); await wallets[0].setPublicAuth(messageHash, true).send().wait(); - const tx = action.send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + const receipt = await action.send().wait(); tokenSim.shield(accounts[0].address, amount); await tokenSim.check(); @@ -911,14 +862,12 @@ 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); await wallets[0].addCapsule(getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true))); - const txClaim = asset.methods.redeem_shield(accounts[0].address, amount, secret).send(); - const receiptClaim = await txClaim.wait(); - expect(receiptClaim.status).toBe(TxStatus.MINED); + await asset.methods.redeem_shield(accounts[0].address, amount, secret).send().wait(); tokenSim.redeemShield(accounts[0].address, amount); }); @@ -929,7 +878,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, ); }); @@ -939,7 +888,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', ); }); @@ -955,7 +904,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 () => { @@ -969,7 +918,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 () => { @@ -980,7 +929,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 () => { @@ -989,7 +938,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'"); }); }); }); @@ -1002,9 +951,7 @@ describe('e2e_blacklist_token_contract', () => { await wallets[1].addCapsule(getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true))); await wallets[1].addCapsule(getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true))); - const tx = asset.methods.unshield(accounts[0].address, accounts[0].address, amount, 0).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.methods.unshield(accounts[0].address, accounts[0].address, amount, 0).send().wait(); tokenSim.unshield(accounts[0].address, accounts[0].address, amount); }); @@ -1029,9 +976,7 @@ describe('e2e_blacklist_token_contract', () => { const witness = await wallets[0].createAuthWitness(messageHash); await wallets[1].addAuthWitness(witness); - const tx = action.send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await action.send().wait(); tokenSim.unshield(accounts[0].address, accounts[1].address, amount); // Perform the transfer again, should fail @@ -1041,7 +986,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? }); @@ -1060,7 +1005,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 () => { @@ -1077,7 +1022,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 () => { @@ -1104,7 +1049,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 () => { @@ -1132,7 +1077,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()}`, ); }); @@ -1146,7 +1091,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 () => { @@ -1158,7 +1103,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'"); }); }); }); @@ -1169,9 +1114,7 @@ describe('e2e_blacklist_token_contract', () => { const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance0 / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods.burn_public(accounts[0].address, amount, 0).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.methods.burn_public(accounts[0].address, amount, 0).send().wait(); tokenSim.burnPublic(accounts[0].address, amount); }); @@ -1187,15 +1130,13 @@ describe('e2e_blacklist_token_contract', () => { const messageHash = computeAuthWitMessageHash(accounts[1].address, action.request()); await wallets[0].setPublicAuth(messageHash, true).send().wait(); - const tx = action.send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await action.send().wait(); tokenSim.burnPublic(accounts[0].address, amount); // 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', () => { @@ -1203,7 +1144,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, ); }); @@ -1213,7 +1154,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', ); }); @@ -1224,7 +1165,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 () => { @@ -1238,7 +1179,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 () => { @@ -1254,11 +1195,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'", ); }); @@ -1273,9 +1214,7 @@ describe('e2e_blacklist_token_contract', () => { await wallets[0].addCapsule( getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true)), ); - const tx = asset.methods.burn(accounts[0].address, amount, 0).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.methods.burn(accounts[0].address, amount, 0).send().wait(); tokenSim.burnPrivate(accounts[0].address, amount); }); @@ -1298,9 +1237,7 @@ describe('e2e_blacklist_token_contract', () => { getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true)), ); - const tx = asset.withWallet(wallets[1]).methods.burn(accounts[0].address, amount, nonce).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.withWallet(wallets[1]).methods.burn(accounts[0].address, amount, nonce).send().wait(); tokenSim.burnPrivate(accounts[0].address, amount); // Perform the transfer again, should fail @@ -1308,7 +1245,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', () => { @@ -1319,7 +1256,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', ); }); @@ -1331,7 +1268,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', ); }); @@ -1355,7 +1292,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 () => { @@ -1371,7 +1308,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()}`, ); }); @@ -1393,7 +1330,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()}`, ); }); @@ -1402,7 +1339,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 3885495eddfb..33fb95fafec0 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 @@ -9,7 +9,6 @@ import { PXE, SentTx, TxReceipt, - TxStatus, Wallet, } from '@aztec/aztec.js'; import { times } from '@aztec/foundation/collection'; @@ -69,7 +68,6 @@ describe('e2e_block_building', () => { // Await txs to be mined and assert they are all mined on the same block const receipts = await Promise.all(txs.map(tx => tx.wait())); - expect(receipts.map(r => r.status)).toEqual(times(TX_COUNT, () => TxStatus.MINED)); expect(receipts.map(r => r.blockNumber)).toEqual(times(TX_COUNT, () => receipts[0].blockNumber)); // Assert all contracts got deployed @@ -148,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_cheat_codes.test.ts b/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts index 8e27cefbabbc..37daaf1b9b9d 100644 --- a/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts +++ b/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts @@ -6,7 +6,6 @@ import { Fr, Note, PXE, - TxStatus, Wallet, computeMessageSecretHash, } from '@aztec/aztec.js'; @@ -168,15 +167,14 @@ describe('e2e_cheat_codes', () => { expect(Number(await rollup.read.lastBlockTs())).toEqual(newTimestamp); expect(Number(await rollup.read.lastWarpedBlockTs())).toEqual(newTimestamp); - const txIsTimeEqual = contract.methods.is_time_equal(newTimestamp).send(); - const isTimeEqualReceipt = await txIsTimeEqual.wait({ interval: 0.1 }); - expect(isTimeEqualReceipt.status).toBe(TxStatus.MINED); + await contract.methods.is_time_equal(newTimestamp).send().wait({ interval: 0.1 }); // Since last rollup block was warped, txs for this rollup will have time incremented by 1 // See https://github.com/AztecProtocol/aztec-packages/issues/1614 for details - const txTimeNotEqual = contract.methods.is_time_equal(newTimestamp + 1).send(); - const isTimeNotEqualReceipt = await txTimeNotEqual.wait({ interval: 0.1 }); - expect(isTimeNotEqualReceipt.status).toBe(TxStatus.MINED); + await contract.methods + .is_time_equal(newTimestamp + 1) + .send() + .wait({ interval: 0.1 }); // block is published at t >= newTimestamp + 1. expect(Number(await rollup.read.lastBlockTs())).toBeGreaterThanOrEqual(newTimestamp + 1); }, 50_000); diff --git a/yarn-project/end-to-end/src/e2e_counter_contract.test.ts b/yarn-project/end-to-end/src/e2e_counter_contract.test.ts index f47c6ba8d203..ea4f806fb7b0 100644 --- a/yarn-project/end-to-end/src/e2e_counter_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_counter_contract.test.ts @@ -1,4 +1,4 @@ -import { AccountWallet, AztecAddress, CompleteAddress, DebugLogger, TxStatus } from '@aztec/aztec.js'; +import { AccountWallet, AztecAddress, CompleteAddress, DebugLogger } from '@aztec/aztec.js'; import { CounterContract } from '@aztec/noir-contracts.js/Counter'; import { setup } from './fixtures/utils.js'; @@ -31,8 +31,7 @@ describe('e2e_counter_contract', () => { describe('increments', () => { it('counts', async () => { - const receipt = await counterContract.methods.increment(owner).send().wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await counterContract.methods.increment(owner).send().wait(); expect(await counterContract.methods.get_counter(owner).view()).toBe(1n); }); }); diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts index 00ba5b5bb1c1..6f9652793782 100644 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts @@ -7,7 +7,6 @@ import { L1Actor, L1ToL2Message, L2Actor, - TxStatus, computeAuthWitMessageHash, } from '@aztec/aztec.js'; import { sha256 } from '@aztec/foundation/crypto'; @@ -168,12 +167,11 @@ describe('e2e_cross_chain_messaging', () => { ).rejects.toThrow(`L1 to L2 message index not found in the store for message ${wrongMessage.hash().toString()}`); // send the right one - - const consumptionTx = l2Bridge + const consumptionReceipt = await l2Bridge .withWallet(user2Wallet) .methods.claim_private(secretHashForRedeemingMintedNotes, bridgeAmount, secretForL2MessageConsumption) - .send(); - const consumptionReceipt = await consumptionTx.wait(); - expect(consumptionReceipt.status).toBe(TxStatus.MINED); + .send() + .wait(); // Now user1 can claim the notes that user2 minted on their behalf. await crossChainTestHarness.addPendingShieldNoteToPXE( 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 bf6455b69af9..047e57674e4b 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 @@ -11,7 +11,6 @@ import { Note, PXE, PublicKey, - TxStatus, computeMessageSecretHash, generatePublicKey, } from '@aztec/aztec.js'; @@ -70,7 +69,6 @@ describe('e2e_escrow_contract', () => { const secretHash = computeMessageSecretHash(secret); const receipt = await token.methods.mint_private(mintAmount, secretHash).send().wait(); - expect(receipt.status).toEqual(TxStatus.MINED); const note = new Note([new Fr(mintAmount), secretHash]); @@ -84,9 +82,7 @@ describe('e2e_escrow_contract', () => { ); await pxe.addNote(extendedNote); - expect( - (await token.methods.redeem_shield(escrowContract.address, mintAmount, secret).send().wait()).status, - ).toEqual(TxStatus.MINED); + await token.methods.redeem_shield(escrowContract.address, mintAmount, secret).send().wait(); logger(`Token contract deployed at ${token.address}`); }, 100_000); @@ -115,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 () => { @@ -125,7 +121,6 @@ describe('e2e_escrow_contract', () => { const secretHash = computeMessageSecretHash(secret); const receipt = await token.methods.mint_private(mintAmount, secretHash).send().wait(); - expect(receipt.status).toEqual(TxStatus.MINED); const note = new Note([new Fr(mintAmount), secretHash]); const extendedNote = new ExtendedNote( @@ -138,7 +133,7 @@ describe('e2e_escrow_contract', () => { ); await pxe.addNote(extendedNote); - expect((await token.methods.redeem_shield(owner, mintAmount, secret).send().wait()).status).toEqual(TxStatus.MINED); + await token.methods.redeem_shield(owner, mintAmount, secret).send().wait(); await expectBalance(owner, 50n); diff --git a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts b/yarn-project/end-to-end/src/e2e_lending_contract.test.ts index 52c23f8129ff..10bae5d432e9 100644 --- a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_lending_contract.test.ts @@ -6,8 +6,6 @@ import { ExtendedNote, Fr, Note, - SentTx, - TxStatus, computeAuthWitMessageHash, computeMessageSecretHash, } from '@aztec/aztec.js'; @@ -36,12 +34,6 @@ describe('e2e_lending_contract', () => { let lendingAccount: LendingAccount; let lendingSim: LendingSimulator; - const waitForSuccess = async (tx: SentTx) => { - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); - return receipt; - }; - const deployContracts = async () => { logger(`Deploying price feed contract...`); const priceFeedContract = await PriceFeedContract.deploy(wallet).send().deployed(); @@ -95,7 +87,10 @@ describe('e2e_lending_contract', () => { }); it('Mint assets for later usage', async () => { - await waitForSuccess(priceFeedContract.methods.set_price(0n, 2n * 10n ** 9n).send()); + await priceFeedContract.methods + .set_price(0n, 2n * 10n ** 9n) + .send() + .wait(); { const assets = [collateralAsset, stableCoin]; @@ -106,7 +101,7 @@ describe('e2e_lending_contract', () => { const a = asset.methods.mint_public(lendingAccount.address, mintAmount).send(); const b = asset.methods.mint_private(mintAmount, secretHash).send(); - await Promise.all([a, b].map(waitForSuccess)); + await Promise.all([a, b].map(tx => tx.wait())); const storageSlot = new Fr(5); const noteTypeId = new Fr(84114971101151129711410111011678111116101n); // TransparentNote @@ -123,7 +118,7 @@ describe('e2e_lending_contract', () => { ); await wallet.addNote(extendedNote); - await waitForSuccess(asset.methods.redeem_shield(lendingAccount.address, mintAmount, secret).send()); + await asset.methods.redeem_shield(lendingAccount.address, mintAmount, secret).send().wait(); } } @@ -139,9 +134,10 @@ describe('e2e_lending_contract', () => { it('Initialize the contract', async () => { await lendingSim.prepare(); logger('Initializing contract'); - await waitForSuccess( - lendingContract.methods.init(priceFeedContract.address, 8000, collateralAsset.address, stableCoin.address).send(), - ); + await lendingContract.methods + .init(priceFeedContract.address, 8000, collateralAsset.address, stableCoin.address) + .send() + .wait(); }); describe('Deposits', () => { @@ -165,18 +161,17 @@ describe('e2e_lending_contract', () => { // - increase last updated timestamp. // - increase the private collateral. logger('Depositing 🥸 : 💰 -> 🏦'); - await waitForSuccess( - lendingContract.methods - .deposit_private( - lendingAccount.address, - depositAmount, - nonce, - lendingAccount.secret, - 0n, - collateralAsset.address, - ) - .send(), - ); + await lendingContract.methods + .deposit_private( + lendingAccount.address, + depositAmount, + nonce, + lendingAccount.secret, + 0n, + collateralAsset.address, + ) + .send() + .wait(); }); it('Depositing 🥸 on behalf of recipient: 💰 -> 🏦', async () => { @@ -198,18 +193,17 @@ describe('e2e_lending_contract', () => { // - increase last updated timestamp. // - increase the public collateral. logger('Depositing 🥸 on behalf of recipient: 💰 -> 🏦'); - await waitForSuccess( - lendingContract.methods - .deposit_private( - lendingAccount.address, - depositAmount, - nonce, - 0n, - lendingAccount.address, - collateralAsset.address, - ) - .send(), - ); + await lendingContract.methods + .deposit_private( + lendingAccount.address, + depositAmount, + nonce, + 0n, + lendingAccount.address, + collateralAsset.address, + ) + .send() + .wait(); }); it('Depositing: 💰 -> 🏦', async () => { @@ -236,11 +230,10 @@ describe('e2e_lending_contract', () => { // - increase the public collateral. logger('Depositing: 💰 -> 🏦'); - await waitForSuccess( - lendingContract.methods - .deposit_public(depositAmount, nonce, lendingAccount.address, collateralAsset.address) - .send(), - ); + await lendingContract.methods + .deposit_public(depositAmount, nonce, lendingAccount.address, collateralAsset.address) + .send() + .wait(); }); }); @@ -257,9 +250,10 @@ describe('e2e_lending_contract', () => { // - increase the private debt. logger('Borrow 🥸 : 🏦 -> 🍌'); - await waitForSuccess( - lendingContract.methods.borrow_private(lendingAccount.secret, lendingAccount.address, borrowAmount).send(), - ); + await lendingContract.methods + .borrow_private(lendingAccount.secret, lendingAccount.address, borrowAmount) + .send() + .wait(); }); it('Borrow: 🏦 -> 🍌', async () => { @@ -274,7 +268,7 @@ describe('e2e_lending_contract', () => { // - increase the public debt. logger('Borrow: 🏦 -> 🍌'); - await waitForSuccess(lendingContract.methods.borrow_public(lendingAccount.address, borrowAmount).send()); + await lendingContract.methods.borrow_public(lendingAccount.address, borrowAmount).send().wait(); }); }); @@ -298,11 +292,10 @@ describe('e2e_lending_contract', () => { // - decrease the private debt. logger('Repay 🥸 : 🍌 -> 🏦'); - await waitForSuccess( - lendingContract.methods - .repay_private(lendingAccount.address, repayAmount, nonce, lendingAccount.secret, 0n, stableCoin.address) - .send(), - ); + await lendingContract.methods + .repay_private(lendingAccount.address, repayAmount, nonce, lendingAccount.secret, 0n, stableCoin.address) + .send() + .wait(); }); it('Repay 🥸 on behalf of public: 🍌 -> 🏦', async () => { @@ -324,11 +317,10 @@ describe('e2e_lending_contract', () => { // - decrease the public debt. logger('Repay 🥸 on behalf of public: 🍌 -> 🏦'); - await waitForSuccess( - lendingContract.methods - .repay_private(lendingAccount.address, repayAmount, nonce, 0n, lendingAccount.address, stableCoin.address) - .send(), - ); + await lendingContract.methods + .repay_private(lendingAccount.address, repayAmount, nonce, 0n, lendingAccount.address, stableCoin.address) + .send() + .wait(); }); it('Repay: 🍌 -> 🏦', async () => { @@ -353,9 +345,10 @@ describe('e2e_lending_contract', () => { // - decrease the public debt. logger('Repay: 🍌 -> 🏦'); - await waitForSuccess( - lendingContract.methods.repay_public(repayAmount, nonce, lendingAccount.address, stableCoin.address).send(), - ); + await lendingContract.methods + .repay_public(repayAmount, nonce, lendingAccount.address, stableCoin.address) + .send() + .wait(); }); }); @@ -372,7 +365,7 @@ describe('e2e_lending_contract', () => { // - decrease the public collateral. logger('Withdraw: 🏦 -> 💰'); - await waitForSuccess(lendingContract.methods.withdraw_public(lendingAccount.address, withdrawAmount).send()); + await lendingContract.methods.withdraw_public(lendingAccount.address, withdrawAmount).send().wait(); }); it('Withdraw 🥸 : 🏦 -> 💰', async () => { @@ -387,9 +380,10 @@ describe('e2e_lending_contract', () => { // - decrease the private collateral. logger('Withdraw 🥸 : 🏦 -> 💰'); - await waitForSuccess( - lendingContract.methods.withdraw_private(lendingAccount.secret, lendingAccount.address, withdrawAmount).send(), - ); + await lendingContract.methods + .withdraw_private(lendingAccount.secret, lendingAccount.address, withdrawAmount) + .send() + .wait(); }); describe('failure cases', () => { diff --git a/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts b/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts index bc01605d6b43..b4d911dfb028 100644 --- a/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts +++ b/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts @@ -9,7 +9,6 @@ import { GrumpkinScalar, Note, PXE, - TxStatus, Wallet, computeMessageSecretHash, generatePublicKey, @@ -63,7 +62,6 @@ describe('e2e_multiple_accounts_1_enc_key', () => { const secretHash = computeMessageSecretHash(secret); const receipt = await token.methods.mint_private(initialBalance, secretHash).send().wait(); - expect(receipt.status).toEqual(TxStatus.MINED); const storageSlot = new Fr(5); const noteTypeId = new Fr(84114971101151129711410111011678111116101n); // TransparentNote @@ -79,9 +77,7 @@ describe('e2e_multiple_accounts_1_enc_key', () => { ); await pxe.addNote(extendedNote); - expect((await token.methods.redeem_shield(accounts[0], initialBalance, secret).send().wait()).status).toEqual( - TxStatus.MINED, - ); + await token.methods.redeem_shield(accounts[0], initialBalance, secret).send().wait(); }, 100_000); afterEach(() => teardown()); @@ -110,8 +106,7 @@ describe('e2e_multiple_accounts_1_enc_key', () => { const contractWithWallet = await TokenContract.at(tokenAddress, wallets[senderIndex]); - const receipt = await contractWithWallet.methods.transfer(sender, receiver, transferAmount, 0).send().wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await contractWithWallet.methods.transfer(sender, receiver, transferAmount, 0).send().wait(); for (let i = 0; i < expectedBalances.length; i++) { await expectBalance(i, expectedBalances[i]); diff --git a/yarn-project/end-to-end/src/e2e_ordering.test.ts b/yarn-project/end-to-end/src/e2e_ordering.test.ts index 14a1aa10195d..68836b1b2e3f 100644 --- a/yarn-project/end-to-end/src/e2e_ordering.test.ts +++ b/yarn-project/end-to-end/src/e2e_ordering.test.ts @@ -1,5 +1,5 @@ // Test suite for testing proper ordering of side effects -import { Fr, FunctionSelector, PXE, TxStatus, Wallet, toBigIntBE } from '@aztec/aztec.js'; +import { Fr, FunctionSelector, PXE, Wallet, toBigIntBE } from '@aztec/aztec.js'; import { ChildContract } from '@aztec/noir-contracts.js/Child'; import { ParentContract } from '@aztec/noir-contracts.js/Parent'; @@ -100,9 +100,7 @@ describe('e2e_ordering', () => { async method => { const expectedOrder = expectedOrders[method]; - const tx = child.methods[method]().send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await child.methods[method]().send().wait(); const value = await pxe.getPublicStorageAt(child.address, new Fr(1)); expect(value.value).toBe(expectedOrder[1]); // final state should match last value set @@ -119,9 +117,7 @@ describe('e2e_ordering', () => { it.each(['setValueTwiceWithNestedLast'] as const)('orders unencrypted logs in %s', async method => { const expectedOrder = expectedOrders[method]; - const tx = child.methods[method]().send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await child.methods[method]().send().wait(); // Logs are emitted in the expected order await expectLogsFromLastBlockToBe(expectedOrder); diff --git a/yarn-project/end-to-end/src/e2e_p2p_network.test.ts b/yarn-project/end-to-end/src/e2e_p2p_network.test.ts index 45258e3eefcd..5f8c80301762 100644 --- a/yarn-project/end-to-end/src/e2e_p2p_network.test.ts +++ b/yarn-project/end-to-end/src/e2e_p2p_network.test.ts @@ -60,12 +60,7 @@ describe('e2e_p2p_network', () => { } // now ensure that all txs were successfully mined - for (const context of contexts) { - for (const tx of context.txs) { - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); - } - } + await Promise.all(contexts.flatMap(context => context.txs.map(tx => tx.wait()))); // shutdown all nodes. for (const context of contexts) { diff --git a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts index f4d772af1577..37e1cbdefdbe 100644 --- a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts @@ -1,4 +1,4 @@ -import { AztecAddress, AztecNode, CompleteAddress, DebugLogger, Fr, TxStatus, Wallet } from '@aztec/aztec.js'; +import { AztecAddress, AztecNode, CompleteAddress, DebugLogger, Fr, Wallet } from '@aztec/aztec.js'; import { PendingNoteHashesContract } from '@aztec/noir-contracts.js/PendingNoteHashes'; import { setup } from './fixtures/utils.js'; @@ -63,11 +63,7 @@ describe('e2e_pending_note_hashes_contract', () => { const deployedContract = await deployContract(); - const receipt = await deployedContract.methods - .test_insert_then_get_then_nullify_flat(mintAmount, owner) - .send() - .wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await deployedContract.methods.test_insert_then_get_then_nullify_flat(mintAmount, owner).send().wait(); }, 60_000); it('Squash! Aztec.nr function can "create" and "nullify" note in the same TX', async () => { @@ -77,7 +73,7 @@ describe('e2e_pending_note_hashes_contract', () => { const deployedContract = await deployContract(); - const receipt = await deployedContract.methods + await deployedContract.methods .test_insert_then_get_then_nullify_all_in_nested_calls( mintAmount, owner, @@ -88,8 +84,6 @@ describe('e2e_pending_note_hashes_contract', () => { .send() .wait(); - expect(receipt.status).toBe(TxStatus.MINED); - await expectNoteHashesSquashedExcept(0); await expectNullifiersSquashedExcept(0); }, 60_000); @@ -101,7 +95,7 @@ describe('e2e_pending_note_hashes_contract', () => { const deployedContract = await deployContract(); - const receipt = await deployedContract.methods + await deployedContract.methods .test_insert2_then_get2_then_nullify2_all_in_nested_calls( mintAmount, owner, @@ -111,8 +105,6 @@ describe('e2e_pending_note_hashes_contract', () => { .send() .wait(); - expect(receipt.status).toBe(TxStatus.MINED); - await expectNoteHashesSquashedExcept(0); await expectNullifiersSquashedExcept(0); }, 60_000); @@ -125,7 +117,7 @@ describe('e2e_pending_note_hashes_contract', () => { const deployedContract = await deployContract(); - const receipt = await deployedContract.methods + await deployedContract.methods .test_insert2_then_get2_then_nullify1_all_in_nested_calls( mintAmount, owner, @@ -135,8 +127,6 @@ describe('e2e_pending_note_hashes_contract', () => { .send() .wait(); - expect(receipt.status).toBe(TxStatus.MINED); - await expectNoteHashesSquashedExcept(1); await expectNullifiersSquashedExcept(0); }, 60_000); @@ -152,14 +142,13 @@ describe('e2e_pending_note_hashes_contract', () => { const deployedContract = await deployContract(); // create persistent note - const receipt0 = await deployedContract.methods.insert_note(mintAmount, owner).send().wait(); - expect(receipt0.status).toBe(TxStatus.MINED); + await deployedContract.methods.insert_note(mintAmount, owner).send().wait(); await expectNoteHashesSquashedExcept(1); // first TX just creates 1 persistent note await expectNullifiersSquashedExcept(0); // create another note, and nullify it and AND nullify the above-created note in the same TX - const receipt1 = await deployedContract.methods + await deployedContract.methods .test_insert1_then_get2_then_nullify2_all_in_nested_calls( mintAmount, owner, @@ -170,8 +159,6 @@ describe('e2e_pending_note_hashes_contract', () => { .send() .wait(); - expect(receipt1.status).toBe(TxStatus.MINED); - // second TX creates 1 note, but it is squashed! await expectNoteHashesSquashedExcept(0); // the nullifier corresponding to this transient note is squashed, but the @@ -188,14 +175,12 @@ describe('e2e_pending_note_hashes_contract', () => { const mintAmount = 65n; const deployedContract = await deployContract(); - const receipt = await deployedContract.methods.insert_note(mintAmount, owner).send().wait(); - - expect(receipt.status).toBe(TxStatus.MINED); + await deployedContract.methods.insert_note(mintAmount, owner).send().wait(); // There is a single new note hash. await expectNoteHashesSquashedExcept(1); - const receipt2 = await deployedContract.methods + await deployedContract.methods .test_insert_then_get_then_nullify_all_in_nested_calls( mintAmount, owner, @@ -206,8 +191,6 @@ describe('e2e_pending_note_hashes_contract', () => { .send() .wait(); - expect(receipt2.status).toBe(TxStatus.MINED); - // There is a single new nullifier. await expectNullifiersSquashedExcept(1); }, 60_000); diff --git a/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts b/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts index e76bd6070929..7d700bdffdc0 100644 --- a/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts @@ -1,4 +1,4 @@ -import { AccountWallet, AztecAddress, CompleteAddress, DebugLogger, Fr, TxStatus } from '@aztec/aztec.js'; +import { AccountWallet, AztecAddress, CompleteAddress, DebugLogger, Fr } from '@aztec/aztec.js'; import { EasyPrivateVotingContract } from '@aztec/noir-contracts.js/EasyPrivateVoting'; import { setup } from './fixtures/utils.js'; @@ -32,9 +32,7 @@ describe('e2e_voting_contract', () => { describe('votes', () => { it('votes', async () => { const candidate = new Fr(1); - const tx = votingContract.methods.cast_vote(candidate).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await votingContract.methods.cast_vote(candidate).send().wait(); expect(await votingContract.methods.get_vote(candidate).view()).toBe(1n); }); }); 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 e9d7363e5994..1930fa216bea 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 748101acea72..ffc41d35586a 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 1b7327ce6a9d..8aebff157522 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 8a000a73af75..742a91b4be55 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 @@ -7,7 +7,6 @@ import { FunctionSelector, Note, TxHash, - TxStatus, computeAuthWitMessageHash, computeMessageSecretHash, } from '@aztec/aztec.js'; @@ -112,10 +111,7 @@ describe('e2e_token_contract', () => { const t = toString(await asset.methods.un_get_name().view()); expect(t).toBe(TOKEN_NAME); - const tx = reader.methods[method](asset.address, TOKEN_NAME).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); - + await reader.methods[method](asset.address, TOKEN_NAME).send().wait(); await expect(reader.methods[method](asset.address, 'WRONG_NAME').simulate()).rejects.toThrow(errorMessage); }); }); @@ -125,23 +121,19 @@ describe('e2e_token_contract', () => { const t = toString(await asset.methods.un_get_symbol().view()); expect(t).toBe(TOKEN_SYMBOL); - const tx = reader.methods.check_symbol_private(asset.address, TOKEN_SYMBOL).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + 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()); expect(t).toBe(TOKEN_SYMBOL); - const tx = reader.methods.check_symbol_public(asset.address, TOKEN_SYMBOL).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + 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)'", ); }); @@ -152,11 +144,9 @@ describe('e2e_token_contract', () => { const t = await asset.methods.un_get_decimals().view(); expect(t).toBe(TOKEN_DECIMALS); - const tx = reader.methods.check_decimals_private(asset.address, TOKEN_DECIMALS).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + 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'", ); }); @@ -165,11 +155,9 @@ describe('e2e_token_contract', () => { const t = await asset.methods.un_get_decimals().view(); expect(t).toBe(TOKEN_DECIMALS); - const tx = reader.methods.check_decimals_public(asset.address, TOKEN_DECIMALS).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + 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'", ); }); @@ -178,34 +166,28 @@ describe('e2e_token_contract', () => { describe('Access controlled functions', () => { it('Set admin', async () => { - const tx = asset.methods.set_admin(accounts[1].address).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.methods.set_admin(accounts[1].address).send().wait(); expect(await asset.methods.admin().view()).toBe(accounts[1].address.toBigInt()); }); it('Add minter as admin', async () => { - const tx = asset.withWallet(wallets[1]).methods.set_minter(accounts[1].address, true).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.withWallet(wallets[1]).methods.set_minter(accounts[1].address, true).send().wait(); expect(await asset.methods.is_minter(accounts[1].address).view()).toBe(true); }); it('Revoke minter as admin', async () => { - const tx = asset.withWallet(wallets[1]).methods.set_minter(accounts[1].address, false).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.withWallet(wallets[1]).methods.set_minter(accounts[1].address, false).send().wait(); expect(await asset.methods.is_minter(accounts[1].address).view()).toBe(false); }); 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', ); }); @@ -216,9 +198,7 @@ describe('e2e_token_contract', () => { describe('Public', () => { it('as minter', async () => { const amount = 10000n; - const tx = asset.methods.mint_public(accounts[0].address, amount).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.methods.mint_public(accounts[0].address, amount).send().wait(); tokenSim.mintPublic(accounts[0].address, amount); expect(await asset.methods.balance_of_public(accounts[0].address).view()).toEqual( @@ -232,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, ); }); @@ -270,9 +250,7 @@ describe('e2e_token_contract', () => { describe('Mint flow', () => { it('mint_private as minter', async () => { - const tx = asset.methods.mint_private(amount, secretHash).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + const receipt = await asset.methods.mint_private(amount, secretHash).send().wait(); tokenSim.mintPrivate(amount); txHash = receipt.txHash; }); @@ -283,7 +261,6 @@ describe('e2e_token_contract', () => { // docs:start:debug const receiptClaim = await txClaim.wait({ debug: true }); // docs:end:debug - expect(receiptClaim.status).toBe(TxStatus.MINED); tokenSim.redeemShield(accounts[0].address, amount); // 1 note should be created containing `amount` of tokens const { visibleNotes } = receiptClaim.debugInfo!; @@ -294,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, ); }); @@ -318,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); }); }); }); @@ -339,9 +312,7 @@ describe('e2e_token_contract', () => { const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance0 / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods.transfer_public(accounts[0].address, accounts[1].address, amount, 0).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.methods.transfer_public(accounts[0].address, accounts[1].address, amount, 0).send().wait(); tokenSim.transferPublic(accounts[0].address, accounts[1].address, amount); }); @@ -350,9 +321,7 @@ describe('e2e_token_contract', () => { const balance = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods.transfer_public(accounts[0].address, accounts[0].address, amount, 0).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.methods.transfer_public(accounts[0].address, accounts[0].address, amount, 0).send().wait(); tokenSim.transferPublic(accounts[0].address, accounts[0].address, amount); }); @@ -373,9 +342,7 @@ describe('e2e_token_contract', () => { // docs:end:authwit_public_transfer_example // Perform the transfer - const tx = action.send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await action.send().wait(); tokenSim.transferPublic(accounts[0].address, accounts[1].address, amount); @@ -384,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', () => { @@ -394,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 () => { @@ -403,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 () => { @@ -415,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 () => { @@ -434,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); @@ -456,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); @@ -477,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); @@ -503,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 () => { @@ -514,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'", ); }); @@ -533,9 +500,7 @@ describe('e2e_token_contract', () => { const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balance0 / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods.transfer(accounts[0].address, accounts[1].address, amount, 0).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.methods.transfer(accounts[0].address, accounts[1].address, amount, 0).send().wait(); tokenSim.transferPrivate(accounts[0].address, accounts[1].address, amount); }); @@ -543,9 +508,7 @@ describe('e2e_token_contract', () => { const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balance0 / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods.transfer(accounts[0].address, accounts[0].address, amount, 0).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.methods.transfer(accounts[0].address, accounts[0].address, amount, 0).send().wait(); tokenSim.transferPrivate(accounts[0].address, accounts[0].address, amount); }); @@ -569,9 +532,7 @@ describe('e2e_token_contract', () => { // docs:end:authwit_transfer_example // Perform the transfer - const tx = action.send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await action.send().wait(); tokenSim.transferPrivate(accounts[0].address, accounts[1].address, amount); // Perform the transfer again, should fail @@ -579,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', () => { @@ -589,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 () => { @@ -598,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 () => { @@ -621,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); }); @@ -645,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()}`, ); }); @@ -666,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); @@ -694,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 () => { @@ -705,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'", ); }); @@ -726,18 +687,14 @@ describe('e2e_token_contract', () => { const amount = balancePub / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods.shield(accounts[0].address, amount, secretHash, 0).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + const receipt = await asset.methods.shield(accounts[0].address, amount, secretHash, 0).send().wait(); tokenSim.shield(accounts[0].address, amount); await tokenSim.check(); // Redeem it await addPendingShieldNoteToPXE(0, amount, secretHash, receipt.txHash); - const txClaim = asset.methods.redeem_shield(accounts[0].address, amount, secret).send(); - const receiptClaim = await txClaim.wait(); - expect(receiptClaim.status).toBe(TxStatus.MINED); + await asset.methods.redeem_shield(accounts[0].address, amount, secret).send().wait(); tokenSim.redeemShield(accounts[0].address, amount); }); @@ -753,9 +710,7 @@ describe('e2e_token_contract', () => { const messageHash = computeAuthWitMessageHash(accounts[1].address, action.request()); await wallets[0].setPublicAuth(messageHash, true).send().wait(); - const tx = action.send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + const receipt = await action.send().wait(); tokenSim.shield(accounts[0].address, amount); await tokenSim.check(); @@ -765,13 +720,11 @@ 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); - const txClaim = asset.methods.redeem_shield(accounts[0].address, amount, secret).send(); - const receiptClaim = await txClaim.wait(); - expect(receiptClaim.status).toBe(TxStatus.MINED); + await asset.methods.redeem_shield(accounts[0].address, amount, secret).send().wait(); tokenSim.redeemShield(accounts[0].address, amount); }); @@ -782,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, ); }); @@ -792,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', ); }); @@ -808,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 () => { @@ -822,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 () => { @@ -833,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`); }); }); }); @@ -844,9 +797,7 @@ describe('e2e_token_contract', () => { const amount = balancePriv / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods.unshield(accounts[0].address, accounts[0].address, amount, 0).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.methods.unshield(accounts[0].address, accounts[0].address, amount, 0).send().wait(); tokenSim.unshield(accounts[0].address, accounts[0].address, amount); }); @@ -869,9 +820,7 @@ describe('e2e_token_contract', () => { const witness = await wallets[0].createAuthWitness(messageHash); await wallets[1].addAuthWitness(witness); - const tx = action.send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await action.send().wait(); tokenSim.unshield(accounts[0].address, accounts[1].address, amount); // Perform the transfer again, should fail @@ -879,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', () => { @@ -890,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 () => { @@ -900,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 () => { @@ -921,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 () => { @@ -943,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()}`, ); }); @@ -956,9 +905,7 @@ describe('e2e_token_contract', () => { const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance0 / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods.burn_public(accounts[0].address, amount, 0).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.methods.burn_public(accounts[0].address, amount, 0).send().wait(); tokenSim.burnPublic(accounts[0].address, amount); }); @@ -974,15 +921,13 @@ describe('e2e_token_contract', () => { const messageHash = computeAuthWitMessageHash(accounts[1].address, action.request()); await wallets[0].setPublicAuth(messageHash, true).send().wait(); - const tx = action.send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await action.send().wait(); tokenSim.burnPublic(accounts[0].address, amount); // 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', () => { @@ -990,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, ); }); @@ -1000,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', ); }); @@ -1011,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 () => { @@ -1025,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 () => { @@ -1041,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'); }); }); }); @@ -1051,9 +996,7 @@ describe('e2e_token_contract', () => { const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balance0 / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods.burn(accounts[0].address, amount, 0).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.methods.burn(accounts[0].address, amount, 0).send().wait(); tokenSim.burnPrivate(accounts[0].address, amount); }); @@ -1073,14 +1016,12 @@ describe('e2e_token_contract', () => { const witness = await wallets[0].createAuthWitness(messageHash); await wallets[1].addAuthWitness(witness); - const tx = asset.withWallet(wallets[1]).methods.burn(accounts[0].address, amount, nonce).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await asset.withWallet(wallets[1]).methods.burn(accounts[0].address, amount, nonce).send().wait(); tokenSim.burnPrivate(accounts[0].address, amount); // 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', () => { @@ -1088,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', ); }); @@ -1097,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', ); }); @@ -1118,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 () => { @@ -1131,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()}`, ); }); @@ -1150,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 9bf90e5e4ae6..40e4571ae94e 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 @@ -6,7 +6,6 @@ import { Fr, Note, PXE, - TxStatus, computeMessageSecretHash, createPXEClient, waitForPXE, @@ -220,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); @@ -240,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); @@ -255,8 +254,7 @@ describe('guides/dapp/testing', () => { it('asserts a transaction with a failing public call is included (with no state changes)', async () => { // docs:start:pub-reverted const call = token.methods.transfer_public(owner.getAddress(), recipient.getAddress(), 1000n, 0); - const receipt = await call.send({ skipPublicSimulation: true }).wait(); - expect(receipt.status).toEqual(TxStatus.MINED); + await call.send({ skipPublicSimulation: true }).wait(); const ownerPublicBalanceSlot = cheats.aztec.computeSlotInMap(6n, owner.getAddress()); const balance = await pxe.getPublicStorageAt(token.address, ownerPublicBalanceSlot); expect(balance.value).toEqual(100n); diff --git a/yarn-project/end-to-end/src/shared/gas_portal_test_harness.ts b/yarn-project/end-to-end/src/shared/gas_portal_test_harness.ts index cf368845f2d7..4f873c3ab3bb 100644 --- a/yarn-project/end-to-end/src/shared/gas_portal_test_harness.ts +++ b/yarn-project/end-to-end/src/shared/gas_portal_test_harness.ts @@ -4,7 +4,6 @@ import { EthAddress, Fr, PXE, - TxStatus, Wallet, computeMessageSecretHash, deployL1Contract, @@ -257,9 +256,7 @@ class GasBridgingTestHarness implements IGasBridgingTestHarness { async consumeMessageOnAztecAndMintPublicly(bridgeAmount: bigint, owner: AztecAddress, secret: Fr) { this.logger('Consuming messages on L2 Publicly'); // Call the mint tokens function on the Aztec.nr contract - const tx = this.l2Token.methods.claim_public(owner, bridgeAmount, secret).send(); - const receipt = await tx.wait(); - expect(receipt.status).toBe(TxStatus.MINED); + await this.l2Token.methods.claim_public(owner, bridgeAmount, secret).send().wait(); } async getL2PublicBalanceOf(owner: AztecAddress) { 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 00ab5e704685..740006650e57 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 @@ -6,7 +6,6 @@ import { EthAddress, Fr, PXE, - TxStatus, computeAuthWitMessageHash, } from '@aztec/aztec.js'; import { deployL1Contract } from '@aztec/ethereum'; @@ -218,7 +217,7 @@ export const uniswapL1L2TestSuite = ( daiCrossChainHarness.generateClaimSecret(); const [secretForRedeemingDai, secretHashForRedeemingDai] = daiCrossChainHarness.generateClaimSecret(); - const withdrawReceipt = await uniswapL2Contract.methods + await uniswapL2Contract.methods .swap_private( wethCrossChainHarness.l2Token.address, wethCrossChainHarness.l2Bridge.address, @@ -233,7 +232,6 @@ export const uniswapL1L2TestSuite = ( ) .send() .wait(); - expect(withdrawReceipt.status).toBe(TxStatus.MINED); // ensure that user's funds were burnt await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge); // ensure that uniswap contract didn't eat the funds. @@ -378,8 +376,7 @@ export const uniswapL1L2TestSuite = ( await ownerWallet.setPublicAuth(swapMessageHash, true).send().wait(); // 4.2 Call swap_public from user2 on behalf of owner - const withdrawReceipt = await action.send().wait(); - expect(withdrawReceipt.status).toBe(TxStatus.MINED); + await action.send().wait(); // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!) await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge); @@ -478,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 () => { @@ -516,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: @@ -538,7 +535,7 @@ export const uniswapL1L2TestSuite = ( // No approval to call `swap` but should work even without it: const [_, secretHashForDepositingSwappedDai] = daiCrossChainHarness.generateClaimSecret(); - const withdrawReceipt = await uniswapL2Contract.methods + await uniswapL2Contract.methods .swap_public( ownerAddress, wethCrossChainHarness.l2Bridge.address, @@ -554,7 +551,6 @@ export const uniswapL1L2TestSuite = ( ) .send() .wait(); - expect(withdrawReceipt.status).toBe(TxStatus.MINED); // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!) await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n); }); @@ -618,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: @@ -646,7 +642,7 @@ export const uniswapL1L2TestSuite = ( logger('Withdrawing weth to L1 and sending message to swap to dai'); const secretHashForDepositingSwappedDai = Fr.random(); - const withdrawReceipt = await uniswapL2Contract.methods + await uniswapL2Contract.methods .swap_private( wethCrossChainHarness.l2Token.address, wethCrossChainHarness.l2Bridge.address, @@ -661,7 +657,6 @@ export const uniswapL1L2TestSuite = ( ) .send() .wait(); - expect(withdrawReceipt.status).toBe(TxStatus.MINED); // ensure that user's funds were burnt await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge); @@ -681,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 () => { @@ -700,7 +695,7 @@ export const uniswapL1L2TestSuite = ( // Call swap_public on L2 const secretHashForDepositingSwappedDai = Fr.random(); - const withdrawReceipt = await uniswapL2Contract.methods + await uniswapL2Contract.methods .swap_public( ownerAddress, wethCrossChainHarness.l2Bridge.address, @@ -716,7 +711,6 @@ export const uniswapL1L2TestSuite = ( ) .send() .wait(); - expect(withdrawReceipt.status).toBe(TxStatus.MINED); // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!) await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n); @@ -737,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 a85c24542360..a234bc04758c 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 6280eca47537..474c26fffb7b 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 6095eb1c310f..ff94978f0d18 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 ba5eeaa9f98b..25c8be3e1a85 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 01588b0e3ba6..57bef759a67c 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 81725755a6be..5a459823acc7 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 41470dc95e57..3976c805a04b 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 f2a0f1e8ccf1..2abe169627f5 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 cff1858a0087..fe7e32cfdff2 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`), ); });