@@ -52,7 +52,7 @@ describe('SFC', () => {
52
52
to : this . sfc ,
53
53
value : 1 ,
54
54
} ) ,
55
- ) . to . revertedWithCustomError ( this . sfc , 'TransfersNotAllowed' ) ;
55
+ ) . to . revertedWithCustomError ( this . sfcLib , 'TransfersNotAllowed' ) ;
56
56
} ) ;
57
57
58
58
describe ( 'Genesis validator' , ( ) => {
@@ -77,11 +77,14 @@ describe('SFC', () => {
77
77
} ) ;
78
78
79
79
it ( 'Should revert when sealEpoch not called by node' , async function ( ) {
80
- await expect ( this . sfc . sealEpoch ( [ 1 ] , [ 1 ] , [ 1 ] , [ 1 ] , 0 ) ) . to . be . revertedWithCustomError ( this . sfc , 'NotDriverAuth' ) ;
80
+ await expect ( this . sfc . sealEpoch ( [ 1 ] , [ 1 ] , [ 1 ] , [ 1 ] , 0 ) ) . to . be . revertedWithCustomError (
81
+ this . sfcLib ,
82
+ 'NotDriverAuth' ,
83
+ ) ;
81
84
} ) ;
82
85
83
86
it ( 'Should revert when SealEpochValidators not called by node' , async function ( ) {
84
- await expect ( this . sfc . sealEpochValidators ( [ 1 ] ) ) . to . be . revertedWithCustomError ( this . sfc , 'NotDriverAuth' ) ;
87
+ await expect ( this . sfc . sealEpochValidators ( [ 1 ] ) ) . to . be . revertedWithCustomError ( this . sfcLib , 'NotDriverAuth' ) ;
85
88
} ) ;
86
89
} ) ;
87
90
@@ -176,13 +179,13 @@ describe('SFC', () => {
176
179
this . sfc
177
180
. connect ( this . validator )
178
181
. createValidator ( ethers . Wallet . createRandom ( ) . publicKey , { value : ethers . parseEther ( '0.1' ) } ) ,
179
- ) . to . be . revertedWithCustomError ( this . sfc , 'InsufficientSelfStake' ) ;
182
+ ) . to . be . revertedWithCustomError ( this . sfcLib , 'InsufficientSelfStake' ) ;
180
183
} ) ;
181
184
182
185
it ( 'Should revert when public key is empty while creating a validator' , async function ( ) {
183
186
await expect (
184
187
this . sfc . connect ( this . validator ) . createValidator ( '0x' , { value : ethers . parseEther ( '0.4' ) } ) ,
185
- ) . to . be . revertedWithCustomError ( this . sfc , 'EmptyPubkey' ) ;
188
+ ) . to . be . revertedWithCustomError ( this . sfcLib , 'EmptyPubkey' ) ;
186
189
} ) ;
187
190
188
191
it ( 'Should succeed and create two validators and return id of last validator' , async function ( ) {
@@ -213,7 +216,7 @@ describe('SFC', () => {
213
216
it ( 'Should revert when staking to non-existing validator' , async function ( ) {
214
217
await expect (
215
218
this . sfc . connect ( this . secondValidator ) . delegate ( 1 , { value : ethers . parseEther ( '0.1' ) } ) ,
216
- ) . to . be . revertedWithCustomError ( this . sfc , 'ValidatorNotExists' ) ;
219
+ ) . to . be . revertedWithCustomError ( this . sfcLib , 'ValidatorNotExists' ) ;
217
220
} ) ;
218
221
219
222
it ( 'Should succeed and stake with different delegators' , async function ( ) {
@@ -328,13 +331,13 @@ describe('SFC', () => {
328
331
0 ,
329
332
0 ,
330
333
) ,
331
- ) . to . be . revertedWithCustomError ( this . sfc , 'NotDriverAuth' ) ;
334
+ ) . to . be . revertedWithCustomError ( this . sfcLib , 'NotDriverAuth' ) ;
332
335
} ) ;
333
336
334
337
it ( 'Should revert when setGenesisDelegation is not called not node' , async function ( ) {
335
338
const delegator = ethers . Wallet . createRandom ( ) ;
336
339
await expect ( this . sfc . setGenesisDelegation ( delegator , 1 , 100 , 0 , 0 , 0 , 0 , 0 , 1000 ) ) . to . be . revertedWithCustomError (
337
- this . sfc ,
340
+ this . sfcLib ,
338
341
'NotDriverAuth' ,
339
342
) ;
340
343
} ) ;
@@ -440,7 +443,7 @@ describe('SFC', () => {
440
443
this . sfc
441
444
. connect ( validator )
442
445
. createValidator ( ethers . Wallet . createRandom ( ) . publicKey , { value : ethers . parseEther ( '0.1' ) } ) ,
443
- ) . to . be . revertedWithCustomError ( this . sfc , 'InsufficientSelfStake' ) ;
446
+ ) . to . be . revertedWithCustomError ( this . sfcLib , 'InsufficientSelfStake' ) ;
444
447
445
448
await node . handleTx (
446
449
await this . sfc . connect ( validator ) . createValidator ( pubkey , { value : ethers . parseEther ( '0.3175' ) } ) ,
@@ -450,7 +453,7 @@ describe('SFC', () => {
450
453
this . sfc
451
454
. connect ( validator )
452
455
. createValidator ( ethers . Wallet . createRandom ( ) . publicKey , { value : ethers . parseEther ( '0.5' ) } ) ,
453
- ) . to . be . revertedWithCustomError ( this . sfc , 'ValidatorExists' ) ;
456
+ ) . to . be . revertedWithCustomError ( this . sfcLib , 'ValidatorExists' ) ;
454
457
455
458
await node . handleTx (
456
459
await this . sfc . connect ( secondValidator ) . createValidator ( secondPubkey , { value : ethers . parseEther ( '0.5' ) } ) ,
@@ -768,7 +771,7 @@ describe('SFC', () => {
768
771
it ( 'Should revert when deactivating validator if not Node' , async function ( ) {
769
772
await this . sfc . disableNonNodeCalls ( ) ;
770
773
await expect ( this . sfc . deactivateValidator ( this . validatorId , 0 ) ) . to . be . revertedWithCustomError (
771
- this . sfc ,
774
+ this . sfcLib ,
772
775
'NotDriverAuth' ,
773
776
) ;
774
777
} ) ;
@@ -1008,7 +1011,7 @@ describe('SFC', () => {
1008
1011
1009
1012
it ( 'Should revert when calling deactivateValidator with wrong status' , async function ( ) {
1010
1013
await expect ( this . sfc . deactivateValidator ( 1 , 0 ) ) . to . be . revertedWithCustomError (
1011
- this . sfc ,
1014
+ this . sfcLib ,
1012
1015
'WrongValidatorStatus' ,
1013
1016
) ;
1014
1017
} ) ;
@@ -1096,24 +1099,24 @@ describe('SFC', () => {
1096
1099
1097
1100
describe ( 'Epoch getters' , ( ) => {
1098
1101
it ( 'Should revert when trying to unlock stake if not lockedup' , async function ( ) {
1099
- await expect ( this . sfc . unlockStake ( 1 , 10 ) ) . to . be . revertedWithCustomError ( this . sfc , 'NotLockedUp' ) ;
1102
+ await expect ( this . sfc . unlockStake ( 1 , 10 ) ) . to . be . revertedWithCustomError ( this . sfcLib , 'NotLockedUp' ) ;
1100
1103
} ) ;
1101
1104
1102
1105
it ( 'Should revert when trying to unlock stake if amount is 0' , async function ( ) {
1103
- await expect ( this . sfc . unlockStake ( 1 , 0 ) ) . to . be . revertedWithCustomError ( this . sfc , 'ZeroAmount' ) ;
1106
+ await expect ( this . sfc . unlockStake ( 1 , 0 ) ) . to . be . revertedWithCustomError ( this . sfcLib , 'ZeroAmount' ) ;
1104
1107
} ) ;
1105
1108
1106
1109
it ( 'Should succeed and return slashed status' , async function ( ) {
1107
1110
expect ( await this . sfc . isSlashed ( 1 ) ) . to . equal ( false ) ;
1108
1111
} ) ;
1109
1112
1110
1113
it ( 'Should revert when delegating to an unexisting validator' , async function ( ) {
1111
- await expect ( this . sfc . delegate ( 4 ) ) . to . be . revertedWithCustomError ( this . sfc , 'ValidatorNotExists' ) ;
1114
+ await expect ( this . sfc . delegate ( 4 ) ) . to . be . revertedWithCustomError ( this . sfcLib , 'ValidatorNotExists' ) ;
1112
1115
} ) ;
1113
1116
1114
1117
it ( 'Should revert when delegating to an unexisting validator (2)' , async function ( ) {
1115
1118
await expect ( this . sfc . delegate ( 4 , { value : ethers . parseEther ( '1' ) } ) ) . to . be . revertedWithCustomError (
1116
- this . sfc ,
1119
+ this . sfcLib ,
1117
1120
'ValidatorNotExists' ,
1118
1121
) ;
1119
1122
} ) ;
@@ -1214,20 +1217,23 @@ describe('SFC', () => {
1214
1217
1215
1218
it ( 'Should revert when withdrawing nonexistent request' , async function ( ) {
1216
1219
await expect ( this . sfc . withdraw ( this . validatorId , 0 ) ) . to . be . revertedWithCustomError (
1217
- this . sfc ,
1220
+ this . sfcLib ,
1218
1221
'RequestNotExists' ,
1219
1222
) ;
1220
1223
} ) ;
1221
1224
1222
1225
it ( 'Should revert when undelegating 0 amount' , async function ( ) {
1223
1226
await this . blockchainNode . sealEpoch ( 1_000 ) ;
1224
- await expect ( this . sfc . undelegate ( this . validatorId , 0 , 0 ) ) . to . be . revertedWithCustomError ( this . sfc , 'ZeroAmount' ) ;
1227
+ await expect ( this . sfc . undelegate ( this . validatorId , 0 , 0 ) ) . to . be . revertedWithCustomError (
1228
+ this . sfcLib ,
1229
+ 'ZeroAmount' ,
1230
+ ) ;
1225
1231
} ) ;
1226
1232
1227
1233
it ( 'Should revert when undelegating if not enough unlocked stake' , async function ( ) {
1228
1234
await this . blockchainNode . sealEpoch ( 1_000 ) ;
1229
1235
await expect ( this . sfc . undelegate ( this . validatorId , 0 , 10 ) ) . to . be . revertedWithCustomError (
1230
- this . sfc ,
1236
+ this . sfcLib ,
1231
1237
'NotEnoughUnlockedStake' ,
1232
1238
) ;
1233
1239
} ) ;
@@ -1237,7 +1243,7 @@ describe('SFC', () => {
1237
1243
await this . sfc . connect ( this . thirdDelegator ) . delegate ( this . validatorId , { value : ethers . parseEther ( '1' ) } ) ;
1238
1244
await expect (
1239
1245
this . sfc . connect ( this . thirdDelegator ) . unlockStake ( this . validatorId , 10 ) ,
1240
- ) . to . be . revertedWithCustomError ( this . sfc , 'NotLockedUp' ) ;
1246
+ ) . to . be . revertedWithCustomError ( this . sfcLib , 'NotLockedUp' ) ;
1241
1247
} ) ;
1242
1248
1243
1249
it ( 'Should succeed and return the unlocked stake' , async function ( ) {
@@ -1253,7 +1259,7 @@ describe('SFC', () => {
1253
1259
await this . blockchainNode . sealEpoch ( 1_000 ) ;
1254
1260
await expect (
1255
1261
this . sfc . connect ( this . thirdDelegator ) . claimRewards ( this . validatorId ) ,
1256
- ) . to . be . revertedWithCustomError ( this . sfc , 'ZeroRewards' ) ;
1262
+ ) . to . be . revertedWithCustomError ( this . sfcLib , 'ZeroRewards' ) ;
1257
1263
} ) ;
1258
1264
} ) ;
1259
1265
@@ -1271,7 +1277,7 @@ describe('SFC', () => {
1271
1277
this . sfc
1272
1278
. connect ( this . thirdDelegator )
1273
1279
. lockStake ( this . validatorId , 2 * 60 * 60 * 24 * 365 , ethers . parseEther ( '0' ) ) ,
1274
- ) . to . be . revertedWithCustomError ( this . sfc , 'ZeroAmount' ) ;
1280
+ ) . to . be . revertedWithCustomError ( this . sfcLib , 'ZeroAmount' ) ;
1275
1281
} ) ;
1276
1282
1277
1283
it ( 'Should revert when locking for more than a year' , async function ( ) {
@@ -1281,7 +1287,7 @@ describe('SFC', () => {
1281
1287
this . sfc
1282
1288
. connect ( this . thirdDelegator )
1283
1289
. lockStake ( this . thirdValidatorId , 2 * 60 * 60 * 24 * 365 , ethers . parseEther ( '1' ) ) ,
1284
- ) . to . be . revertedWithCustomError ( this . sfc , 'IncorrectDuration' ) ;
1290
+ ) . to . be . revertedWithCustomError ( this . sfcLib , 'IncorrectDuration' ) ;
1285
1291
} ) ;
1286
1292
1287
1293
it ( 'Should revert when locking for more than a validator lockup period' , async function ( ) {
@@ -1291,7 +1297,7 @@ describe('SFC', () => {
1291
1297
this . sfc
1292
1298
. connect ( this . thirdDelegator )
1293
1299
. lockStake ( this . thirdValidatorId , 60 * 60 * 24 * 364 , ethers . parseEther ( '1' ) ) ,
1294
- ) . to . be . revertedWithCustomError ( this . sfc , 'ValidatorLockupTooShort' ) ;
1300
+ ) . to . be . revertedWithCustomError ( this . sfcLib , 'ValidatorLockupTooShort' ) ;
1295
1301
await this . sfc
1296
1302
. connect ( this . thirdDelegator )
1297
1303
. lockStake ( this . thirdValidatorId , 60 * 60 * 24 * 363 , ethers . parseEther ( '1' ) ) ;
@@ -1315,7 +1321,7 @@ describe('SFC', () => {
1315
1321
await this . blockchainNode . sealEpoch ( 60 * 60 * 24 * 14 ) ;
1316
1322
await expect (
1317
1323
this . sfc . unlockStake ( this . thirdValidatorId , ethers . parseEther ( '10' ) ) ,
1318
- ) . to . be . revertedWithCustomError ( this . sfc , 'NotLockedUp' ) ;
1324
+ ) . to . be . revertedWithCustomError ( this . sfcLib , 'NotLockedUp' ) ;
1319
1325
} ) ;
1320
1326
1321
1327
it ( 'Should revert when unlocking more than locked stake' , async function ( ) {
@@ -1327,7 +1333,7 @@ describe('SFC', () => {
1327
1333
await this . blockchainNode . sealEpoch ( 60 * 60 * 24 * 14 ) ;
1328
1334
await expect (
1329
1335
this . sfc . connect ( this . thirdDelegator ) . unlockStake ( this . thirdValidatorId , ethers . parseEther ( '10' ) ) ,
1330
- ) . to . be . revertedWithCustomError ( this . sfc , 'NotEnoughLockedStake' ) ;
1336
+ ) . to . be . revertedWithCustomError ( this . sfcLib , 'NotEnoughLockedStake' ) ;
1331
1337
} ) ;
1332
1338
1333
1339
it ( 'Should succeed and scale unlocking penalty' , async function ( ) {
@@ -1358,7 +1364,7 @@ describe('SFC', () => {
1358
1364
1359
1365
await expect (
1360
1366
this . sfc . connect ( this . thirdDelegator ) . unlockStake ( this . thirdValidatorId , ethers . parseEther ( '0.51' ) ) ,
1361
- ) . to . be . revertedWithCustomError ( this . sfc , 'NotEnoughLockedStake' ) ;
1367
+ ) . to . be . revertedWithCustomError ( this . sfcLib , 'NotEnoughLockedStake' ) ;
1362
1368
expect (
1363
1369
await this . sfc
1364
1370
. connect ( this . thirdDelegator )
@@ -1399,7 +1405,7 @@ describe('SFC', () => {
1399
1405
1400
1406
await expect (
1401
1407
this . sfc . connect ( this . thirdDelegator ) . unlockStake ( this . thirdValidatorId , ethers . parseEther ( '0.51' ) ) ,
1402
- ) . to . be . revertedWithCustomError ( this . sfc , 'NotEnoughLockedStake' ) ;
1408
+ ) . to . be . revertedWithCustomError ( this . sfcLib , 'NotEnoughLockedStake' ) ;
1403
1409
expect (
1404
1410
await this . sfc
1405
1411
. connect ( this . thirdDelegator )
@@ -1417,7 +1423,7 @@ describe('SFC', () => {
1417
1423
1418
1424
await expect (
1419
1425
this . sfc . connect ( this . thirdDelegator ) . unlockStake ( this . thirdValidatorId , ethers . parseEther ( '1.51' ) ) ,
1420
- ) . to . be . revertedWithCustomError ( this . sfc , 'NotEnoughLockedStake' ) ;
1426
+ ) . to . be . revertedWithCustomError ( this . sfcLib , 'NotEnoughLockedStake' ) ;
1421
1427
expect (
1422
1428
await this . sfc
1423
1429
. connect ( this . thirdDelegator )
@@ -1479,13 +1485,16 @@ describe('SFC', () => {
1479
1485
1480
1486
await expect (
1481
1487
this . sfc . connect ( this . validator ) . updateSlashingRefundRatio ( this . thirdValidatorId , 1 ) ,
1482
- ) . to . be . revertedWithCustomError ( this . sfc , 'ValidatorNotSlashed' ) ;
1488
+ ) . to . be . revertedWithCustomError ( this . sfcLib , 'ValidatorNotSlashed' ) ;
1483
1489
1484
1490
await this . blockchainNode . sealEpoch ( 60 * 60 * 24 * 14 ) ;
1485
1491
} ) ;
1486
1492
1487
1493
it ( 'Should revert when syncing if validator does not exist' , async function ( ) {
1488
- await expect ( this . sfc . _syncValidator ( 33 , false ) ) . to . be . revertedWithCustomError ( this . sfc , 'ValidatorNotExists' ) ;
1494
+ await expect ( this . sfc . _syncValidator ( 33 , false ) ) . to . be . revertedWithCustomError (
1495
+ this . sfcLib ,
1496
+ 'ValidatorNotExists' ,
1497
+ ) ;
1489
1498
} ) ;
1490
1499
} ) ;
1491
1500
} ) ;
@@ -1688,7 +1697,7 @@ describe('SFC', () => {
1688
1697
await this . blockchainNode . sealEpoch ( 60 * 60 * 24 ) ;
1689
1698
await expect (
1690
1699
this . sfc . connect ( this . firstDelegator ) . relockStake ( this . validatorId , 60 * 60 * 24 * 20 , ethers . parseEther ( '0' ) ) ,
1691
- ) . to . be . revertedWithCustomError ( this . sfc , 'TooFrequentReLocks' ) ;
1700
+ ) . to . be . revertedWithCustomError ( this . sfcLib , 'TooFrequentReLocks' ) ;
1692
1701
1693
1702
// 4
1694
1703
await this . sfc . advanceTime ( 60 * 60 * 24 * 14 ) ;
@@ -1698,7 +1707,7 @@ describe('SFC', () => {
1698
1707
await this . blockchainNode . sealEpoch ( 60 * 60 * 24 ) ;
1699
1708
await expect (
1700
1709
this . sfc . connect ( this . firstDelegator ) . relockStake ( this . validatorId , 60 * 60 * 24 * 20 , ethers . parseEther ( '0' ) ) ,
1701
- ) . to . be . revertedWithCustomError ( this . sfc , 'TooFrequentReLocks' ) ;
1710
+ ) . to . be . revertedWithCustomError ( this . sfcLib , 'TooFrequentReLocks' ) ;
1702
1711
1703
1712
for ( let i = 5 ; i <= 40 ; i ++ ) {
1704
1713
// 5-40
0 commit comments