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 42865d4793a..29e84a1b62d 100644 --- a/yarn-project/end-to-end/src/e2e_authwit.test.ts +++ b/yarn-project/end-to-end/src/e2e_authwit.test.ts @@ -3,6 +3,7 @@ import { SchnorrAccountContract } from '@aztec/noir-contracts.js'; import { jest } from '@jest/globals'; +import { DUPLICATE_NULLIFIER_ERROR } from './fixtures/fixtures.js'; import { publicDeployAccounts, setup } from './fixtures/utils.js'; const TIMEOUT = 90_000; @@ -86,7 +87,7 @@ describe('e2e_authwit_tests', () => { }); // The transaction should be dropped because of a cancelled authwit (duplicate nullifier) - await expect(txCancelledAuthwit.wait()).rejects.toThrow('Transaction '); + await expect(txCancelledAuthwit.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); }); it('invalid chain id', async () => { @@ -130,7 +131,7 @@ describe('e2e_authwit_tests', () => { }); // The transaction should be dropped because of the invalid chain id - await expect(txCancelledAuthwit.wait()).rejects.toThrow('Transaction '); + await expect(txCancelledAuthwit.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); }); it('invalid version', async () => { @@ -174,7 +175,7 @@ describe('e2e_authwit_tests', () => { }); // The transaction should be dropped because of the invalid version - await expect(txCancelledAuthwit.wait()).rejects.toThrow('Transaction '); + await expect(txCancelledAuthwit.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); }); }); }); @@ -234,7 +235,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.toThrow('Transaction '); + await expect(txCancelledAuthwit.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); }); }); }); diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/burn.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/burn.test.ts index cb521a0baef..05ca22f844f 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/burn.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/burn.test.ts @@ -1,6 +1,6 @@ import { Fr, computeAuthWitMessageHash } from '@aztec/aztec.js'; -import { U128_UNDERFLOW_ERROR } from '../fixtures/index.js'; +import { DUPLICATE_NULLIFIER_ERROR, U128_UNDERFLOW_ERROR } from '../fixtures/index.js'; import { BlacklistTokenContractTest } from './blacklist_token_contract_test.js'; describe('e2e_blacklist_token_contract burn', () => { @@ -50,7 +50,7 @@ describe('e2e_blacklist_token_contract burn', () => { // 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(wallets[0].getAddress(), amount, nonce).send(); - await expect(txReplay.wait()).rejects.toThrow('Transaction '); + await expect(txReplay.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); }); describe('failure cases', () => { @@ -146,7 +146,7 @@ describe('e2e_blacklist_token_contract burn', () => { // Perform the transfer again, should fail const txReplay = asset.withWallet(wallets[1]).methods.burn(wallets[0].getAddress(), amount, nonce).send(); - await expect(txReplay.wait()).rejects.toThrow('Transaction '); + await expect(txReplay.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); }); describe('failure cases', () => { diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/shielding.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/shielding.test.ts index 4bffbc3a7ef..d5dfbe462e9 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/shielding.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/shielding.test.ts @@ -1,6 +1,6 @@ import { Fr, computeSecretHash } from '@aztec/aztec.js'; -import { U128_UNDERFLOW_ERROR } from '../fixtures/index.js'; +import { DUPLICATE_NULLIFIER_ERROR, U128_UNDERFLOW_ERROR } from '../fixtures/index.js'; import { BlacklistTokenContractTest } from './blacklist_token_contract_test.js'; describe('e2e_blacklist_token_contract shield + redeem_shield', () => { @@ -67,7 +67,7 @@ describe('e2e_blacklist_token_contract shield + redeem_shield', () => { .withWallet(wallets[1]) .methods.shield(wallets[0].getAddress(), amount, secretHash, nonce) .send(); - await expect(txReplay.wait()).rejects.toThrow('Transaction '); + await expect(txReplay.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); // Redeem it await t.addPendingShieldNoteToPXE(0, amount, secretHash, receipt.txHash); diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_private.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_private.test.ts index ed78def1481..ffc06411d2e 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_private.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_private.test.ts @@ -1,5 +1,6 @@ import { Fr, computeAuthWitMessageHash } from '@aztec/aztec.js'; +import { DUPLICATE_NULLIFIER_ERROR } from '../fixtures/fixtures.js'; import { BlacklistTokenContractTest } from './blacklist_token_contract_test.js'; describe('e2e_blacklist_token_contract transfer private', () => { @@ -67,7 +68,7 @@ describe('e2e_blacklist_token_contract transfer private', () => { .withWallet(wallets[1]) .methods.transfer(wallets[0].getAddress(), wallets[1].getAddress(), amount, nonce) .send(); - await expect(txReplay.wait()).rejects.toThrow('Transaction '); + await expect(txReplay.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); }); describe('failure cases', () => { diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_public.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_public.test.ts index 1459704e8aa..45996cf0207 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_public.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_public.test.ts @@ -1,6 +1,6 @@ import { Fr } from '@aztec/aztec.js'; -import { U128_UNDERFLOW_ERROR } from '../fixtures/index.js'; +import { DUPLICATE_NULLIFIER_ERROR, U128_UNDERFLOW_ERROR } from '../fixtures/index.js'; import { BlacklistTokenContractTest } from './blacklist_token_contract_test.js'; describe('e2e_blacklist_token_contract transfer public', () => { @@ -66,7 +66,7 @@ describe('e2e_blacklist_token_contract transfer public', () => { .withWallet(wallets[1]) .methods.transfer_public(wallets[0].getAddress(), wallets[1].getAddress(), amount, nonce) .send(); - await expect(txReplay.wait()).rejects.toThrow('Transaction '); + await expect(txReplay.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); }); describe('failure cases', () => { diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/unshielding.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/unshielding.test.ts index ba8f69e6f26..224a26b5f0f 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/unshielding.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/unshielding.test.ts @@ -1,5 +1,6 @@ import { Fr, computeAuthWitMessageHash } from '@aztec/aztec.js'; +import { DUPLICATE_NULLIFIER_ERROR } from '../fixtures/fixtures.js'; import { BlacklistTokenContractTest } from './blacklist_token_contract_test.js'; describe('e2e_blacklist_token_contract unshielding', () => { @@ -57,7 +58,7 @@ describe('e2e_blacklist_token_contract unshielding', () => { .withWallet(wallets[1]) .methods.unshield(wallets[0].getAddress(), wallets[1].getAddress(), amount, nonce) .send(); - await expect(txReplay.wait()).rejects.toThrow('Transaction '); + await expect(txReplay.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); // @todo @LHerskind This error is weird? }); diff --git a/yarn-project/end-to-end/src/e2e_token_contract/burn.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/burn.test.ts index ff7aed370b5..bfe3406329c 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/burn.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/burn.test.ts @@ -1,6 +1,6 @@ import { Fr, computeAuthWitMessageHash } from '@aztec/aztec.js'; -import { U128_UNDERFLOW_ERROR } from '../fixtures/index.js'; +import { DUPLICATE_NULLIFIER_ERROR, U128_UNDERFLOW_ERROR } from '../fixtures/index.js'; import { TokenContractTest } from './token_contract_test.js'; describe('e2e_token_contract burn', () => { @@ -49,7 +49,7 @@ describe('e2e_token_contract burn', () => { // 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.toThrow('Transaction '); + await expect(txReplay.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); }); describe('failure cases', () => { @@ -139,7 +139,7 @@ describe('e2e_token_contract burn', () => { // 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.toThrow('Transaction '); + await expect(txReplay.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); }); describe('failure cases', () => { diff --git a/yarn-project/end-to-end/src/e2e_token_contract/shielding.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/shielding.test.ts index b0cee961f35..93ab4e44870 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/shielding.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/shielding.test.ts @@ -1,6 +1,6 @@ import { Fr, computeSecretHash } from '@aztec/aztec.js'; -import { U128_UNDERFLOW_ERROR } from '../fixtures/fixtures.js'; +import { DUPLICATE_NULLIFIER_ERROR, U128_UNDERFLOW_ERROR } from '../fixtures/fixtures.js'; import { TokenContractTest } from './token_contract_test.js'; describe('e2e_token_contract shield + redeem shield', () => { @@ -60,7 +60,7 @@ describe('e2e_token_contract shield + redeem shield', () => { // Check that replaying the shield should fail! const txReplay = asset.withWallet(wallets[1]).methods.shield(accounts[0].address, amount, secretHash, nonce).send(); - await expect(txReplay.wait()).rejects.toThrow('Transaction '); + await expect(txReplay.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); // Redeem it await t.addPendingShieldNoteToPXE(0, amount, secretHash, receipt.txHash); diff --git a/yarn-project/end-to-end/src/e2e_token_contract/transfer_private.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/transfer_private.test.ts index 3251c7422a9..fb5394567dc 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/transfer_private.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/transfer_private.test.ts @@ -1,5 +1,6 @@ import { Fr, computeAuthWitMessageHash } from '@aztec/aztec.js'; +import { DUPLICATE_NULLIFIER_ERROR } from '../fixtures/fixtures.js'; import { TokenContractTest } from './token_contract_test.js'; describe('e2e_token_contract transfer private', () => { @@ -66,7 +67,7 @@ describe('e2e_token_contract transfer private', () => { .withWallet(wallets[1]) .methods.transfer(accounts[0].address, accounts[1].address, amount, nonce) .send(); - await expect(txReplay.wait()).rejects.toThrow('Transaction '); + await expect(txReplay.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); }); describe('failure cases', () => { @@ -188,7 +189,7 @@ describe('e2e_token_contract transfer private', () => { .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.toThrowError(DUPLICATE_NULLIFIER_ERROR); }); it('transfer on behalf of other, cancelled authwit, flow 2', async () => { @@ -212,7 +213,7 @@ describe('e2e_token_contract transfer private', () => { .withWallet(wallets[1]) .methods.transfer(accounts[0].address, accounts[1].address, amount, nonce) .send(); - await expect(txCancelledAuthwit.wait()).rejects.toThrow('Transaction '); + await expect(txCancelledAuthwit.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); }); it('transfer on behalf of other, invalid spend_private_authwit on "from"', async () => { diff --git a/yarn-project/end-to-end/src/e2e_token_contract/transfer_public.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/transfer_public.test.ts index 13430c1916a..cb352c57df2 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/transfer_public.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/transfer_public.test.ts @@ -1,6 +1,6 @@ import { Fr, computeAuthWitMessageHash } from '@aztec/aztec.js'; -import { U128_UNDERFLOW_ERROR } from '../fixtures/fixtures.js'; +import { DUPLICATE_NULLIFIER_ERROR, U128_UNDERFLOW_ERROR } from '../fixtures/fixtures.js'; import { TokenContractTest } from './token_contract_test.js'; describe('e2e_token_contract transfer public', () => { @@ -65,7 +65,7 @@ describe('e2e_token_contract transfer public', () => { .withWallet(wallets[1]) .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce) .send(); - await expect(txReplay.wait()).rejects.toThrow('Transaction '); + await expect(txReplay.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); }); describe('failure cases', () => { @@ -194,7 +194,7 @@ describe('e2e_token_contract transfer public', () => { .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.toThrowError(DUPLICATE_NULLIFIER_ERROR); }); it('transfer on behalf of other, cancelled authwit, flow 2', async () => { @@ -216,7 +216,7 @@ describe('e2e_token_contract transfer public', () => { .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.toThrowError(DUPLICATE_NULLIFIER_ERROR); }); it('transfer on behalf of other, cancelled authwit, flow 3', async () => { @@ -244,7 +244,7 @@ describe('e2e_token_contract transfer public', () => { .withWallet(wallets[1]) .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce) .send(); - await expect(txCancelledAuthwit.wait()).rejects.toThrow('Transaction '); + await expect(txCancelledAuthwit.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); }); it('transfer on behalf of other, invalid spend_public_authwit on "from"', async () => { diff --git a/yarn-project/end-to-end/src/e2e_token_contract/unshielding.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/unshielding.test.ts index 998b978e081..d52b3ce214e 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/unshielding.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/unshielding.test.ts @@ -1,5 +1,6 @@ import { Fr, computeAuthWitMessageHash } from '@aztec/aztec.js'; +import { DUPLICATE_NULLIFIER_ERROR } from '../fixtures/fixtures.js'; import { TokenContractTest } from './token_contract_test.js'; describe('e2e_token_contract unshielding', () => { @@ -56,7 +57,7 @@ describe('e2e_token_contract unshielding', () => { .withWallet(wallets[1]) .methods.unshield(accounts[0].address, accounts[1].address, amount, nonce) .send(); - await expect(txReplay.wait()).rejects.toThrow('Transaction '); + await expect(txReplay.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); }); describe('failure cases', () => { diff --git a/yarn-project/end-to-end/src/fixtures/fixtures.ts b/yarn-project/end-to-end/src/fixtures/fixtures.ts index c33f3929718..8e9284a1945 100644 --- a/yarn-project/end-to-end/src/fixtures/fixtures.ts +++ b/yarn-project/end-to-end/src/fixtures/fixtures.ts @@ -7,3 +7,5 @@ export const U128_UNDERFLOW_ERROR = "Assertion failed: attempt to subtract with export const U128_OVERFLOW_ERROR = "Assertion failed: attempt to add with overflow 'hi == high'"; export const BITSIZE_TOO_BIG_ERROR = "Assertion failed: call to assert_max_bit_size 'self.__assert_max_bit_size(bit_size)'"; +// TODO(https://github.com/AztecProtocol/aztec-packages/issues/5818): Make this a fixed error after transition. +export const DUPLICATE_NULLIFIER_ERROR = /Transaction .*|.*duplicate nullifier.*/;