Skip to content

Commit b8097fd

Browse files
committed
tests
1 parent ce89cdc commit b8097fd

File tree

1 file changed

+19
-58
lines changed

1 file changed

+19
-58
lines changed

test/Validator.t.sol

Lines changed: 19 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ contract ValidatorTest is Test {
116116
validator.createRail(token);
117117

118118
vm.prank(porepService);
119-
validator.setDealEndEpoch(dealId, CommonTypes.ChainEpoch.wrap(int64(CHAIN_EPOCH)));
119+
validator.setDealEndEpoch(CommonTypes.ChainEpoch.wrap(int64(CHAIN_EPOCH)));
120120

121121
vm.prank(oracleUpdater);
122122
sliOracle.setSLI(providerFilActorId, defaultRequirements);
@@ -143,7 +143,7 @@ contract ValidatorTest is Test {
143143
uint256 newLockup = 123;
144144

145145
vm.prank(admin);
146-
validator.updateLockupPeriod(railId, newLockup);
146+
validator.updateLockupPeriod(newLockup);
147147

148148
(uint256 lockupPeriod, uint256 lockupFixed) = filecoinPayMock.getRailLockup(railId);
149149
assertEq(lockupPeriod, newLockup);
@@ -250,14 +250,6 @@ contract ValidatorTest is Test {
250250
validator.validatePayment(wrongRailId, 100, 0, type(uint256).max, 1);
251251
}
252252

253-
function testUpdateLockupPeriodInvalidRailIdRevert() public {
254-
uint256 wrongRailId = railId + 1;
255-
256-
vm.expectRevert(abi.encodeWithSelector(Validator.InvalidRailId.selector, railId, wrongRailId));
257-
vm.prank(admin);
258-
validator.updateLockupPeriod(wrongRailId, 123);
259-
}
260-
261253
function testRailTerminatedInvalidRailIdRevert() public {
262254
uint256 wrongRailId = railId + 1;
263255

@@ -404,7 +396,7 @@ contract ValidatorTest is Test {
404396
emit Validator.RailPaymentModified(railId, expectedRate);
405397

406398
vm.prank(porepService);
407-
validator.modifyRailPayment(railId);
399+
validator.modifyRailPayment();
408400
}
409401

410402
function testUpdateLockupPeriodEmitsLockupPeriodUpdated() public {
@@ -413,7 +405,7 @@ contract ValidatorTest is Test {
413405
vm.expectEmit(true, false, false, true, address(validator));
414406
emit Validator.LockupPeriodUpdated(railId, newLockupPeriod);
415407

416-
validator.updateLockupPeriod(railId, newLockupPeriod);
408+
validator.updateLockupPeriod(newLockupPeriod);
417409
}
418410

419411
function testRailTerminatedEmitsRailTerminated() public {
@@ -436,32 +428,32 @@ contract ValidatorTest is Test {
436428
function testTerminateRailTerminatesFilecoinPayRailAsAnAdmin() public {
437429
assertFalse(filecoinPayMock.terminated(railId));
438430
vm.prank(admin);
439-
validator.terminateRail(railId);
431+
validator.terminateRail();
440432
assertTrue(filecoinPayMock.terminated(railId));
441433
}
442434

443435
function testTerminateRailTerminatesFilecoinPayRailAsPoRepService() public {
444436
assertFalse(filecoinPayMock.terminated(railId));
445437
vm.prank(porepService);
446-
validator.terminateRail(railId);
438+
validator.terminateRail();
447439
assertTrue(filecoinPayMock.terminated(railId));
448440
}
449441

450442
function testTerminateRailRevertsWhenCallerHasPoRepServiceRole() public {
451443
vm.expectRevert(Validator.UnauthorizedCaller.selector);
452444
vm.prank(address(123));
453-
validator.terminateRail(railId);
445+
validator.terminateRail();
454446
}
455447

456448
function testTerminateRailRevertsWhenCallerHasAdminRole() public {
457449
vm.expectRevert(Validator.UnauthorizedCaller.selector);
458450
vm.prank(address(123));
459-
validator.terminateRail(railId);
451+
validator.terminateRail();
460452
}
461453

462454
function testValidatePaymentReturnsDealEndedWhenFromEpochPastDealEndEpoch() public {
463455
vm.prank(porepService);
464-
validator.setDealEndEpoch(dealId, CommonTypes.ChainEpoch.wrap(int64(10)));
456+
validator.setDealEndEpoch(CommonTypes.ChainEpoch.wrap(int64(10)));
465457

466458
clientSCMock.setDataSizeMatching(dealId, true);
467459

@@ -477,7 +469,7 @@ contract ValidatorTest is Test {
477469
clientSCMock.setDataSizeMatching(dealId, true);
478470

479471
vm.prank(porepService);
480-
validator.setDealEndEpoch(dealId, CommonTypes.ChainEpoch.wrap(int64(1000)));
472+
validator.setDealEndEpoch(CommonTypes.ChainEpoch.wrap(int64(1000)));
481473

482474
vm.prank(oracleUpdater);
483475
sliOracle.setSLI(providerFilActorId, defaultRequirements);
@@ -498,15 +490,7 @@ contract ValidatorTest is Test {
498490
abi.encodeWithSelector(IAccessControl.AccessControlUnauthorizedAccount.selector, unauthorized, expectedRole)
499491
);
500492
vm.prank(unauthorized);
501-
validator.setDealEndEpoch(dealId, CommonTypes.ChainEpoch.wrap(int64(1_000_000)));
502-
}
503-
504-
function testSetDealEndEpochInvalidDealIdRevert() public {
505-
uint256 wrongDealId = dealId + 1;
506-
507-
vm.expectRevert(Validator.InvalidDealId.selector);
508-
vm.prank(porepService);
509-
validator.setDealEndEpoch(wrongDealId, CommonTypes.ChainEpoch.wrap(int64(1_000_000)));
493+
validator.setDealEndEpoch(CommonTypes.ChainEpoch.wrap(int64(1_000_000)));
510494
}
511495

512496
function testCreateRailRevertsWhenOperatorNotApproved() public {
@@ -607,41 +591,18 @@ contract ValidatorTest is Test {
607591

608592
vm.expectRevert(Validator.InvalidSectorCount.selector);
609593
vm.prank(porepService);
610-
validator.modifyRailPayment(railId);
594+
validator.modifyRailPayment();
611595
}
612596

613597
function testValidatePaymentRevertsWhenDealNotCompleted() public {
614598
vm.prank(porepService);
615-
validator.setDealEndEpoch(dealId, CommonTypes.ChainEpoch.wrap(int64(0)));
599+
validator.setDealEndEpoch(CommonTypes.ChainEpoch.wrap(int64(0)));
616600

617601
vm.expectRevert(abi.encodeWithSelector(Validator.DealNotCompleted.selector, dealId));
618602
vm.prank(address(filecoinPayMock));
619603
validator.validatePayment(railId, 100, 0, 86_400, 1);
620604
}
621605

622-
function testDisableFutureRailPaymentsInvalidRailIdRevert() public {
623-
uint256 wrongRailId = railId + 1;
624-
625-
vm.expectRevert(abi.encodeWithSelector(Validator.InvalidRailId.selector, railId, wrongRailId));
626-
vm.prank(porepService);
627-
validator.disableFutureRailPayments(wrongRailId);
628-
}
629-
630-
function testModifyRailPaymentInvalidRailIdRevert() public {
631-
uint256 wrongRailId = railId + 1;
632-
633-
vm.expectRevert(abi.encodeWithSelector(Validator.InvalidRailId.selector, railId, wrongRailId));
634-
vm.prank(porepService);
635-
validator.modifyRailPayment(wrongRailId);
636-
}
637-
638-
function testTerminateRailInvalidRailIdRevert() public {
639-
uint256 wrongRailId = railId + 1;
640-
641-
vm.expectRevert(abi.encodeWithSelector(Validator.InvalidRailId.selector, railId, wrongRailId));
642-
validator.terminateRail(wrongRailId);
643-
}
644-
645606
function testCreateRailEmitsInitialLockupPeriodUpdated() public {
646607
Validator impl = new Validator();
647608
ERC1967Proxy proxy = new ERC1967Proxy(address(impl), "");
@@ -675,15 +636,15 @@ contract ValidatorTest is Test {
675636
emit Validator.DealEndEpochUpdated(dealId, newEndEpoch);
676637

677638
vm.prank(porepService);
678-
validator.setDealEndEpoch(dealId, newEndEpoch);
639+
validator.setDealEndEpoch(newEndEpoch);
679640
}
680641

681642
function testDisableFutureRailPaymentsEmitsRailDisabled() public {
682643
vm.expectEmit(true, false, false, true, address(validator));
683644
emit Validator.RailDisabled(railId);
684645

685646
vm.prank(porepService);
686-
validator.disableFutureRailPayments(railId);
647+
validator.disableFutureRailPayments();
687648
}
688649

689650
function testValidatePaymentCapsSettlementToEarlyTerminatedEpoch() public {
@@ -698,7 +659,7 @@ contract ValidatorTest is Test {
698659
sliOracle.setSLI(providerFilActorId, defaultRequirements);
699660

700661
vm.prank(porepService);
701-
validator.disableFutureRailPayments(railId);
662+
validator.disableFutureRailPayments();
702663

703664
vm.prank(address(filecoinPayMock));
704665
IFilecoinPayValidator.ValidationResult memory result =
@@ -721,7 +682,7 @@ contract ValidatorTest is Test {
721682
sliOracle.setSLI(providerFilActorId, defaultRequirements);
722683

723684
vm.prank(porepService);
724-
validator.disableFutureRailPayments(railId);
685+
validator.disableFutureRailPayments();
725686

726687
vm.prank(address(filecoinPayMock));
727688
IFilecoinPayValidator.ValidationResult memory result =
@@ -743,13 +704,13 @@ contract ValidatorTest is Test {
743704

744705
vm.expectRevert(Validator.InvalidZeroAmount.selector);
745706
vm.prank(porepService);
746-
validator.modifyRailPayment(railId);
707+
validator.modifyRailPayment();
747708
}
748709

749710
function testSetDealEndEpochNegativeEndEpochRevert() public {
750711
vm.expectRevert(Validator.NegativeEndEpoch.selector);
751712
vm.prank(porepService);
752-
validator.setDealEndEpoch(dealId, CommonTypes.ChainEpoch.wrap(int64(-1)));
713+
validator.setDealEndEpoch(CommonTypes.ChainEpoch.wrap(int64(-1)));
753714
}
754715

755716
function testSetMinEpochsBetweenSettlementsRevertsMinTimeNotReached() public {

0 commit comments

Comments
 (0)