Skip to content

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jdevcs committed Sep 27, 2023
1 parent 2dbbc8a commit 284b81b
Showing 1 changed file with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ describe('defaults', () => {
beforeEach(() => {
clientUrl = getSystemTestProvider();
web3 = new Web3(clientUrl);
// Make the test run faster by casing the polling to start after 2 blocks
web3.eth.transactionBlockTimeout = 2;

// Increase other timeouts so only `transactionBlockTimeout` would be reached
web3.eth.transactionSendTimeout = MAX_32_SIGNED_INTEGER;
Expand All @@ -64,6 +62,7 @@ describe('defaults', () => {
account1 = await createLocalAccount(web3);
account2 = await createLocalAccount(web3);
// Setting a high `nonce` when sending a transaction, to cause the RPC call to stuck at the Node

const sentTx: Web3PromiEvent<
TransactionReceipt,
SendTransactionEvents<typeof DEFAULT_RETURN_FORMAT>
Expand All @@ -81,18 +80,13 @@ describe('defaults', () => {
// So, send 2 transactions, one after another, because in this test `transactionBlockTimeout = 2`.
// eslint-disable-next-line no-void
await sendFewSampleTxs(2);

web3.eth.transactionBlockTimeout = 2;

await expect(sentTx).rejects.toThrow(/was not mined within [0-9]+ blocks/);

await expect(sentTx).rejects.toThrow(TransactionBlockTimeoutError);

try {
await sentTx;
throw new Error(
'The test should fail if there is no exception when sending a transaction that could not be mined within transactionBlockTimeout',
);
} catch (error) {
// eslint-disable-next-line jest/no-conditional-expect
expect(error).toBeInstanceOf(TransactionBlockTimeoutError);
// eslint-disable-next-line jest/no-conditional-expect
expect((error as Error).message).toMatch(/was not mined within [0-9]+ blocks/);
}
await closeOpenConnection(web3.eth);
});

Expand Down Expand Up @@ -128,6 +122,8 @@ describe('defaults', () => {
// eslint-disable-next-line no-void, @typescript-eslint/no-unsafe-call
void sendFewSampleTxs(2);

web3.eth.transactionBlockTimeout = 2;

await expect(sentTx).rejects.toThrow(/was not mined within [0-9]+ blocks/);

await expect(sentTx).rejects.toThrow(TransactionBlockTimeoutError);
Expand Down

0 comments on commit 284b81b

Please sign in to comment.