Skip to content

Commit 870a073

Browse files
fix: SubgraphService run lint:sol
1 parent 1b55b04 commit 870a073

38 files changed

+361
-347
lines changed

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

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import { MockRewardsManager } from "./mocks/MockRewardsManager.sol";
2929
import { MockEpochManager } from "./mocks/MockEpochManager.sol";
3030

3131
abstract contract SubgraphBaseTest is Utils, Constants {
32-
3332
/*
3433
* VARIABLES
3534
*/
@@ -89,7 +88,7 @@ abstract contract SubgraphBaseTest is Utils, Constants {
8988
resetPrank(users.governor);
9089
proxyAdmin = new GraphProxyAdmin();
9190
controller = new Controller();
92-
91+
9392
resetPrank(users.deployer);
9493
GraphProxy stakingProxy = new GraphProxy(address(0), address(proxyAdmin));
9594
rewardsManager = new MockRewardsManager(token, rewardsPerSignal, rewardsPerSubgraphAllocationUpdate);
@@ -98,30 +97,27 @@ abstract contract SubgraphBaseTest is Utils, Constants {
9897

9998
// GraphPayments predict address
10099
bytes32 saltGraphPayments = keccak256("GraphPaymentsSalt");
101-
bytes32 paymentsHash = keccak256(bytes.concat(
102-
vm.getCode("GraphPayments.sol:GraphPayments"),
103-
abi.encode(address(controller), protocolPaymentCut)
104-
));
100+
bytes32 paymentsHash = keccak256(
101+
bytes.concat(
102+
vm.getCode("GraphPayments.sol:GraphPayments"),
103+
abi.encode(address(controller), protocolPaymentCut)
104+
)
105+
);
105106
address predictedGraphPaymentsAddress = vm.computeCreate2Address(
106107
saltGraphPayments,
107108
paymentsHash,
108109
users.deployer
109110
);
110-
111+
111112
// GraphEscrow predict address
112113
bytes32 saltEscrow = keccak256("GraphEscrowSalt");
113-
bytes32 escrowHash = keccak256(bytes.concat(
114-
vm.getCode("PaymentsEscrow.sol:PaymentsEscrow"),
115-
abi.encode(
116-
address(controller),
117-
withdrawEscrowThawingPeriod
114+
bytes32 escrowHash = keccak256(
115+
bytes.concat(
116+
vm.getCode("PaymentsEscrow.sol:PaymentsEscrow"),
117+
abi.encode(address(controller), withdrawEscrowThawingPeriod)
118118
)
119-
));
120-
address predictedEscrowAddress = vm.computeCreate2Address(
121-
saltEscrow,
122-
escrowHash,
123-
users.deployer
124119
);
120+
address predictedEscrowAddress = vm.computeCreate2Address(saltEscrow, escrowHash, users.deployer);
125121

126122
resetPrank(users.governor);
127123
controller.setContractProxy(keccak256("GraphToken"), address(token));
@@ -147,9 +143,19 @@ abstract contract SubgraphBaseTest is Utils, Constants {
147143
disputeManager = DisputeManager(disputeManagerProxy);
148144
disputeManager.transferOwnership(users.governor);
149145

150-
graphTallyCollector = new GraphTallyCollector("GraphTallyCollector", "1", address(controller), revokeSignerThawingPeriod);
146+
graphTallyCollector = new GraphTallyCollector(
147+
"GraphTallyCollector",
148+
"1",
149+
address(controller),
150+
revokeSignerThawingPeriod
151+
);
151152
address subgraphServiceImplementation = address(
152-
new SubgraphService(address(controller), address(disputeManager), address(graphTallyCollector), address(curation))
153+
new SubgraphService(
154+
address(controller),
155+
address(disputeManager),
156+
address(graphTallyCollector),
157+
address(curation)
158+
)
153159
);
154160
address subgraphServiceProxy = UnsafeUpgrades.deployTransparentProxy(
155161
subgraphServiceImplementation,
@@ -158,24 +164,11 @@ abstract contract SubgraphBaseTest is Utils, Constants {
158164
);
159165
subgraphService = SubgraphService(subgraphServiceProxy);
160166

161-
stakingExtension = new HorizonStakingExtension(
162-
address(controller),
163-
address(subgraphService)
164-
);
165-
stakingBase = new HorizonStaking(
166-
address(controller),
167-
address(stakingExtension),
168-
address(subgraphService)
169-
);
167+
stakingExtension = new HorizonStakingExtension(address(controller), address(subgraphService));
168+
stakingBase = new HorizonStaking(address(controller), address(stakingExtension), address(subgraphService));
170169

171-
graphPayments = new GraphPayments{salt: saltGraphPayments}(
172-
address(controller),
173-
protocolPaymentCut
174-
);
175-
escrow = new PaymentsEscrow{salt: saltEscrow}(
176-
address(controller),
177-
withdrawEscrowThawingPeriod
178-
);
170+
graphPayments = new GraphPayments{ salt: saltGraphPayments }(address(controller), protocolPaymentCut);
171+
escrow = new PaymentsEscrow{ salt: saltEscrow }(address(controller), withdrawEscrowThawingPeriod);
179172

180173
resetPrank(users.governor);
181174
disputeManager.setSubgraphService(address(subgraphService));
@@ -215,4 +208,4 @@ abstract contract SubgraphBaseTest is Utils, Constants {
215208
function burn(address _from, uint256 amount) internal {
216209
token.burnFrom(_from, amount);
217210
}
218-
}
211+
}

packages/subgraph-service/test/disputeManager/DisputeManager.t.sol

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,7 @@ contract DisputeManagerTest is SubgraphServiceSharedTest {
344344
disputeManager.acceptDispute(_disputeId, _tokensSlash);
345345

346346
// Check fisherman's got their reward and their deposit (if any) back
347-
uint256 fishermanExpectedBalance = fishermanPreviousBalance +
348-
fishermanReward +
349-
disputeDeposit;
347+
uint256 fishermanExpectedBalance = fishermanPreviousBalance + fishermanReward + disputeDeposit;
350348
assertEq(
351349
token.balanceOf(fisherman),
352350
fishermanExpectedBalance,
@@ -387,11 +385,19 @@ contract DisputeManagerTest is SubgraphServiceSharedTest {
387385
uint256 expectedBalance;
388386
}
389387

390-
function _acceptDisputeConflict(bytes32 _disputeId, uint256 _tokensSlash, bool _acceptRelatedDispute, uint256 _tokensRelatedSlash) internal {
388+
function _acceptDisputeConflict(
389+
bytes32 _disputeId,
390+
uint256 _tokensSlash,
391+
bool _acceptRelatedDispute,
392+
uint256 _tokensRelatedSlash
393+
) internal {
391394
IDisputeManager.Dispute memory dispute = _getDispute(_disputeId);
392395
IDisputeManager.Dispute memory relatedDispute = _getDispute(dispute.relatedDisputeId);
393396
uint256 indexerTokensAvailable = staking.getProviderTokensAvailable(dispute.indexer, address(subgraphService));
394-
uint256 relatedIndexerTokensAvailable = staking.getProviderTokensAvailable(relatedDispute.indexer, address(subgraphService));
397+
uint256 relatedIndexerTokensAvailable = staking.getProviderTokensAvailable(
398+
relatedDispute.indexer,
399+
address(subgraphService)
400+
);
395401

396402
FishermanParams memory params;
397403
params.fisherman = dispute.fisherman;
@@ -431,7 +437,8 @@ contract DisputeManagerTest is SubgraphServiceSharedTest {
431437
disputeManager.acceptDisputeConflict(_disputeId, _tokensSlash, _acceptRelatedDispute, _tokensRelatedSlash);
432438

433439
// Check fisherman's got their reward and their deposit back
434-
params.expectedBalance = params.previousBalance +
440+
params.expectedBalance =
441+
params.previousBalance +
435442
params.totalReward +
436443
params.disputeDeposit +
437444
params.relatedDisputeDeposit;
@@ -486,7 +493,6 @@ contract DisputeManagerTest is SubgraphServiceSharedTest {
486493
}
487494
}
488495

489-
490496
// Check dispute status
491497
dispute = _getDispute(_disputeId);
492498
assertEq(
@@ -500,8 +506,8 @@ contract DisputeManagerTest is SubgraphServiceSharedTest {
500506
assertEq(
501507
uint8(relatedDispute.status),
502508
_acceptRelatedDispute
503-
? uint8(IDisputeManager.DisputeStatus.Accepted)
504-
: uint8(IDisputeManager.DisputeStatus.Drawn),
509+
? uint8(IDisputeManager.DisputeStatus.Accepted)
510+
: uint8(IDisputeManager.DisputeStatus.Drawn),
505511
"Related dispute status should be drawn"
506512
);
507513
}

packages/subgraph-service/test/disputeManager/constructor/constructor.t.sol

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@ contract DisputeManagerConstructorTest is DisputeManagerTest {
3535
uint32 fishermanRewardPercentage,
3636
uint32 maxSlashingPercentage
3737
) private returns (address) {
38-
return UnsafeUpgrades.deployTransparentProxy(
39-
implementation,
40-
users.governor,
41-
abi.encodeCall(
42-
DisputeManager.initialize,
43-
(arbitrator, disputePeriod, disputeDeposit, fishermanRewardPercentage, maxSlashingPercentage)
44-
)
45-
);
38+
return
39+
UnsafeUpgrades.deployTransparentProxy(
40+
implementation,
41+
users.governor,
42+
abi.encodeCall(
43+
DisputeManager.initialize,
44+
(arbitrator, disputePeriod, disputeDeposit, fishermanRewardPercentage, maxSlashingPercentage)
45+
)
46+
);
4647
}
4748

4849
/*
@@ -83,9 +84,7 @@ contract DisputeManagerConstructorTest is DisputeManagerTest {
8384

8485
function test_DisputeManager_Constructor_RevertIf_ArbitratorAddressIsZero() public useDeployer {
8586
address disputeManagerImplementation = address(new DisputeManager(address(controller)));
86-
bytes memory expectedError = abi.encodeWithSelector(
87-
IDisputeManager.DisputeManagerInvalidZeroAddress.selector
88-
);
87+
bytes memory expectedError = abi.encodeWithSelector(IDisputeManager.DisputeManagerInvalidZeroAddress.selector);
8988
vm.expectRevert(expectedError);
9089
_initializeDisputeManager(
9190
disputeManagerImplementation,
@@ -99,9 +98,7 @@ contract DisputeManagerConstructorTest is DisputeManagerTest {
9998

10099
function test_DisputeManager_Constructor_RevertIf_InvalidDisputePeriod() public useDeployer {
101100
address disputeManagerImplementation = address(new DisputeManager(address(controller)));
102-
bytes memory expectedError = abi.encodeWithSelector(
103-
IDisputeManager.DisputeManagerDisputePeriodZero.selector
104-
);
101+
bytes memory expectedError = abi.encodeWithSelector(IDisputeManager.DisputeManagerDisputePeriodZero.selector);
105102
vm.expectRevert(expectedError);
106103
_initializeDisputeManager(
107104
disputeManagerImplementation,
@@ -130,7 +127,9 @@ contract DisputeManagerConstructorTest is DisputeManagerTest {
130127
);
131128
}
132129

133-
function test_DisputeManager_Constructor_RevertIf_InvalidFishermanRewardPercentage(uint32 _fishermanRewardPercentage) public useDeployer {
130+
function test_DisputeManager_Constructor_RevertIf_InvalidFishermanRewardPercentage(
131+
uint32 _fishermanRewardPercentage
132+
) public useDeployer {
134133
vm.assume(_fishermanRewardPercentage > disputeManager.MAX_FISHERMAN_REWARD_CUT());
135134
address disputeManagerImplementation = address(new DisputeManager(address(controller)));
136135
bytes memory expectedError = abi.encodeWithSelector(
@@ -148,7 +147,9 @@ contract DisputeManagerConstructorTest is DisputeManagerTest {
148147
);
149148
}
150149

151-
function test_DisputeManager_Constructor_RevertIf_InvalidMaxSlashingPercentage(uint32 _maxSlashingPercentage) public useDeployer {
150+
function test_DisputeManager_Constructor_RevertIf_InvalidMaxSlashingPercentage(
151+
uint32 _maxSlashingPercentage
152+
) public useDeployer {
152153
vm.assume(_maxSlashingPercentage > PPMMath.MAX_PPM);
153154
address disputeManagerImplementation = address(new DisputeManager(address(controller)));
154155
bytes memory expectedError = abi.encodeWithSelector(

packages/subgraph-service/test/disputeManager/disputes/disputes.t.sol

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,49 +23,36 @@ contract DisputeManagerDisputeTest is DisputeManagerTest {
2323
bytes32 disputeID = bytes32("0x0");
2424

2525
resetPrank(users.arbitrator);
26-
vm.expectRevert(abi.encodeWithSelector(
27-
IDisputeManager.DisputeManagerInvalidDispute.selector,
28-
disputeID
29-
));
26+
vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerInvalidDispute.selector, disputeID));
3027
disputeManager.acceptDispute(disputeID, tokensSlash);
3128
}
3229

33-
function test_Dispute_Accept_RevertIf_SlashZeroTokens(
34-
uint256 tokens
35-
) public useIndexer useAllocation(tokens) {
30+
function test_Dispute_Accept_RevertIf_SlashZeroTokens(uint256 tokens) public useIndexer useAllocation(tokens) {
3631
resetPrank(users.fisherman);
37-
bytes32 disputeID =_createIndexingDispute(allocationID, bytes32("POI101"));
32+
bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI101"));
3833

3934
// attempt to accept dispute with 0 tokens slashed
4035
resetPrank(users.arbitrator);
4136
uint256 maxTokensToSlash = uint256(maxSlashingPercentage).mulPPM(tokens);
42-
vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerInvalidTokensSlash.selector, 0, maxTokensToSlash));
37+
vm.expectRevert(
38+
abi.encodeWithSelector(IDisputeManager.DisputeManagerInvalidTokensSlash.selector, 0, maxTokensToSlash)
39+
);
4340
disputeManager.acceptDispute(disputeID, 0);
4441
}
4542

46-
function test_Dispute_Reject_RevertIf_DisputeDoesNotExist(
47-
uint256 tokens
48-
) public useIndexer useAllocation(tokens) {
43+
function test_Dispute_Reject_RevertIf_DisputeDoesNotExist(uint256 tokens) public useIndexer useAllocation(tokens) {
4944
bytes32 disputeID = bytes32("0x0");
5045

5146
resetPrank(users.arbitrator);
52-
vm.expectRevert(abi.encodeWithSelector(
53-
IDisputeManager.DisputeManagerInvalidDispute.selector,
54-
disputeID
55-
));
47+
vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerInvalidDispute.selector, disputeID));
5648
disputeManager.rejectDispute(disputeID);
5749
}
5850

59-
function test_Dispute_Draw_RevertIf_DisputeDoesNotExist(
60-
uint256 tokens
61-
) public useIndexer useAllocation(tokens) {
51+
function test_Dispute_Draw_RevertIf_DisputeDoesNotExist(uint256 tokens) public useIndexer useAllocation(tokens) {
6252
bytes32 disputeID = bytes32("0x0");
6353

6454
resetPrank(users.arbitrator);
65-
vm.expectRevert(abi.encodeWithSelector(
66-
IDisputeManager.DisputeManagerInvalidDispute.selector,
67-
disputeID
68-
));
55+
vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerInvalidDispute.selector, disputeID));
6956
disputeManager.drawDispute(disputeID);
7057
}
7158
}

packages/subgraph-service/test/disputeManager/disputes/indexing/accept.t.sol

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@ contract DisputeManagerIndexingAcceptDisputeTest is DisputeManagerTest {
1414
* TESTS
1515
*/
1616

17-
function test_Indexing_Accept_Dispute(
18-
uint256 tokens,
19-
uint256 tokensSlash
20-
) public useIndexer useAllocation(tokens) {
17+
function test_Indexing_Accept_Dispute(uint256 tokens, uint256 tokensSlash) public useIndexer useAllocation(tokens) {
2118
tokensSlash = bound(tokensSlash, 1, uint256(maxSlashingPercentage).mulPPM(tokens));
2219

2320
resetPrank(users.fisherman);
2421
bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1"));
25-
22+
2623
resetPrank(users.arbitrator);
2724
_acceptDispute(disputeID, tokensSlash);
2825
}
@@ -35,7 +32,7 @@ contract DisputeManagerIndexingAcceptDisputeTest is DisputeManagerTest {
3532

3633
resetPrank(users.fisherman);
3734
bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1"));
38-
35+
3936
resetPrank(users.arbitrator);
4037
// clear subgraph service address from storage
4138
_setStorage_SubgraphService(address(0));
@@ -52,7 +49,7 @@ contract DisputeManagerIndexingAcceptDisputeTest is DisputeManagerTest {
5249

5350
resetPrank(users.fisherman);
5451
bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1"));
55-
52+
5653
resetPrank(users.arbitrator);
5754
_acceptDispute(disputeID, tokensSlash);
5855
}
@@ -84,7 +81,7 @@ contract DisputeManagerIndexingAcceptDisputeTest is DisputeManagerTest {
8481
resetPrank(users.arbitrator);
8582
uint256 maxTokensToSlash = uint256(maxSlashingPercentage).mulPPM(tokens);
8683
bytes memory expectedError = abi.encodeWithSelector(
87-
IDisputeManager.DisputeManagerInvalidTokensSlash.selector,
84+
IDisputeManager.DisputeManagerInvalidTokensSlash.selector,
8885
tokensSlash,
8986
maxTokensToSlash
9087
);

packages/subgraph-service/test/disputeManager/disputes/indexing/cancel.t.sol

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ import { IDisputeManager } from "../../../../contracts/interfaces/IDisputeManage
77
import { DisputeManagerTest } from "../../DisputeManager.t.sol";
88

99
contract DisputeManagerIndexingCancelDisputeTest is DisputeManagerTest {
10-
1110
/*
1211
* TESTS
1312
*/
1413

1514
function test_Indexing_Cancel_Dispute(uint256 tokens) public useIndexer useAllocation(tokens) {
1615
resetPrank(users.fisherman);
17-
bytes32 disputeID =_createIndexingDispute(allocationID, bytes32("POI1"));
16+
bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1"));
1817

1918
_cancelDispute(disputeID);
2019
}
@@ -23,7 +22,7 @@ contract DisputeManagerIndexingCancelDisputeTest is DisputeManagerTest {
2322
uint256 tokens
2423
) public useIndexer useAllocation(tokens) {
2524
resetPrank(users.fisherman);
26-
bytes32 disputeID =_createIndexingDispute(allocationID, bytes32("POI1"));
25+
bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1"));
2726

2827
resetPrank(users.arbitrator);
2928
vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerNotFisherman.selector));
@@ -34,7 +33,7 @@ contract DisputeManagerIndexingCancelDisputeTest is DisputeManagerTest {
3433
uint256 tokens
3534
) public useIndexer useAllocation(tokens) {
3635
resetPrank(users.fisherman);
37-
bytes32 disputeID =_createIndexingDispute(allocationID, bytes32("POI1"));
36+
bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1"));
3837

3938
vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerDisputePeriodNotFinished.selector));
4039
disputeManager.cancelDispute(disputeID);

0 commit comments

Comments
 (0)