@@ -17,8 +17,8 @@ import { Courts } from "../../deploy/utils";
1717/* eslint-disable no-unused-expressions */ // https://github.com/standard/standard/issues/690#issuecomment-278533482
1818
1919describe ( "Draw Benchmark" , async ( ) => {
20- const ONE_TENTH_ETH = toBigInt ( 10 ) ** toBigInt ( 17 ) ;
21- const ONE_THOUSAND_PNK = toBigInt ( 10 ) ** toBigInt ( 21 ) ;
20+ const ONE_TENTH_ETH = 10n ** 17n ;
21+ const ONE_THOUSAND_PNK = 10n ** 21n ;
2222
2323 const enum Period {
2424 evidence , // Evidence can be submitted. This is also when drawing has to take place.
@@ -39,8 +39,8 @@ describe("Draw Benchmark", async () => {
3939 drawing , // Jurors can be drawn.
4040 }
4141
42- let deployer ;
43- let relayer ;
42+ let deployer : string ;
43+ let relayer : string ;
4444 let disputeKit : DisputeKitClassic ;
4545 let pnk : PNK ;
4646 let core : KlerosCore ;
@@ -50,7 +50,7 @@ describe("Draw Benchmark", async () => {
5050 let rng : IncrementalNG ;
5151 let parentCourtMinStake : bigint ;
5252 let childCourtMinStake : bigint ;
53- const RANDOM = toBigInt ( "61688911660239508166491237672720926005752254046266901728404745669596507231249" ) ;
53+ const RANDOM = 61688911660239508166491237672720926005752254046266901728404745669596507231249n ;
5454 const PARENT_COURT = 1 ;
5555 const CHILD_COURT = 2 ;
5656 const abiCoder = ethers . AbiCoder . defaultAbiCoder ( ) ;
@@ -71,7 +71,7 @@ describe("Draw Benchmark", async () => {
7171
7272 parentCourtMinStake = await core . courts ( Courts . GENERAL ) . then ( ( court ) => court . minStake ) ;
7373
74- childCourtMinStake = toBigInt ( 10 ) ** toBigInt ( 20 ) * toBigInt ( 3 ) ; // 300 PNK
74+ childCourtMinStake = 3n * 10n ** 20n ; // 300 PNK
7575
7676 // Make the tests more deterministic with this dummy RNG
7777 await deployments . deploy ( "IncrementalNG" , {
@@ -84,9 +84,9 @@ describe("Draw Benchmark", async () => {
8484 await sortitionModule . changeRandomNumberGenerator ( rng . target , 20 ) ;
8585
8686 // CourtId 2 = CHILD_COURT
87- const minStake = toBigInt ( 10 ) ** toBigInt ( 20 ) * toBigInt ( 3 ) ; // 300 PNK
88- const alpha = 10000 ;
89- const feeForJuror = toBigInt ( 10 ) ** toBigInt ( 17 ) ;
87+ const minStake = 3n * 10n ** 20n ; // 300 PNK
88+ const alpha = 10000n ;
89+ const feeForJuror = 10n * 17n ;
9090 await core . createCourt (
9191 1 ,
9292 false ,
@@ -110,7 +110,7 @@ describe("Draw Benchmark", async () => {
110110 expectFromDraw : ExpectFromDraw ,
111111 unstake : SetStake
112112 ) => {
113- const arbitrationCost = ONE_TENTH_ETH * toBigInt ( 3 ) ;
113+ const arbitrationCost = ONE_TENTH_ETH * 3n ;
114114 const [ bridger ] = await ethers . getSigners ( ) ;
115115 const wallets : HDNodeWallet [ ] = [ ] ;
116116
@@ -125,10 +125,10 @@ describe("Draw Benchmark", async () => {
125125 } ) ;
126126 expect ( await ethers . provider . getBalance ( wallet ) ) . to . equal ( ethers . parseEther ( "10" ) ) ;
127127
128- await pnk . transfer ( wallet . address , ONE_THOUSAND_PNK * toBigInt ( 10 ) ) ;
129- expect ( await pnk . balanceOf ( wallet . address ) ) . to . equal ( ONE_THOUSAND_PNK * toBigInt ( 10 ) ) ;
128+ await pnk . transfer ( wallet . address , ONE_THOUSAND_PNK * 10n ) ;
129+ expect ( await pnk . balanceOf ( wallet . address ) ) . to . equal ( ONE_THOUSAND_PNK * 10n ) ;
130130
131- await pnk . connect ( wallet ) . approve ( core . target , ONE_THOUSAND_PNK * toBigInt ( 10 ) , { gasLimit : 300000 } ) ;
131+ await pnk . connect ( wallet ) . approve ( core . target , ONE_THOUSAND_PNK * 10n , { gasLimit : 300000 } ) ;
132132
133133 await stake ( wallet ) ;
134134 }
@@ -147,7 +147,7 @@ describe("Draw Benchmark", async () => {
147147 . connect ( await ethers . getSigner ( relayer ) )
148148 [ "relayCreateDispute((bytes32,uint256,address,uint256,uint256,uint256,string,uint256,bytes))" ] (
149149 {
150- foreignBlockHash : ethers . toBeHex ( lastBlock ?. hash ) ,
150+ foreignBlockHash : lastBlock ?. hash ,
151151 foreignChainID : 31337 ,
152152 foreignArbitrable : arbitrable . target ,
153153 foreignDisputeID : disputeId ,
@@ -193,12 +193,12 @@ describe("Draw Benchmark", async () => {
193193
194194 it ( "Stakes in parent court and should draw jurors in parent court" , async ( ) => {
195195 const stake = async ( wallet : HDNodeWallet ) => {
196- await core . connect ( wallet ) . setStake ( PARENT_COURT , ONE_THOUSAND_PNK * toBigInt ( 5 ) , { gasLimit : 5000000 } ) ;
196+ await core . connect ( wallet ) . setStake ( PARENT_COURT , ONE_THOUSAND_PNK * 5n , { gasLimit : 5000000 } ) ;
197197
198198 expect ( await sortitionModule . getJurorBalance ( wallet . address , 1 ) ) . to . deep . equal ( [
199- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // totalStaked
200- 0 , // totalLocked
201- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // stakedInCourt
199+ ONE_THOUSAND_PNK * 5n , // totalStaked
200+ 0n , // totalLocked
201+ ONE_THOUSAND_PNK * 5n , // stakedInCourt
202202 PARENT_COURT , // nbOfCourts
203203 ] ) ;
204204 } ;
@@ -219,15 +219,15 @@ describe("Draw Benchmark", async () => {
219219 countedDraws = await countDraws ( tx . blockNumber ) ;
220220 for ( const [ address , draws ] of Object . entries ( countedDraws ) ) {
221221 expect ( await sortitionModule . getJurorBalance ( address , PARENT_COURT ) ) . to . deep . equal ( [
222- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // totalStaked
222+ ONE_THOUSAND_PNK * 5n , // totalStaked
223223 parentCourtMinStake * toBigInt ( draws ) , // totalLocked
224- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // stakedInCourt
224+ ONE_THOUSAND_PNK * 5n , // stakedInCourt
225225 1 , // nbOfCourts
226226 ] ) ;
227227 expect ( await sortitionModule . getJurorBalance ( address , CHILD_COURT ) ) . to . deep . equal ( [
228- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // totalStaked
228+ ONE_THOUSAND_PNK * 5n , // totalStaked
229229 parentCourtMinStake * toBigInt ( draws ) , // totalLocked
230- 0 , // stakedInCourt
230+ 0n , // stakedInCourt
231231 1 , // nbOfCourts
232232 ] ) ;
233233 }
@@ -262,7 +262,7 @@ describe("Draw Benchmark", async () => {
262262 // Warning: we are skipping this during `hardhat coverage` because it fails, although it passes with `hardhat test`
263263 it ( "Stakes in parent court and should draw nobody in subcourt [ @skip-on-coverage ]" , async ( ) => {
264264 const stake = async ( wallet : HDNodeWallet ) => {
265- await core . connect ( wallet ) . setStake ( PARENT_COURT , ONE_THOUSAND_PNK * toBigInt ( 5 ) , { gasLimit : 5000000 } ) ;
265+ await core . connect ( wallet ) . setStake ( PARENT_COURT , ONE_THOUSAND_PNK * 5n , { gasLimit : 5000000 } ) ;
266266 } ;
267267
268268 const expectFromDraw = async ( drawTx : Promise < ContractTransactionResponse > ) => {
@@ -298,7 +298,7 @@ describe("Draw Benchmark", async () => {
298298
299299 it ( "Stakes in subcourt and should draw jurors in parent court" , async ( ) => {
300300 const stake = async ( wallet : HDNodeWallet ) => {
301- await core . connect ( wallet ) . setStake ( CHILD_COURT , ONE_THOUSAND_PNK * toBigInt ( 5 ) , { gasLimit : 5000000 } ) ;
301+ await core . connect ( wallet ) . setStake ( CHILD_COURT , ONE_THOUSAND_PNK * 5n , { gasLimit : 5000000 } ) ;
302302 } ;
303303 let countedDraws : CountedDraws ;
304304 const expectFromDraw = async ( drawTx : Promise < ContractTransactionResponse > ) => {
@@ -318,15 +318,15 @@ describe("Draw Benchmark", async () => {
318318 countedDraws = await countDraws ( tx . blockNumber ) ;
319319 for ( const [ address , draws ] of Object . entries ( countedDraws ) ) {
320320 expect ( await sortitionModule . getJurorBalance ( address , PARENT_COURT ) ) . to . deep . equal ( [
321- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // totalStaked
321+ ONE_THOUSAND_PNK * 5n , // totalStaked
322322 parentCourtMinStake * toBigInt ( draws ) , // totalLocked
323323 0 , // stakedInCourt
324324 1 , // nbOfCourts
325325 ] ) ;
326326 expect ( await sortitionModule . getJurorBalance ( address , CHILD_COURT ) ) . to . deep . equal ( [
327- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // totalStaked
327+ ONE_THOUSAND_PNK * 5n , // totalStaked
328328 parentCourtMinStake * toBigInt ( draws ) , // totalLocked
329- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // stakedInCourt
329+ ONE_THOUSAND_PNK * 5n , // stakedInCourt
330330 1 , // nbOfCourts
331331 ] ) ;
332332 }
@@ -360,7 +360,7 @@ describe("Draw Benchmark", async () => {
360360
361361 it ( "Stakes in subcourt and should draw jurors in subcourt" , async ( ) => {
362362 const stake = async ( wallet : HDNodeWallet ) => {
363- await core . connect ( wallet ) . setStake ( CHILD_COURT , ONE_THOUSAND_PNK * toBigInt ( 5 ) , { gasLimit : 5000000 } ) ;
363+ await core . connect ( wallet ) . setStake ( CHILD_COURT , ONE_THOUSAND_PNK * 5n , { gasLimit : 5000000 } ) ;
364364 } ;
365365 let countedDraws : CountedDraws ;
366366 const expectFromDraw = async ( drawTx : Promise < ContractTransactionResponse > ) => {
@@ -380,15 +380,15 @@ describe("Draw Benchmark", async () => {
380380 countedDraws = await countDraws ( tx . blockNumber ) ;
381381 for ( const [ address , draws ] of Object . entries ( countedDraws ) ) {
382382 expect ( await sortitionModule . getJurorBalance ( address , PARENT_COURT ) ) . to . deep . equal ( [
383- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // totalStaked
383+ ONE_THOUSAND_PNK * 5n , // totalStaked
384384 childCourtMinStake * toBigInt ( draws ) , // totalLocked
385- 0 , // stakedInCourt
385+ 0n , // stakedInCourt
386386 1 , // nbOfCourts
387387 ] ) ;
388388 expect ( await sortitionModule . getJurorBalance ( address , CHILD_COURT ) ) . to . deep . equal ( [
389- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // totalStaked
389+ ONE_THOUSAND_PNK * 5n , // totalStaked
390390 childCourtMinStake * toBigInt ( draws ) , // totalLocked
391- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // stakedInCourt
391+ ONE_THOUSAND_PNK * 5n , // stakedInCourt
392392 1 , // nbOfCourts
393393 ] ) ;
394394 }
0 commit comments