@@ -81,23 +81,25 @@ describe("Draw Benchmark", async () => {
8181 } ) ;
8282 rng = ( await ethers . getContract ( "IncrementalNG" ) ) as IncrementalNG ;
8383
84- await sortitionModule . changeRandomNumberGenerator ( rng . target , 20 ) ;
84+ await sortitionModule . changeRandomNumberGenerator ( rng . target , 20 ) . then ( ( tx ) => tx . wait ( ) ) ;
8585
8686 // CourtId 2 = CHILD_COURT
8787 const minStake = 3n * 10n ** 20n ; // 300 PNK
8888 const alpha = 10000n ;
8989 const feeForJuror = ONE_TENTH_ETH ;
90- await core . createCourt (
91- 1 ,
92- false ,
93- minStake ,
94- alpha ,
95- feeForJuror ,
96- 256 ,
97- [ 0 , 0 , 0 , 10 ] , // evidencePeriod, commitPeriod, votePeriod, appealPeriod
98- ethers . toBeHex ( 5 ) , // Extra data for sortition module will return the default value of K)
99- [ 1 ]
100- ) ;
90+ await core
91+ . createCourt (
92+ 1 ,
93+ false ,
94+ minStake ,
95+ alpha ,
96+ feeForJuror ,
97+ 256 ,
98+ [ 0 , 0 , 0 , 10 ] , // evidencePeriod, commitPeriod, votePeriod, appealPeriod
99+ ethers . toBeHex ( 5 ) , // Extra data for sortition module will return the default value of K)
100+ [ 1 ]
101+ )
102+ . then ( ( tx ) => tx . wait ( ) ) ;
101103 } ) ;
102104
103105 type CountedDraws = { [ address : string ] : number } ;
@@ -119,16 +121,21 @@ describe("Draw Benchmark", async () => {
119121 const wallet = ethers . Wallet . createRandom ( ) . connect ( ethers . provider ) ;
120122 wallets . push ( wallet ) ;
121123
122- await bridger . sendTransaction ( {
123- to : wallet . address ,
124- value : ethers . parseEther ( "10" ) ,
125- } ) ;
124+ await bridger
125+ . sendTransaction ( {
126+ to : wallet . address ,
127+ value : ethers . parseEther ( "10" ) ,
128+ } )
129+ . then ( ( tx ) => tx . wait ( ) ) ;
126130 expect ( await ethers . provider . getBalance ( wallet ) ) . to . equal ( ethers . parseEther ( "10" ) ) ;
127131
128- await pnk . transfer ( wallet . address , ONE_THOUSAND_PNK * 10n ) ;
132+ await pnk . transfer ( wallet . address , ONE_THOUSAND_PNK * 10n ) . then ( ( tx ) => tx . wait ( ) ) ;
129133 expect ( await pnk . balanceOf ( wallet . address ) ) . to . equal ( ONE_THOUSAND_PNK * 10n ) ;
130134
131- await pnk . connect ( wallet ) . approve ( core . target , ONE_THOUSAND_PNK * 10n , { gasLimit : 300000 } ) ;
135+ await pnk
136+ . connect ( wallet )
137+ . approve ( core . target , ONE_THOUSAND_PNK * 10n , { gasLimit : 300000 } )
138+ . then ( ( tx ) => tx . wait ( ) ) ;
132139
133140 await stake ( wallet ) ;
134141 }
@@ -159,22 +166,23 @@ describe("Draw Benchmark", async () => {
159166 extraData : `0x000000000000000000000000000000000000000000000000000000000000000${ createDisputeCourtId } 0000000000000000000000000000000000000000000000000000000000000003` ,
160167 } ,
161168 { value : arbitrationCost }
162- ) ;
169+ )
170+ . then ( ( tx ) => tx . wait ( ) ) ;
163171
164172 await network . provider . send ( "evm_increaseTime" , [ 2000 ] ) ; // Wait for minStakingTime
165173 await network . provider . send ( "evm_mine" ) ;
166- await sortitionModule . passPhase ( ) ; // Staking -> Generating
174+ await sortitionModule . passPhase ( ) . then ( ( tx ) => tx . wait ( ) ) ; // Staking -> Generating
167175
168176 const lookahead = await sortitionModule . rngLookahead ( ) ;
169177 for ( let index = 0 ; index < lookahead ; index ++ ) {
170178 await network . provider . send ( "evm_mine" ) ;
171179 }
172180
173- await sortitionModule . passPhase ( ) ; // Generating -> Drawing
181+ await sortitionModule . passPhase ( ) . then ( ( tx ) => tx . wait ( ) ) ; // Generating -> Drawing
174182 await expectFromDraw ( core . draw ( 0 , 20 , { gasLimit : 1000000 } ) ) ;
175183
176184 await network . provider . send ( "evm_increaseTime" , [ 2000 ] ) ; // Wait for maxDrawingTime
177- await sortitionModule . passPhase ( ) ; // Drawing -> Staking
185+ await sortitionModule . passPhase ( ) . then ( ( tx ) => tx . wait ( ) ) ; // Drawing -> Staking
178186 expect ( await sortitionModule . phase ( ) ) . to . equal ( Phase . staking ) ;
179187
180188 // Unstake jurors
@@ -194,7 +202,10 @@ describe("Draw Benchmark", async () => {
194202
195203 it ( "Stakes in parent court and should draw jurors in parent court" , async ( ) => {
196204 const stake = async ( wallet : HDNodeWallet ) => {
197- await core . connect ( wallet ) . setStake ( PARENT_COURT , ONE_THOUSAND_PNK * 5n , { gasLimit : 5000000 } ) ;
205+ await core
206+ . connect ( wallet )
207+ . setStake ( PARENT_COURT , ONE_THOUSAND_PNK * 5n , { gasLimit : 5000000 } )
208+ . then ( ( tx ) => tx . wait ( ) ) ;
198209
199210 expect ( await sortitionModule . getJurorBalance ( wallet . address , 1 ) ) . to . deep . equal ( [
200211 ONE_THOUSAND_PNK * 5n , // totalStaked
@@ -205,9 +216,6 @@ describe("Draw Benchmark", async () => {
205216 } ;
206217 let countedDraws : CountedDraws ;
207218 const expectFromDraw = async ( drawTx : Promise < ContractTransactionResponse > ) => {
208- console . log ( ( await core . getRoundInfo ( 0 , 0 ) ) . drawIterations ) ;
209- expect ( await core . getRoundInfo ( 0 , 0 ) . then ( ( round ) => round . drawIterations ) ) . to . equal ( 3 ) ;
210-
211219 const tx = await ( await drawTx ) . wait ( ) ;
212220 if ( ! tx ) throw new Error ( "Failed to get transaction receipt" ) ;
213221 expect ( tx )
@@ -233,10 +241,14 @@ describe("Draw Benchmark", async () => {
233241 1 , // nbOfCourts
234242 ] ) ;
235243 }
244+ expect ( await core . getRoundInfo ( 0 , 0 ) . then ( ( round ) => round . drawIterations ) ) . to . equal ( 3 ) ;
236245 } ;
237246
238247 const unstake = async ( wallet : HDNodeWallet ) => {
239- await core . connect ( wallet ) . setStake ( PARENT_COURT , 0 , { gasLimit : 5000000 } ) ;
248+ await core
249+ . connect ( wallet )
250+ . setStake ( PARENT_COURT , 0 , { gasLimit : 5000000 } )
251+ . then ( ( tx ) => tx . wait ( ) ) ;
240252 const locked = parentCourtMinStake * toBigInt ( countedDraws [ wallet . address ] ?? 0 ) ;
241253 expect (
242254 await sortitionModule . getJurorBalance ( wallet . address , PARENT_COURT ) ,
@@ -261,20 +273,24 @@ describe("Draw Benchmark", async () => {
261273 await draw ( stake , PARENT_COURT , expectFromDraw , unstake ) ;
262274 } ) ;
263275
264- // Warning: we are skipping this during `hardhat coverage` because it fails, although it passes with `hardhat test`
265276 it ( "Stakes in parent court and should draw nobody in subcourt [ @skip-on-coverage ]" , async ( ) => {
266277 const stake = async ( wallet : HDNodeWallet ) => {
267- await core . connect ( wallet ) . setStake ( PARENT_COURT , ONE_THOUSAND_PNK * 5n , { gasLimit : 5000000 } ) ;
278+ await core
279+ . connect ( wallet )
280+ . setStake ( PARENT_COURT , ONE_THOUSAND_PNK * 5n , { gasLimit : 5000000 } )
281+ . then ( ( tx ) => tx . wait ( ) ) ;
268282 } ;
269283
270284 const expectFromDraw = async ( drawTx : Promise < ContractTransactionResponse > ) => {
271- console . log ( ( await core . getRoundInfo ( 0 , 0 ) ) . drawIterations ) ;
272- expect ( await core . getRoundInfo ( 0 , 0 ) . then ( ( round ) => round . drawIterations ) ) . to . equal ( 20 ) ;
273285 expect ( await drawTx ) . to . not . emit ( core , "Draw" ) ;
286+ expect ( await core . getRoundInfo ( 0 , 0 ) . then ( ( round ) => round . drawIterations ) ) . to . equal ( 20 ) ;
274287 } ;
275288
276289 const unstake = async ( wallet : HDNodeWallet ) => {
277- await core . connect ( wallet ) . setStake ( PARENT_COURT , 0 , { gasLimit : 5000000 } ) ;
290+ await core
291+ . connect ( wallet )
292+ . setStake ( PARENT_COURT , 0 , { gasLimit : 5000000 } )
293+ . then ( ( tx ) => tx . wait ( ) ) ;
278294 expect (
279295 await sortitionModule . getJurorBalance ( wallet . address , PARENT_COURT ) ,
280296 "No locked stake in the parent court"
@@ -300,13 +316,13 @@ describe("Draw Benchmark", async () => {
300316
301317 it ( "Stakes in subcourt and should draw jurors in parent court" , async ( ) => {
302318 const stake = async ( wallet : HDNodeWallet ) => {
303- await core . connect ( wallet ) . setStake ( CHILD_COURT , ONE_THOUSAND_PNK * 5n , { gasLimit : 5000000 } ) ;
319+ await core
320+ . connect ( wallet )
321+ . setStake ( CHILD_COURT , ONE_THOUSAND_PNK * 5n , { gasLimit : 5000000 } )
322+ . then ( ( tx ) => tx . wait ( ) ) ;
304323 } ;
305324 let countedDraws : CountedDraws ;
306325 const expectFromDraw = async ( drawTx : Promise < ContractTransactionResponse > ) => {
307- console . log ( ( await core . getRoundInfo ( 0 , 0 ) ) . drawIterations ) ;
308- expect ( await core . getRoundInfo ( 0 , 0 ) . then ( ( round ) => round . drawIterations ) ) . to . equal ( 3 ) ;
309-
310326 const tx = await ( await drawTx ) . wait ( ) ;
311327 if ( ! tx ) throw new Error ( "Failed to get transaction receipt" ) ;
312328 expect ( tx )
@@ -332,10 +348,14 @@ describe("Draw Benchmark", async () => {
332348 1 , // nbOfCourts
333349 ] ) ;
334350 }
351+ expect ( await core . getRoundInfo ( 0 , 0 ) . then ( ( round ) => round . drawIterations ) ) . to . equal ( 3 ) ;
335352 } ;
336353
337354 const unstake = async ( wallet : HDNodeWallet ) => {
338- await core . connect ( wallet ) . setStake ( CHILD_COURT , 0 , { gasLimit : 5000000 } ) ;
355+ await core
356+ . connect ( wallet )
357+ . setStake ( CHILD_COURT , 0 , { gasLimit : 5000000 } )
358+ . then ( ( tx ) => tx . wait ( ) ) ;
339359 const locked = parentCourtMinStake * toBigInt ( countedDraws [ wallet . address ] ?? 0 ) ;
340360 expect (
341361 await sortitionModule . getJurorBalance ( wallet . address , PARENT_COURT ) ,
@@ -362,13 +382,13 @@ describe("Draw Benchmark", async () => {
362382
363383 it ( "Stakes in subcourt and should draw jurors in subcourt" , async ( ) => {
364384 const stake = async ( wallet : HDNodeWallet ) => {
365- await core . connect ( wallet ) . setStake ( CHILD_COURT , ONE_THOUSAND_PNK * 5n , { gasLimit : 5000000 } ) ;
385+ await core
386+ . connect ( wallet )
387+ . setStake ( CHILD_COURT , ONE_THOUSAND_PNK * 5n , { gasLimit : 5000000 } )
388+ . then ( ( tx ) => tx . wait ( ) ) ;
366389 } ;
367390 let countedDraws : CountedDraws ;
368391 const expectFromDraw = async ( drawTx : Promise < ContractTransactionResponse > ) => {
369- console . log ( ( await core . getRoundInfo ( 0 , 0 ) ) . drawIterations ) ;
370- expect ( await core . getRoundInfo ( 0 , 0 ) . then ( ( round ) => round . drawIterations ) ) . to . equal ( 3 ) ;
371-
372392 const tx = await ( await drawTx ) . wait ( ) ;
373393 if ( ! tx ) throw new Error ( "Failed to get transaction receipt" ) ;
374394 expect ( tx )
@@ -394,10 +414,14 @@ describe("Draw Benchmark", async () => {
394414 1 , // nbOfCourts
395415 ] ) ;
396416 }
417+ expect ( await core . getRoundInfo ( 0 , 0 ) . then ( ( round ) => round . drawIterations ) ) . to . equal ( 3 ) ;
397418 } ;
398419
399420 const unstake = async ( wallet : HDNodeWallet ) => {
400- await core . connect ( wallet ) . setStake ( CHILD_COURT , 0 , { gasLimit : 5000000 } ) ;
421+ await core
422+ . connect ( wallet )
423+ . setStake ( CHILD_COURT , 0 , { gasLimit : 5000000 } )
424+ . then ( ( tx ) => tx . wait ( ) ) ;
401425 const locked = childCourtMinStake * toBigInt ( countedDraws [ wallet . address ] ?? 0 ) ;
402426 expect (
403427 await sortitionModule . getJurorBalance ( wallet . address , PARENT_COURT ) ,
0 commit comments