Skip to content

Commit

Permalink
replacin deprecated toThrowError
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Mar 18, 2024
1 parent d139c53 commit 47776ec
Show file tree
Hide file tree
Showing 25 changed files with 192 additions and 212 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch
});

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

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

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

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

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

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

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

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

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

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

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

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

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

it('reports mismatch on newer pxe version', async () => {
pxe.getNodeInfo.mockResolvedValue({ nodeVersion: '0.1.0-alpha48' } as NodeInfo);
await expect(checkServerVersion(pxe, '0.1.0-alpha47')).rejects.toThrowError(
/is newer than the expected by this CLI/,
);
await expect(checkServerVersion(pxe, '0.1.0-alpha47')).rejects.toThrow(/is newer than the expected by this CLI/);
});
});
});
4 changes: 1 addition & 3 deletions yarn-project/end-to-end/src/e2e_account_contracts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ function itShouldBehaveLikeAnAccountContract(
const accountAddress = wallet.getCompleteAddress();
const invalidWallet = await walletAt(context.pxe, getAccountContract(GrumpkinScalar.random()), accountAddress);
const childWithInvalidWallet = await ChildContract.at(child.address, invalidWallet);
await expect(childWithInvalidWallet.methods.value(42).simulate()).rejects.toThrowError(
/Cannot satisfy constraint.*/,
);
await expect(childWithInvalidWallet.methods.value(42).simulate()).rejects.toThrow(/Cannot satisfy constraint.*/);
});
});
}
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/end-to-end/src/e2e_authwit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('e2e_authwit_tests', () => {
const c = await SchnorrAccountContract.at(wallets[0].getAddress(), wallets[0]);
const txCancelledAuthwit = c.withWallet(wallets[1]).methods.spend_private_authwit(innerHash).send();
// The transaction should be dropped because of a cancelled authwit (duplicate nullifier)
await expect(txCancelledAuthwit.wait()).rejects.toThrowError('Transaction ');
await expect(txCancelledAuthwit.wait()).rejects.toThrow('Transaction ');
});
});
});
Expand Down Expand Up @@ -73,7 +73,7 @@ describe('e2e_authwit_tests', () => {
const c = await SchnorrAccountContract.at(wallets[0].getAddress(), wallets[0]);
const txCancelledAuthwit = c.withWallet(wallets[1]).methods.spend_public_authwit(innerHash).send();
// The transaction should be dropped because of a cancelled authwit (duplicate nullifier)
await expect(txCancelledAuthwit.wait()).rejects.toThrowError('Transaction ');
await expect(txCancelledAuthwit.wait()).rejects.toThrow('Transaction ');
});
});
});
Expand Down
Loading

0 comments on commit 47776ec

Please sign in to comment.