@@ -17,13 +17,11 @@ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
1717import { Web3Eth } from 'web3-eth' ;
1818import { FMT_BYTES , FMT_NUMBER } from 'web3-types' ;
1919import { Contract , createContractAddress } from '../../src' ;
20- import { sleep } from '../shared_fixtures/utils' ;
2120import { ERC721TokenAbi , ERC721TokenBytecode } from '../shared_fixtures/build/ERC721Token' ;
2221import { GreeterBytecode , GreeterAbi } from '../shared_fixtures/build/Greeter' ;
2322import { DeployRevertAbi , DeployRevertBytecode } from '../shared_fixtures/build/DeployRevert' ;
2423import {
2524 getSystemTestProvider ,
26- isWs ,
2725 createTempAccount ,
2826 createNewAccount ,
2927 signTxAndSendEIP2930 ,
@@ -245,26 +243,18 @@ describe('contract', () => {
245243
246244 it ( 'should emit the "confirmation" event' , async ( ) => {
247245 const confirmationHandler = jest . fn ( ) ;
248- contract . setConfig ( { transactionConfirmationBlocks : 1 } ) ;
249- await contract
246+ contract . setConfig ( { transactionConfirmationBlocks : 2 } ) ;
247+
248+ const promiEvent = contract
250249 . deploy ( deployOptions )
251250 . send ( sendOptions )
252251 . on ( 'confirmation' , confirmationHandler ) ;
253252
254- // Wait for some time to allow the transaction to be processed
255- await sleep ( 500 ) ;
256-
257- // Deploy once again to trigger block mining to trigger confirmation
258- // We can send any other transaction as well
259- await contract . deploy ( deployOptions ) . send ( sendOptions ) ;
253+ // Deploy the contract
254+ await promiEvent ;
260255
261256 await sendFewSampleTxs ( 3 ) ;
262257
263- // Wait for some fraction of time to trigger the handler
264- // On http we use polling to get confirmation, so wait a bit longer
265- await sleep ( isWs ? 500 : 2000 ) ;
266-
267- // eslint-disable-next-line jest/no-standalone-expect
268258 expect ( confirmationHandler ) . toHaveBeenCalled ( ) ;
269259 } ) ;
270260
0 commit comments