From 284b81b68ee928b463be4a9f74f6f2f883511640 Mon Sep 17 00:00:00 2001 From: jdevcs Date: Wed, 27 Sep 2023 22:00:57 +0200 Subject: [PATCH] test fix --- .../defaults.transactionBlockTimeout.test.ts | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/packages/web3-eth/test/integration/defaults.transactionBlockTimeout.test.ts b/packages/web3-eth/test/integration/defaults.transactionBlockTimeout.test.ts index b366b89d537..d547c2bc551 100644 --- a/packages/web3-eth/test/integration/defaults.transactionBlockTimeout.test.ts +++ b/packages/web3-eth/test/integration/defaults.transactionBlockTimeout.test.ts @@ -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; @@ -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 @@ -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); }); @@ -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);