Skip to content

Commit 51d0f7f

Browse files
authored
fix: add whenNotPaused to closeStaleAllocation (#1081)
1 parent 1d097de commit 51d0f7f

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

packages/subgraph-service/contracts/SubgraphService.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ contract SubgraphService is
313313
/**
314314
* @notice See {ISubgraphService.closeStaleAllocation}
315315
*/
316-
function closeStaleAllocation(address allocationId) external override {
316+
function closeStaleAllocation(address allocationId) external override whenNotPaused {
317317
Allocation.State memory allocation = allocations.get(allocationId);
318318
require(allocation.isStale(maxPOIStaleness), SubgraphServiceCannotForceCloseAllocation(allocationId));
319319
require(!allocation.isAltruistic(), SubgraphServiceAllocationIsAltruistic(allocationId));

packages/subgraph-service/test/SubgraphBaseTest.t.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ abstract contract SubgraphBaseTest is Utils, Constants {
7575
delegator: createUser("delegator"),
7676
arbitrator: createUser("arbitrator"),
7777
fisherman: createUser("fisherman"),
78-
rewardsDestination: createUser("rewardsDestination")
78+
rewardsDestination: createUser("rewardsDestination"),
79+
pauseGuardian: createUser("pauseGuardian")
7980
});
8081

8182
deployProtocolContracts();
@@ -191,6 +192,7 @@ abstract contract SubgraphBaseTest is Utils, Constants {
191192
epochManager.setEpochLength(EPOCH_LENGTH);
192193
subgraphService.setMaxPOIStaleness(maxPOIStaleness);
193194
subgraphService.setCurationCut(curationCut);
195+
subgraphService.setPauseGuardian(users.pauseGuardian, true);
194196
}
195197

196198
function unpauseProtocol() private {

packages/subgraph-service/test/shared/SubgraphServiceShared.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ abstract contract SubgraphServiceSharedTest is HorizonStakingSharedTest {
3131
}
3232

3333
modifier useAllocation(uint256 tokens) {
34-
vm.assume(tokens > minimumProvisionTokens);
34+
vm.assume(tokens >= minimumProvisionTokens);
3535
vm.assume(tokens < 10_000_000_000 ether);
3636
_createProvision(users.indexer, tokens, maxSlashingPercentage, disputePeriod);
3737
_register(users.indexer, abi.encode("url", "geoHash", address(0)));

packages/subgraph-service/test/subgraphService/allocation/forceClose.t.sol

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pragma solidity 0.8.27;
33

44
import "forge-std/Test.sol";
55

6+
import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
67
import { IGraphPayments } from "@graphprotocol/horizon/contracts/interfaces/IGraphPayments.sol";
78

89
import { Allocation } from "../../../contracts/libraries/Allocation.sol";
@@ -91,4 +92,13 @@ contract SubgraphServiceAllocationForceCloseTest is SubgraphServiceTest {
9192
);
9293
subgraphService.closeStaleAllocation(allocationID);
9394
}
95+
96+
function test_SubgraphService_Allocation_ForceClose_RevertIf_Paused() public useIndexer useAllocation(1000 ether) {
97+
resetPrank(users.pauseGuardian);
98+
subgraphService.pause();
99+
100+
resetPrank(permissionlessBob);
101+
vm.expectRevert(abi.encodeWithSelector(PausableUpgradeable.EnforcedPause.selector));
102+
subgraphService.closeStaleAllocation(allocationID);
103+
}
94104
}

packages/subgraph-service/test/utils/Users.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ struct Users {
1212
address arbitrator;
1313
address fisherman;
1414
address rewardsDestination;
15+
address pauseGuardian;
1516
}

0 commit comments

Comments
 (0)