@@ -17,8 +17,8 @@ import { Courts } from "../../deploy/utils";
17
17
/* eslint-disable no-unused-expressions */ // https://github.com/standard/standard/issues/690#issuecomment-278533482
18
18
19
19
describe ( "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 ;
22
22
23
23
const enum Period {
24
24
evidence , // Evidence can be submitted. This is also when drawing has to take place.
@@ -39,8 +39,8 @@ describe("Draw Benchmark", async () => {
39
39
drawing , // Jurors can be drawn.
40
40
}
41
41
42
- let deployer ;
43
- let relayer ;
42
+ let deployer : string ;
43
+ let relayer : string ;
44
44
let disputeKit : DisputeKitClassic ;
45
45
let pnk : PNK ;
46
46
let core : KlerosCore ;
@@ -50,7 +50,7 @@ describe("Draw Benchmark", async () => {
50
50
let rng : IncrementalNG ;
51
51
let parentCourtMinStake : bigint ;
52
52
let childCourtMinStake : bigint ;
53
- const RANDOM = toBigInt ( "61688911660239508166491237672720926005752254046266901728404745669596507231249" ) ;
53
+ const RANDOM = 61688911660239508166491237672720926005752254046266901728404745669596507231249n ;
54
54
const PARENT_COURT = 1 ;
55
55
const CHILD_COURT = 2 ;
56
56
const abiCoder = ethers . AbiCoder . defaultAbiCoder ( ) ;
@@ -71,7 +71,7 @@ describe("Draw Benchmark", async () => {
71
71
72
72
parentCourtMinStake = await core . courts ( Courts . GENERAL ) . then ( ( court ) => court . minStake ) ;
73
73
74
- childCourtMinStake = toBigInt ( 10 ) ** toBigInt ( 20 ) * toBigInt ( 3 ) ; // 300 PNK
74
+ childCourtMinStake = 3n * 10n ** 20n ; // 300 PNK
75
75
76
76
// Make the tests more deterministic with this dummy RNG
77
77
await deployments . deploy ( "IncrementalNG" , {
@@ -84,9 +84,9 @@ describe("Draw Benchmark", async () => {
84
84
await sortitionModule . changeRandomNumberGenerator ( rng . target , 20 ) ;
85
85
86
86
// 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 ;
90
90
await core . createCourt (
91
91
1 ,
92
92
false ,
@@ -110,7 +110,7 @@ describe("Draw Benchmark", async () => {
110
110
expectFromDraw : ExpectFromDraw ,
111
111
unstake : SetStake
112
112
) => {
113
- const arbitrationCost = ONE_TENTH_ETH * toBigInt ( 3 ) ;
113
+ const arbitrationCost = ONE_TENTH_ETH * 3n ;
114
114
const [ bridger ] = await ethers . getSigners ( ) ;
115
115
const wallets : HDNodeWallet [ ] = [ ] ;
116
116
@@ -125,10 +125,10 @@ describe("Draw Benchmark", async () => {
125
125
} ) ;
126
126
expect ( await ethers . provider . getBalance ( wallet ) ) . to . equal ( ethers . parseEther ( "10" ) ) ;
127
127
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 ) ;
130
130
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 } ) ;
132
132
133
133
await stake ( wallet ) ;
134
134
}
@@ -147,7 +147,7 @@ describe("Draw Benchmark", async () => {
147
147
. connect ( await ethers . getSigner ( relayer ) )
148
148
[ "relayCreateDispute((bytes32,uint256,address,uint256,uint256,uint256,string,uint256,bytes))" ] (
149
149
{
150
- foreignBlockHash : ethers . toBeHex ( lastBlock ?. hash ) ,
150
+ foreignBlockHash : lastBlock ?. hash ,
151
151
foreignChainID : 31337 ,
152
152
foreignArbitrable : arbitrable . target ,
153
153
foreignDisputeID : disputeId ,
@@ -193,12 +193,12 @@ describe("Draw Benchmark", async () => {
193
193
194
194
it ( "Stakes in parent court and should draw jurors in parent court" , async ( ) => {
195
195
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 } ) ;
197
197
198
198
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
202
202
PARENT_COURT , // nbOfCourts
203
203
] ) ;
204
204
} ;
@@ -219,15 +219,15 @@ describe("Draw Benchmark", async () => {
219
219
countedDraws = await countDraws ( tx . blockNumber ) ;
220
220
for ( const [ address , draws ] of Object . entries ( countedDraws ) ) {
221
221
expect ( await sortitionModule . getJurorBalance ( address , PARENT_COURT ) ) . to . deep . equal ( [
222
- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // totalStaked
222
+ ONE_THOUSAND_PNK * 5n , // totalStaked
223
223
parentCourtMinStake * toBigInt ( draws ) , // totalLocked
224
- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // stakedInCourt
224
+ ONE_THOUSAND_PNK * 5n , // stakedInCourt
225
225
1 , // nbOfCourts
226
226
] ) ;
227
227
expect ( await sortitionModule . getJurorBalance ( address , CHILD_COURT ) ) . to . deep . equal ( [
228
- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // totalStaked
228
+ ONE_THOUSAND_PNK * 5n , // totalStaked
229
229
parentCourtMinStake * toBigInt ( draws ) , // totalLocked
230
- 0 , // stakedInCourt
230
+ 0n , // stakedInCourt
231
231
1 , // nbOfCourts
232
232
] ) ;
233
233
}
@@ -262,7 +262,7 @@ describe("Draw Benchmark", async () => {
262
262
// Warning: we are skipping this during `hardhat coverage` because it fails, although it passes with `hardhat test`
263
263
it ( "Stakes in parent court and should draw nobody in subcourt [ @skip-on-coverage ]" , async ( ) => {
264
264
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 } ) ;
266
266
} ;
267
267
268
268
const expectFromDraw = async ( drawTx : Promise < ContractTransactionResponse > ) => {
@@ -298,7 +298,7 @@ describe("Draw Benchmark", async () => {
298
298
299
299
it ( "Stakes in subcourt and should draw jurors in parent court" , async ( ) => {
300
300
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 } ) ;
302
302
} ;
303
303
let countedDraws : CountedDraws ;
304
304
const expectFromDraw = async ( drawTx : Promise < ContractTransactionResponse > ) => {
@@ -318,15 +318,15 @@ describe("Draw Benchmark", async () => {
318
318
countedDraws = await countDraws ( tx . blockNumber ) ;
319
319
for ( const [ address , draws ] of Object . entries ( countedDraws ) ) {
320
320
expect ( await sortitionModule . getJurorBalance ( address , PARENT_COURT ) ) . to . deep . equal ( [
321
- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // totalStaked
321
+ ONE_THOUSAND_PNK * 5n , // totalStaked
322
322
parentCourtMinStake * toBigInt ( draws ) , // totalLocked
323
323
0 , // stakedInCourt
324
324
1 , // nbOfCourts
325
325
] ) ;
326
326
expect ( await sortitionModule . getJurorBalance ( address , CHILD_COURT ) ) . to . deep . equal ( [
327
- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // totalStaked
327
+ ONE_THOUSAND_PNK * 5n , // totalStaked
328
328
parentCourtMinStake * toBigInt ( draws ) , // totalLocked
329
- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // stakedInCourt
329
+ ONE_THOUSAND_PNK * 5n , // stakedInCourt
330
330
1 , // nbOfCourts
331
331
] ) ;
332
332
}
@@ -360,7 +360,7 @@ describe("Draw Benchmark", async () => {
360
360
361
361
it ( "Stakes in subcourt and should draw jurors in subcourt" , async ( ) => {
362
362
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 } ) ;
364
364
} ;
365
365
let countedDraws : CountedDraws ;
366
366
const expectFromDraw = async ( drawTx : Promise < ContractTransactionResponse > ) => {
@@ -380,15 +380,15 @@ describe("Draw Benchmark", async () => {
380
380
countedDraws = await countDraws ( tx . blockNumber ) ;
381
381
for ( const [ address , draws ] of Object . entries ( countedDraws ) ) {
382
382
expect ( await sortitionModule . getJurorBalance ( address , PARENT_COURT ) ) . to . deep . equal ( [
383
- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // totalStaked
383
+ ONE_THOUSAND_PNK * 5n , // totalStaked
384
384
childCourtMinStake * toBigInt ( draws ) , // totalLocked
385
- 0 , // stakedInCourt
385
+ 0n , // stakedInCourt
386
386
1 , // nbOfCourts
387
387
] ) ;
388
388
expect ( await sortitionModule . getJurorBalance ( address , CHILD_COURT ) ) . to . deep . equal ( [
389
- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // totalStaked
389
+ ONE_THOUSAND_PNK * 5n , // totalStaked
390
390
childCourtMinStake * toBigInt ( draws ) , // totalLocked
391
- ONE_THOUSAND_PNK * toBigInt ( 5 ) , // stakedInCourt
391
+ ONE_THOUSAND_PNK * 5n , // stakedInCourt
392
392
1 , // nbOfCourts
393
393
] ) ;
394
394
}
0 commit comments