diff --git a/packages/horizon/package.json b/packages/horizon/package.json index b46eb8167..89fda2213 100644 --- a/packages/horizon/package.json +++ b/packages/horizon/package.json @@ -12,7 +12,7 @@ ], "scripts": { "lint:ts": "eslint '**/*.{js,ts}' --fix", - "lint:sol": "prettier --write contracts/**/*.sol && solhint --noPrompt --fix contracts/**/*.sol --config node_modules/solhint-graph-config/index.js", + "lint:sol": "prettier --write contracts/**/*.sol test/**/*.sol && solhint --noPrompt --fix contracts/**/*.sol --config node_modules/solhint-graph-config/index.js", "lint": "yarn lint:ts && yarn lint:sol", "clean": "rm -rf build dist cache cache_forge typechain-types", "build": "forge build --skip test && BUILD_RUN=true hardhat compile", diff --git a/packages/horizon/test/GraphBase.t.sol b/packages/horizon/test/GraphBase.t.sol index afa914341..fcbbf7b48 100644 --- a/packages/horizon/test/GraphBase.t.sol +++ b/packages/horizon/test/GraphBase.t.sol @@ -201,7 +201,12 @@ abstract contract GraphBaseTest is IHorizonStakingTypes, Utils, Constants { subgraphDataServiceLegacyAddress ); - graphTallyCollector = new GraphTallyCollector("GraphTallyCollector", "1", address(controller), revokeSignerThawingPeriod); + graphTallyCollector = new GraphTallyCollector( + "GraphTallyCollector", + "1", + address(controller), + revokeSignerThawingPeriod + ); resetPrank(users.governor); proxyAdmin.upgrade(stakingProxy, address(stakingBase)); diff --git a/packages/horizon/test/data-service/DataService.t.sol b/packages/horizon/test/data-service/DataService.t.sol index d18e49ba9..4a29a523f 100644 --- a/packages/horizon/test/data-service/DataService.t.sol +++ b/packages/horizon/test/data-service/DataService.t.sol @@ -65,7 +65,10 @@ contract DataServiceTest is HorizonStakingSharedTest { assertEq(max, dataServiceOverride.PROVISION_TOKENS_MAX()); } - function test_ProvisionTokens_WhenCheckingAValidProvision_WithThawing(uint256 tokens, uint256 tokensThaw) external useIndexer { + function test_ProvisionTokens_WhenCheckingAValidProvision_WithThawing( + uint256 tokens, + uint256 tokensThaw + ) external useIndexer { dataService.setProvisionTokensRange(dataService.PROVISION_TOKENS_MIN(), dataService.PROVISION_TOKENS_MAX()); tokens = bound(tokens, dataService.PROVISION_TOKENS_MIN(), dataService.PROVISION_TOKENS_MAX()); tokensThaw = bound(tokensThaw, tokens - dataService.PROVISION_TOKENS_MIN() + 1, tokens); @@ -313,12 +316,7 @@ contract DataServiceTest is HorizonStakingSharedTest { dataService.VERIFIER_CUT_MIN(), dataService.THAWING_PERIOD_MIN() ); - _setProvisionParameters( - users.indexer, - address(dataService), - dataService.VERIFIER_CUT_MIN(), - thawingPeriod - ); + _setProvisionParameters(users.indexer, address(dataService), dataService.VERIFIER_CUT_MIN(), thawingPeriod); // accept provision parameters vm.expectRevert( @@ -351,12 +349,7 @@ contract DataServiceTest is HorizonStakingSharedTest { dataService.VERIFIER_CUT_MIN(), dataService.THAWING_PERIOD_MIN() ); - _setProvisionParameters( - users.indexer, - address(dataService), - maxVerifierCut, - dataService.THAWING_PERIOD_MIN() - ); + _setProvisionParameters(users.indexer, address(dataService), maxVerifierCut, dataService.THAWING_PERIOD_MIN()); // accept provision parameters if (maxVerifierCut != dataService.VERIFIER_CUT_MIN()) { diff --git a/packages/horizon/test/data-service/extensions/DataServiceFees.t.sol b/packages/horizon/test/data-service/extensions/DataServiceFees.t.sol index a45a7bee2..345a86db7 100644 --- a/packages/horizon/test/data-service/extensions/DataServiceFees.t.sol +++ b/packages/horizon/test/data-service/extensions/DataServiceFees.t.sol @@ -146,7 +146,12 @@ contract DataServiceFeesTest is HorizonStakingSharedTest { // it should emit a an event vm.expectEmit(); - emit IDataServiceFees.StakeClaimLocked(serviceProvider, calcValues.predictedClaimId, calcValues.stakeToLock, calcValues.unlockTimestamp); + emit IDataServiceFees.StakeClaimLocked( + serviceProvider, + calcValues.predictedClaimId, + calcValues.stakeToLock, + calcValues.unlockTimestamp + ); dataService.lockStake(serviceProvider, tokens); // after state @@ -195,7 +200,9 @@ contract DataServiceFeesTest is HorizonStakingSharedTest { tokensReleased: 0, head: beforeHead }); - while (calcValues.head != bytes32(0) && (calcValues.claimsCount < numClaimsToRelease || numClaimsToRelease == 0)) { + while ( + calcValues.head != bytes32(0) && (calcValues.claimsCount < numClaimsToRelease || numClaimsToRelease == 0) + ) { (uint256 claimTokens, , uint256 releasableAt, bytes32 nextClaim) = dataService.claims(calcValues.head); if (releasableAt > block.timestamp) { break; diff --git a/packages/horizon/test/data-service/implementations/DataServiceBase.sol b/packages/horizon/test/data-service/implementations/DataServiceBase.sol index 0d51241ce..e31b21a7b 100644 --- a/packages/horizon/test/data-service/implementations/DataServiceBase.sol +++ b/packages/horizon/test/data-service/implementations/DataServiceBase.sol @@ -25,7 +25,11 @@ contract DataServiceBase is DataService { function stopService(address serviceProvider, bytes calldata data) external {} - function collect(address serviceProvider, IGraphPayments.PaymentTypes feeType, bytes calldata data) external returns (uint256) {} + function collect( + address serviceProvider, + IGraphPayments.PaymentTypes feeType, + bytes calldata data + ) external returns (uint256) {} function slash(address serviceProvider, bytes calldata data) external {} diff --git a/packages/horizon/test/data-service/implementations/DataServiceBaseUpgradeable.sol b/packages/horizon/test/data-service/implementations/DataServiceBaseUpgradeable.sol index a7ebfd465..907ad6e3a 100644 --- a/packages/horizon/test/data-service/implementations/DataServiceBaseUpgradeable.sol +++ b/packages/horizon/test/data-service/implementations/DataServiceBaseUpgradeable.sol @@ -21,7 +21,11 @@ contract DataServiceBaseUpgradeable is DataService { function stopService(address serviceProvider, bytes calldata data) external {} - function collect(address serviceProvider, IGraphPayments.PaymentTypes feeType, bytes calldata data) external returns (uint256) {} + function collect( + address serviceProvider, + IGraphPayments.PaymentTypes feeType, + bytes calldata data + ) external returns (uint256) {} function slash(address serviceProvider, bytes calldata data) external {} diff --git a/packages/horizon/test/data-service/implementations/DataServiceImpFees.sol b/packages/horizon/test/data-service/implementations/DataServiceImpFees.sol index ac5c79c89..163281d32 100644 --- a/packages/horizon/test/data-service/implementations/DataServiceImpFees.sol +++ b/packages/horizon/test/data-service/implementations/DataServiceImpFees.sol @@ -21,7 +21,11 @@ contract DataServiceImpFees is DataServiceFees { function stopService(address serviceProvider, bytes calldata data) external {} - function collect(address serviceProvider, IGraphPayments.PaymentTypes, bytes calldata data) external returns (uint256) { + function collect( + address serviceProvider, + IGraphPayments.PaymentTypes, + bytes calldata data + ) external returns (uint256) { uint256 amount = abi.decode(data, (uint256)); _releaseStake(serviceProvider, 0); _lockStake(serviceProvider, amount * STAKE_TO_FEES_RATIO, block.timestamp + LOCK_DURATION); diff --git a/packages/horizon/test/data-service/implementations/DataServiceImpPausable.sol b/packages/horizon/test/data-service/implementations/DataServiceImpPausable.sol index 5073207ab..678f46cc0 100644 --- a/packages/horizon/test/data-service/implementations/DataServiceImpPausable.sol +++ b/packages/horizon/test/data-service/implementations/DataServiceImpPausable.sol @@ -29,7 +29,11 @@ contract DataServiceImpPausable is DataServicePausable { function stopService(address serviceProvider, bytes calldata data) external {} - function collect(address serviceProvider, IGraphPayments.PaymentTypes feeType, bytes calldata data) external returns (uint256) {} + function collect( + address serviceProvider, + IGraphPayments.PaymentTypes feeType, + bytes calldata data + ) external returns (uint256) {} function slash(address serviceProvider, bytes calldata data) external {} diff --git a/packages/horizon/test/data-service/implementations/DataServiceImpPausableUpgradeable.sol b/packages/horizon/test/data-service/implementations/DataServiceImpPausableUpgradeable.sol index cea615885..dd2ea21f1 100644 --- a/packages/horizon/test/data-service/implementations/DataServiceImpPausableUpgradeable.sol +++ b/packages/horizon/test/data-service/implementations/DataServiceImpPausableUpgradeable.sol @@ -23,7 +23,11 @@ contract DataServiceImpPausableUpgradeable is DataServicePausableUpgradeable { function stopService(address serviceProvider, bytes calldata data) external {} - function collect(address serviceProvider, IGraphPayments.PaymentTypes feeType, bytes calldata data) external returns (uint256) {} + function collect( + address serviceProvider, + IGraphPayments.PaymentTypes feeType, + bytes calldata data + ) external returns (uint256) {} function slash(address serviceProvider, bytes calldata data) external {} diff --git a/packages/horizon/test/data-service/libraries/ProvisionTracker.t.sol b/packages/horizon/test/data-service/libraries/ProvisionTracker.t.sol index af147fdd6..7d8541cec 100644 --- a/packages/horizon/test/data-service/libraries/ProvisionTracker.t.sol +++ b/packages/horizon/test/data-service/libraries/ProvisionTracker.t.sol @@ -86,13 +86,19 @@ contract ProvisionTrackerTest is HorizonStakingSharedTest, ProvisionTrackerImple assertEq(provisionTracker[users.indexer], delta); } - function test_Release_RevertGiven_TheProvisionHasInsufficientLockedTokens(uint256 tokens) external useIndexer useProvisionDataService(address(this), tokens, 0, 0) { + function test_Release_RevertGiven_TheProvisionHasInsufficientLockedTokens( + uint256 tokens + ) external useIndexer useProvisionDataService(address(this), tokens, 0, 0) { // setup provisionTracker.lock(staking, users.indexer, tokens, uint32(0)); uint256 tokensToRelease = tokens + 1; vm.expectRevert( - abi.encodeWithSelector(ProvisionTracker.ProvisionTrackerInsufficientTokens.selector, tokens, tokensToRelease) + abi.encodeWithSelector( + ProvisionTracker.ProvisionTrackerInsufficientTokens.selector, + tokens, + tokensToRelease + ) ); provisionTracker.release(users.indexer, tokensToRelease); } diff --git a/packages/horizon/test/data-service/libraries/ProvisionTrackerImplementation.sol b/packages/horizon/test/data-service/libraries/ProvisionTrackerImplementation.sol index 5c9cf4a6a..d79d13da0 100644 --- a/packages/horizon/test/data-service/libraries/ProvisionTrackerImplementation.sol +++ b/packages/horizon/test/data-service/libraries/ProvisionTrackerImplementation.sol @@ -4,5 +4,5 @@ pragma solidity 0.8.27; import { ProvisionTracker } from "../../../contracts/data-service/libraries/ProvisionTracker.sol"; contract ProvisionTrackerImplementation { - mapping(address => uint256) public provisionTracker; + mapping(address => uint256) public provisionTracker; } diff --git a/packages/horizon/test/escrow/GraphEscrow.t.sol b/packages/horizon/test/escrow/GraphEscrow.t.sol index ee41a7909..4c6933adf 100644 --- a/packages/horizon/test/escrow/GraphEscrow.t.sol +++ b/packages/horizon/test/escrow/GraphEscrow.t.sol @@ -61,7 +61,11 @@ contract GraphEscrowTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest { function _cancelThawEscrow(address collector, address receiver) internal { (, address msgSender, ) = vm.readCallers(); - (, uint256 amountThawingBefore, uint256 thawEndTimestampBefore) = escrow.escrowAccounts(msgSender, collector, receiver); + (, uint256 amountThawingBefore, uint256 thawEndTimestampBefore) = escrow.escrowAccounts( + msgSender, + collector, + receiver + ); vm.expectEmit(address(escrow)); emit IPaymentsEscrow.CancelThaw(msgSender, collector, receiver, amountThawingBefore, thawEndTimestampBefore); @@ -84,7 +88,11 @@ contract GraphEscrowTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest { emit IPaymentsEscrow.Withdraw(msgSender, collector, receiver, amountToWithdraw); escrow.withdraw(collector, receiver); - (uint256 balanceAfter, uint256 tokensThawingAfter, uint256 thawEndTimestampAfter) = escrow.escrowAccounts(msgSender, collector, receiver); + (uint256 balanceAfter, uint256 tokensThawingAfter, uint256 thawEndTimestampAfter) = escrow.escrowAccounts( + msgSender, + collector, + receiver + ); uint256 tokenBalanceAfterSender = token.balanceOf(msgSender); uint256 tokenBalanceAfterEscrow = token.balanceOf(address(escrow)); @@ -93,7 +101,7 @@ contract GraphEscrowTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest { assertEq(thawEndTimestampAfter, 0); assertEq(tokenBalanceAfterSender, tokenBalanceBeforeSender + amountToWithdraw); - assertEq(tokenBalanceAfterEscrow, tokenBalanceBeforeEscrow - amountToWithdraw); + assertEq(tokenBalanceAfterEscrow, tokenBalanceBeforeEscrow - amountToWithdraw); } struct CollectPaymentData { diff --git a/packages/horizon/test/escrow/deposit.t.sol b/packages/horizon/test/escrow/deposit.t.sol index fba3b7c0d..bab8d0e5f 100644 --- a/packages/horizon/test/escrow/deposit.t.sol +++ b/packages/horizon/test/escrow/deposit.t.sol @@ -31,7 +31,7 @@ contract GraphEscrowDepositTest is GraphEscrowTest { _depositTokens(users.verifier, users.indexer, amount1); _depositTokens(users.verifier, users.indexer, amount2); - (uint256 balance,,) = escrow.escrowAccounts(users.gateway, users.verifier, users.indexer); + (uint256 balance, , ) = escrow.escrowAccounts(users.gateway, users.verifier, users.indexer); assertEq(balance, amount1 + amount2); } } diff --git a/packages/horizon/test/escrow/paused.t.sol b/packages/horizon/test/escrow/paused.t.sol index 6019b5c15..a75532ed6 100644 --- a/packages/horizon/test/escrow/paused.t.sol +++ b/packages/horizon/test/escrow/paused.t.sol @@ -9,14 +9,13 @@ import { IPaymentsEscrow } from "../../contracts/interfaces/IPaymentsEscrow.sol" import { GraphEscrowTest } from "./GraphEscrow.t.sol"; contract GraphEscrowPausedTest is GraphEscrowTest { - /* * MODIFIERS */ modifier usePaused(bool paused) { address msgSender; - (, msgSender,) = vm.readCallers(); + (, msgSender, ) = vm.readCallers(); resetPrank(users.governor); controller.setPaused(paused); resetPrank(msgSender); @@ -46,7 +45,7 @@ contract GraphEscrowPausedTest is GraphEscrowTest { } function testPaused_RevertWhen_WithdrawTokens( - uint256 tokens, + uint256 tokens, uint256 thawAmount ) public useGateway depositAndThawTokens(tokens, thawAmount) usePaused(true) { // advance time @@ -61,6 +60,13 @@ contract GraphEscrowPausedTest is GraphEscrowTest { function testPaused_RevertWhen_CollectTokens(uint256 tokens, uint256 tokensDataService) public usePaused(true) { resetPrank(users.verifier); vm.expectRevert(abi.encodeWithSelector(IPaymentsEscrow.PaymentsEscrowIsPaused.selector)); - escrow.collect(IGraphPayments.PaymentTypes.QueryFee, users.gateway, users.indexer, tokens, subgraphDataServiceAddress, tokensDataService); + escrow.collect( + IGraphPayments.PaymentTypes.QueryFee, + users.gateway, + users.indexer, + tokens, + subgraphDataServiceAddress, + tokensDataService + ); } -} \ No newline at end of file +} diff --git a/packages/horizon/test/escrow/withdraw.t.sol b/packages/horizon/test/escrow/withdraw.t.sol index db7001fd8..ff4d98650 100644 --- a/packages/horizon/test/escrow/withdraw.t.sol +++ b/packages/horizon/test/escrow/withdraw.t.sol @@ -7,13 +7,12 @@ import { IGraphPayments } from "../../contracts/interfaces/IGraphPayments.sol"; import { GraphEscrowTest } from "./GraphEscrow.t.sol"; contract GraphEscrowWithdrawTest is GraphEscrowTest { - /* * TESTS */ function testWithdraw_Tokens( - uint256 amount, + uint256 amount, uint256 thawAmount ) public useGateway depositAndThawTokens(amount, thawAmount) { // advance time @@ -33,7 +32,11 @@ contract GraphEscrowWithdrawTest is GraphEscrowTest { uint256 amount, uint256 thawAmount ) public useGateway depositAndThawTokens(amount, thawAmount) { - bytes memory expectedError = abi.encodeWithSignature("PaymentsEscrowStillThawing(uint256,uint256)", block.timestamp, block.timestamp + withdrawEscrowThawingPeriod); + bytes memory expectedError = abi.encodeWithSignature( + "PaymentsEscrowStillThawing(uint256,uint256)", + block.timestamp, + block.timestamp + withdrawEscrowThawingPeriod + ); vm.expectRevert(expectedError); escrow.withdraw(users.verifier, users.indexer); } @@ -68,4 +71,4 @@ contract GraphEscrowWithdrawTest is GraphEscrowTest { resetPrank(users.gateway); _withdrawEscrow(users.verifier, users.indexer); } -} \ No newline at end of file +} diff --git a/packages/horizon/test/libraries/LinkedList.t.sol b/packages/horizon/test/libraries/LinkedList.t.sol index 1850cdb47..3bf957a11 100644 --- a/packages/horizon/test/libraries/LinkedList.t.sol +++ b/packages/horizon/test/libraries/LinkedList.t.sol @@ -2,16 +2,16 @@ pragma solidity 0.8.27; import "forge-std/console.sol"; -import {Test} from "forge-std/Test.sol"; -import {LinkedList} from "../../contracts/libraries/LinkedList.sol"; +import { Test } from "forge-std/Test.sol"; +import { LinkedList } from "../../contracts/libraries/LinkedList.sol"; -import {ListImplementation} from "./ListImplementation.sol"; +import { ListImplementation } from "./ListImplementation.sol"; contract LinkedListTest is Test, ListImplementation { using LinkedList for LinkedList.List; function setUp() internal { - list = LinkedList.List({head: bytes32(0), tail: bytes32(0), nonce: 0, count: 0}); + list = LinkedList.List({ head: bytes32(0), tail: bytes32(0), nonce: 0, count: 0 }); } function test_Add_RevertGiven_TheItemIdIsZero() external { @@ -161,8 +161,13 @@ contract LinkedListTest is Test, ListImplementation { } } - (uint256 processedCount, bytes memory acc) = - list.traverse(_getNextItem, _processItem, _deleteItem, _initAcc, _n); + (uint256 processedCount, bytes memory acc) = list.traverse( + _getNextItem, + _processItem, + _deleteItem, + _initAcc, + _n + ); uint256 afterNonce = list.nonce; uint256 afterCount = list.count; bytes32 afterTail = list.tail; diff --git a/packages/horizon/test/libraries/PPMMath.t.sol b/packages/horizon/test/libraries/PPMMath.t.sol index 8aff288b5..2906bfc4c 100644 --- a/packages/horizon/test/libraries/PPMMath.t.sol +++ b/packages/horizon/test/libraries/PPMMath.t.sol @@ -11,7 +11,7 @@ contract PPMMathTest is Test { function test_mulPPM(uint256 a, uint256 b) public pure { a = bound(a, 0, MAX_PPM); b = bound(b, 0, type(uint256).max / MAX_PPM); - + uint256 result = PPMMath.mulPPM(a, b); assertEq(result, (a * b) / MAX_PPM); } @@ -19,7 +19,7 @@ contract PPMMathTest is Test { function test_mulPPMRoundUp(uint256 a, uint256 b) public pure { a = bound(a, 0, type(uint256).max / MAX_PPM); b = bound(b, 0, MAX_PPM); - + uint256 result = PPMMath.mulPPMRoundUp(a, b); assertEq(result, a - PPMMath.mulPPM(a, MAX_PPM - b)); } diff --git a/packages/horizon/test/payments/graph-tally-collector/GraphTallyCollector.t.sol b/packages/horizon/test/payments/graph-tally-collector/GraphTallyCollector.t.sol index b824d59ef..6b29153de 100644 --- a/packages/horizon/test/payments/graph-tally-collector/GraphTallyCollector.t.sol +++ b/packages/horizon/test/payments/graph-tally-collector/GraphTallyCollector.t.sol @@ -48,7 +48,9 @@ contract GraphTallyTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest { function _getSignerProof(uint256 _proofDeadline, uint256 _signer) internal returns (bytes memory) { (, address msgSender, ) = vm.readCallers(); - bytes32 messageHash = keccak256(abi.encodePacked(block.chainid, address(graphTallyCollector), _proofDeadline, msgSender)); + bytes32 messageHash = keccak256( + abi.encodePacked(block.chainid, address(graphTallyCollector), _proofDeadline, msgSender) + ); bytes32 proofToDigest = MessageHashUtils.toEthSignedMessageHash(messageHash); (uint8 v, bytes32 r, bytes32 s) = vm.sign(_signer, proofToDigest); return abi.encodePacked(r, s, v); diff --git a/packages/horizon/test/payments/graph-tally-collector/collect/collect.t.sol b/packages/horizon/test/payments/graph-tally-collector/collect/collect.t.sol index cf892b89e..d59de2a1f 100644 --- a/packages/horizon/test/payments/graph-tally-collector/collect/collect.t.sol +++ b/packages/horizon/test/payments/graph-tally-collector/collect/collect.t.sol @@ -271,7 +271,11 @@ contract GraphTallyCollectTest is GraphTallyTest { // Attempt to collect again vm.expectRevert( - abi.encodeWithSelector(IGraphTallyCollector.GraphTallyCollectorInconsistentRAVTokens.selector, tokens, tokens) + abi.encodeWithSelector( + IGraphTallyCollector.GraphTallyCollectorInconsistentRAVTokens.selector, + tokens, + tokens + ) ); graphTallyCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); } @@ -466,7 +470,11 @@ contract GraphTallyCollectTest is GraphTallyTest { // Try to collect again with the same allocation - should revert bytes memory data = _getQueryFeeEncodedData(signerPrivateKey, collectTestParams[i]); vm.expectRevert( - abi.encodeWithSelector(IGraphTallyCollector.GraphTallyCollectorInconsistentRAVTokens.selector, tokens, tokens) + abi.encodeWithSelector( + IGraphTallyCollector.GraphTallyCollectorInconsistentRAVTokens.selector, + tokens, + tokens + ) ); graphTallyCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); } diff --git a/packages/horizon/test/payments/graph-tally-collector/signer/authorizeSigner.t.sol b/packages/horizon/test/payments/graph-tally-collector/signer/authorizeSigner.t.sol index 192ac4c64..2cec32716 100644 --- a/packages/horizon/test/payments/graph-tally-collector/signer/authorizeSigner.t.sol +++ b/packages/horizon/test/payments/graph-tally-collector/signer/authorizeSigner.t.sol @@ -8,7 +8,6 @@ import { IGraphTallyCollector } from "../../../../contracts/interfaces/IGraphTal import { GraphTallyTest } from "../GraphTallyCollector.t.sol"; contract GraphTallyAuthorizeSignerTest is GraphTallyTest { - uint256 constant SECP256K1_CURVE_ORDER = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141; /* @@ -26,9 +25,11 @@ contract GraphTallyAuthorizeSignerTest is GraphTallyTest { // Sign proof with payer uint256 proofDeadline = block.timestamp + 1; bytes memory signerProof = _getSignerProof(proofDeadline, signerPrivateKey); - + // Attempt to authorize delegator with payer's proof - bytes memory expectedError = abi.encodeWithSelector(IGraphTallyCollector.GraphTallyCollectorInvalidSignerProof.selector); + bytes memory expectedError = abi.encodeWithSelector( + IGraphTallyCollector.GraphTallyCollectorInvalidSignerProof.selector + ); vm.expectRevert(expectedError); graphTallyCollector.authorizeSigner(users.delegator, proofDeadline, signerProof); } @@ -74,7 +75,7 @@ contract GraphTallyAuthorizeSignerTest is GraphTallyTest { // Sign proof with payer uint256 proofDeadline = block.timestamp - 1; bytes memory signerProof = _getSignerProof(proofDeadline, signerPrivateKey); - + // Attempt to authorize delegator with expired proof bytes memory expectedError = abi.encodeWithSelector( IGraphTallyCollector.GraphTallyCollectorInvalidSignerProofDeadline.selector, diff --git a/packages/horizon/test/payments/graph-tally-collector/signer/cancelThawSigner.t.sol b/packages/horizon/test/payments/graph-tally-collector/signer/cancelThawSigner.t.sol index fae5a943f..aa741276d 100644 --- a/packages/horizon/test/payments/graph-tally-collector/signer/cancelThawSigner.t.sol +++ b/packages/horizon/test/payments/graph-tally-collector/signer/cancelThawSigner.t.sol @@ -8,7 +8,6 @@ import { IGraphTallyCollector } from "../../../../contracts/interfaces/IGraphTal import { GraphTallyTest } from "../GraphTallyCollector.t.sol"; contract GraphTallyCancelThawSignerTest is GraphTallyTest { - /* * TESTS */ @@ -27,7 +26,7 @@ contract GraphTallyCancelThawSignerTest is GraphTallyTest { vm.expectRevert(expectedError); graphTallyCollector.thawSigner(signer); } - + function testGraphTally_CancelThawSigner_RevertWhen_NotThawing() public useGateway useSigner { bytes memory expectedError = abi.encodeWithSelector( IGraphTallyCollector.GraphTallyCollectorSignerNotThawing.selector, diff --git a/packages/horizon/test/payments/graph-tally-collector/signer/revokeSigner.t.sol b/packages/horizon/test/payments/graph-tally-collector/signer/revokeSigner.t.sol index f6a53e9c3..d73438a37 100644 --- a/packages/horizon/test/payments/graph-tally-collector/signer/revokeSigner.t.sol +++ b/packages/horizon/test/payments/graph-tally-collector/signer/revokeSigner.t.sol @@ -8,7 +8,6 @@ import { IGraphTallyCollector } from "../../../../contracts/interfaces/IGraphTal import { GraphTallyTest } from "../GraphTallyCollector.t.sol"; contract GraphTallyRevokeAuthorizedSignerTest is GraphTallyTest { - /* * TESTS */ @@ -31,7 +30,7 @@ contract GraphTallyRevokeAuthorizedSignerTest is GraphTallyTest { vm.expectRevert(expectedError); graphTallyCollector.revokeAuthorizedSigner(signer); } - + function testGraphTally_RevokeAuthorizedSigner_RevertWhen_NotThawing() public useGateway useSigner { bytes memory expectedError = abi.encodeWithSelector( IGraphTallyCollector.GraphTallyCollectorSignerNotThawing.selector, diff --git a/packages/horizon/test/payments/graph-tally-collector/signer/thawSigner.t.sol b/packages/horizon/test/payments/graph-tally-collector/signer/thawSigner.t.sol index 7be6d28bf..2d08512e7 100644 --- a/packages/horizon/test/payments/graph-tally-collector/signer/thawSigner.t.sol +++ b/packages/horizon/test/payments/graph-tally-collector/signer/thawSigner.t.sol @@ -8,7 +8,6 @@ import { IGraphTallyCollector } from "../../../../contracts/interfaces/IGraphTal import { GraphTallyTest } from "../GraphTallyCollector.t.sol"; contract GraphTallyThawSignerTest is GraphTallyTest { - /* * TESTS */ @@ -44,7 +43,7 @@ contract GraphTallyThawSignerTest is GraphTallyTest { function testGraphTally_ThawSigner_RevertWhen_AlreadyThawing() public useGateway useSigner { _thawSigner(signer); - (,uint256 thawEndTimestamp,) = graphTallyCollector.authorizedSigners(signer); + (, uint256 thawEndTimestamp, ) = graphTallyCollector.authorizedSigners(signer); bytes memory expectedError = abi.encodeWithSelector( IGraphTallyCollector.GraphTallyCollectorSignerAlreadyThawing.selector, signer, diff --git a/packages/horizon/test/shared/horizon-staking/HorizonStakingShared.t.sol b/packages/horizon/test/shared/horizon-staking/HorizonStakingShared.t.sol index 94e943347..d3b25ad1c 100644 --- a/packages/horizon/test/shared/horizon-staking/HorizonStakingShared.t.sol +++ b/packages/horizon/test/shared/horizon-staking/HorizonStakingShared.t.sol @@ -213,7 +213,10 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { } else { if (withdrawCalled) { vm.expectEmit(address(staking)); - emit IHorizonStakingMain.HorizonStakeWithdrawn(msgSender, beforeServiceProvider.__DEPRECATED_tokensLocked); + emit IHorizonStakingMain.HorizonStakeWithdrawn( + msgSender, + beforeServiceProvider.__DEPRECATED_tokensLocked + ); } vm.expectEmit(address(staking)); @@ -430,9 +433,20 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { // after Provision memory afterProvision = staking.getProvision(serviceProvider, verifier); - ThawRequest memory afterThawRequest = staking.getThawRequest(IHorizonStakingTypes.ThawRequestType.Provision, thawRequestId); - LinkedList.List memory afterThawRequestList = _getThawRequestList(IHorizonStakingTypes.ThawRequestType.Provision, serviceProvider, verifier, serviceProvider); - ThawRequest memory afterPreviousTailThawRequest = staking.getThawRequest(IHorizonStakingTypes.ThawRequestType.Provision, beforeThawRequestList.tail); + ThawRequest memory afterThawRequest = staking.getThawRequest( + IHorizonStakingTypes.ThawRequestType.Provision, + thawRequestId + ); + LinkedList.List memory afterThawRequestList = _getThawRequestList( + IHorizonStakingTypes.ThawRequestType.Provision, + serviceProvider, + verifier, + serviceProvider + ); + ThawRequest memory afterPreviousTailThawRequest = staking.getThawRequest( + IHorizonStakingTypes.ThawRequestType.Provision, + beforeThawRequestList.tail + ); // assert assertEq(afterProvision.tokens, beforeProvision.tokens); @@ -543,7 +557,10 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { beforeServiceProvider.__DEPRECATED_tokensLockedUntil ); for (uint i = 0; i < calcValues.thawRequestsFulfilledListIds.length; i++) { - ThawRequest memory thawRequest = staking.getThawRequest(IHorizonStakingTypes.ThawRequestType.Provision, calcValues.thawRequestsFulfilledListIds[i]); + ThawRequest memory thawRequest = staking.getThawRequest( + IHorizonStakingTypes.ThawRequestType.Provision, + calcValues.thawRequestsFulfilledListIds[i] + ); assertEq(thawRequest.shares, 0); assertEq(thawRequest.thawingUntil, 0); assertEq(thawRequest.next, bytes32(0)); @@ -586,7 +603,12 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { provision: staking.getProvision(serviceProvider, verifier), provisionNewVerifier: staking.getProvision(serviceProvider, newVerifier), serviceProvider: _getStorage_ServiceProviderInternal(serviceProvider), - thawRequestList: staking.getThawRequestList(IHorizonStakingTypes.ThawRequestType.Provision, serviceProvider, verifier, serviceProvider) + thawRequestList: staking.getThawRequestList( + IHorizonStakingTypes.ThawRequestType.Provision, + serviceProvider, + verifier, + serviceProvider + ) }); // calc @@ -687,7 +709,10 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { // assert: thaw request list old verifier for (uint i = 0; i < calcValues.thawRequestsFulfilledListIds.length; i++) { - ThawRequest memory thawRequest = staking.getThawRequest(IHorizonStakingTypes.ThawRequestType.Provision, calcValues.thawRequestsFulfilledListIds[i]); + ThawRequest memory thawRequest = staking.getThawRequest( + IHorizonStakingTypes.ThawRequestType.Provision, + calcValues.thawRequestsFulfilledListIds[i] + ); assertEq(thawRequest.shares, 0); assertEq(thawRequest.thawingUntil, 0); assertEq(thawRequest.next, bytes32(0)); @@ -947,7 +972,12 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { BeforeValues_Undelegate memory beforeValues; beforeValues.pool = _getStorage_DelegationPoolInternal(serviceProvider, verifier, legacy); beforeValues.delegation = _getStorage_Delegation(serviceProvider, verifier, delegator, legacy); - beforeValues.thawRequestList = staking.getThawRequestList(thawRequestType, serviceProvider, verifier, delegator); + beforeValues.thawRequestList = staking.getThawRequestList( + thawRequestType, + serviceProvider, + verifier, + delegator + ); beforeValues.delegatedTokens = staking.getDelegatedTokensAvailable(serviceProvider, verifier); // calc @@ -997,7 +1027,12 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { beneficiary, legacy ); - LinkedList.List memory afterThawRequestList = staking.getThawRequestList(thawRequestType, serviceProvider, verifier, beneficiary); + LinkedList.List memory afterThawRequestList = staking.getThawRequestList( + thawRequestType, + serviceProvider, + verifier, + beneficiary + ); ThawRequest memory afterThawRequest = staking.getThawRequest(thawRequestType, calcValues.thawRequestId); uint256 afterDelegatedTokens = staking.getDelegatedTokensAvailable(serviceProvider, verifier); @@ -1022,11 +1057,7 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { assertEq(afterDelegatedTokens + calcValues.tokens, beforeValues.delegatedTokens); } - function _withdrawDelegated( - address serviceProvider, - address verifier, - uint256 nThawRequests - ) internal { + function _withdrawDelegated(address serviceProvider, address verifier, uint256 nThawRequests) internal { Params_WithdrawDelegated memory params = Params_WithdrawDelegated({ thawRequestType: IHorizonStakingTypes.ThawRequestType.Delegation, serviceProvider: serviceProvider, @@ -1097,9 +1128,23 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { // before BeforeValues_WithdrawDelegated memory beforeValues; beforeValues.pool = _getStorage_DelegationPoolInternal(params.serviceProvider, params.verifier, params.legacy); - beforeValues.newPool = _getStorage_DelegationPoolInternal(params.newServiceProvider, params.newVerifier, params.legacy); - beforeValues.newDelegation = _getStorage_Delegation(params.newServiceProvider, params.newVerifier, msgSender, params.legacy); - beforeValues.thawRequestList = staking.getThawRequestList(params.thawRequestType, params.serviceProvider, params.verifier, msgSender); + beforeValues.newPool = _getStorage_DelegationPoolInternal( + params.newServiceProvider, + params.newVerifier, + params.legacy + ); + beforeValues.newDelegation = _getStorage_Delegation( + params.newServiceProvider, + params.newVerifier, + msgSender, + params.legacy + ); + beforeValues.thawRequestList = staking.getThawRequestList( + params.thawRequestType, + params.serviceProvider, + params.verifier, + msgSender + ); beforeValues.senderBalance = token.balanceOf(msgSender); beforeValues.stakingBalance = token.balanceOf(address(staking)); @@ -1146,7 +1191,7 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { ); } else { emit Transfer(address(staking), msgSender, calcValues.tokensThawed); - + vm.expectEmit(); emit IHorizonStakingMain.DelegatedTokensWithdrawn( params.serviceProvider, @@ -1175,9 +1220,23 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { // after AfterValues_WithdrawDelegated memory afterValues; afterValues.pool = _getStorage_DelegationPoolInternal(params.serviceProvider, params.verifier, params.legacy); - afterValues.newPool = _getStorage_DelegationPoolInternal(params.newServiceProvider, params.newVerifier, params.legacy); - afterValues.newDelegation = _getStorage_Delegation(params.newServiceProvider, params.newVerifier, msgSender, params.legacy); - afterValues.thawRequestList = staking.getThawRequestList(params.thawRequestType, params.serviceProvider, params.verifier, msgSender); + afterValues.newPool = _getStorage_DelegationPoolInternal( + params.newServiceProvider, + params.newVerifier, + params.legacy + ); + afterValues.newDelegation = _getStorage_Delegation( + params.newServiceProvider, + params.newVerifier, + msgSender, + params.legacy + ); + afterValues.thawRequestList = staking.getThawRequestList( + params.thawRequestType, + params.serviceProvider, + params.verifier, + msgSender + ); afterValues.senderBalance = token.balanceOf(msgSender); afterValues.stakingBalance = token.balanceOf(address(staking)); @@ -1189,7 +1248,10 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { assertEq(afterValues.pool.thawingNonce, beforeValues.pool.thawingNonce); for (uint i = 0; i < calcValues.thawRequestsFulfilledListIds.length; i++) { - ThawRequest memory thawRequest = staking.getThawRequest(params.thawRequestType, calcValues.thawRequestsFulfilledListIds[i]); + ThawRequest memory thawRequest = staking.getThawRequest( + params.thawRequestType, + calcValues.thawRequestsFulfilledListIds[i] + ); assertEq(thawRequest.shares, 0); assertEq(thawRequest.thawingUntil, 0); assertEq(thawRequest.next, bytes32(0)); @@ -1444,7 +1506,9 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { uint256 tokensSlashed = calcValues.providerTokensSlashed + (isDelegationSlashingEnabled ? calcValues.delegationTokensSlashed : 0); uint256 provisionThawingTokens = (before.provision.tokensThawing * - (1e18 - ((calcValues.providerTokensSlashed * 1e18 + before.provision.tokens - 1) / before.provision.tokens))) / (1e18); + (1e18 - + ((calcValues.providerTokensSlashed * 1e18 + before.provision.tokens - 1) / + before.provision.tokens))) / (1e18); // assert assertEq(afterProvision.tokens + calcValues.providerTokensSlashed, before.provision.tokens); @@ -1458,16 +1522,26 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { assertEq(afterProvision.thawingPeriod, before.provision.thawingPeriod); assertEq(afterProvision.thawingPeriodPending, before.provision.thawingPeriodPending); assertEq( - afterProvision.thawingNonce, - (before.provision.sharesThawing != 0 && afterProvision.sharesThawing == 0) ? before.provision.thawingNonce + 1 : before.provision.thawingNonce); + afterProvision.thawingNonce, + (before.provision.sharesThawing != 0 && afterProvision.sharesThawing == 0) + ? before.provision.thawingNonce + 1 + : before.provision.thawingNonce + ); if (isDelegationSlashingEnabled) { uint256 poolThawingTokens = (before.pool.tokensThawing * - (1e18 - ((calcValues.delegationTokensSlashed * 1e18 + before.pool.tokens - 1) / before.pool.tokens))) / (1e18); + (1e18 - + ((calcValues.delegationTokensSlashed * 1e18 + before.pool.tokens - 1) / before.pool.tokens))) / + (1e18); assertEq(afterPool.tokens + calcValues.delegationTokensSlashed, before.pool.tokens); assertEq(afterPool.shares, before.pool.shares); assertEq(afterPool.tokensThawing, poolThawingTokens); assertEq(afterPool.sharesThawing, afterPool.tokensThawing == 0 ? 0 : before.pool.sharesThawing); - assertEq(afterPool.thawingNonce, (before.pool.sharesThawing != 0 && afterPool.sharesThawing == 0) ? before.pool.thawingNonce + 1 : before.pool.thawingNonce); + assertEq( + afterPool.thawingNonce, + (before.pool.sharesThawing != 0 && afterPool.sharesThawing == 0) + ? before.pool.thawingNonce + 1 + : before.pool.thawingNonce + ); } assertEq(before.stakingBalance - tokensSlashed, afterStakingBalance); @@ -2251,7 +2325,9 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { bool delegation; } - function calcThawRequestData(Params_CalcThawRequestData memory params) private view returns (CalcValues_ThawRequestData memory) { + function calcThawRequestData( + Params_CalcThawRequestData memory params + ) private view returns (CalcValues_ThawRequestData memory) { LinkedList.List memory thawRequestList = _getThawRequestList( params.thawRequestType, params.serviceProvider, @@ -2274,7 +2350,8 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { bytes32 thawRequestId = thawRequestList.head; while (thawRequestId != bytes32(0) && (params.iterations == 0 || thawRequestsFulfilled < params.iterations)) { ThawRequest memory thawRequest = _getThawRequest(params.thawRequestType, thawRequestId); - bool isThawRequestValid = thawRequest.thawingNonce == (params.delegation ? pool.thawingNonce : prov.thawingNonce); + bool isThawRequestValid = thawRequest.thawingNonce == + (params.delegation ? pool.thawingNonce : prov.thawingNonce); if (thawRequest.thawingUntil <= block.timestamp) { thawRequestsFulfilled++; if (isThawRequestValid) { @@ -2305,7 +2382,8 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { thawRequestId = thawRequestList.head; while (thawRequestId != bytes32(0) && (params.iterations == 0 || i < params.iterations)) { ThawRequest memory thawRequest = _getThawRequest(params.thawRequestType, thawRequestId); - bool isThawRequestValid = thawRequest.thawingNonce == (params.delegation ? pool.thawingNonce : prov.thawingNonce); + bool isThawRequestValid = thawRequest.thawingNonce == + (params.delegation ? pool.thawingNonce : prov.thawingNonce); if (thawRequest.thawingUntil <= block.timestamp) { if (isThawRequestValid) { @@ -2336,21 +2414,13 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { address verifier, address owner ) private view returns (LinkedList.List memory) { - return staking.getThawRequestList( - thawRequestType, - serviceProvider, - verifier, - owner - ); + return staking.getThawRequestList(thawRequestType, serviceProvider, verifier, owner); } function _getThawRequest( IHorizonStakingTypes.ThawRequestType thawRequestType, bytes32 thawRequestId ) private view returns (ThawRequest memory) { - return staking.getThawRequest( - thawRequestType, - thawRequestId - ); + return staking.getThawRequest(thawRequestType, thawRequestId); } } diff --git a/packages/horizon/test/shared/payments-escrow/PaymentsEscrowShared.t.sol b/packages/horizon/test/shared/payments-escrow/PaymentsEscrowShared.t.sol index 28b0327ae..72e92dfde 100644 --- a/packages/horizon/test/shared/payments-escrow/PaymentsEscrowShared.t.sol +++ b/packages/horizon/test/shared/payments-escrow/PaymentsEscrowShared.t.sol @@ -7,7 +7,6 @@ import { IPaymentsEscrow } from "../../../contracts/interfaces/IPaymentsEscrow.s import { GraphBaseTest } from "../../GraphBase.t.sol"; abstract contract PaymentsEscrowSharedTest is GraphBaseTest { - /* * MODIFIERS */ @@ -21,29 +20,29 @@ abstract contract PaymentsEscrowSharedTest is GraphBaseTest { /* * HELPERS */ - + function _depositTokens(address _collector, address _receiver, uint256 _tokens) internal { (, address msgSender, ) = vm.readCallers(); - (uint256 escrowBalanceBefore,,) = escrow.escrowAccounts(msgSender, _collector, _receiver); + (uint256 escrowBalanceBefore, , ) = escrow.escrowAccounts(msgSender, _collector, _receiver); token.approve(address(escrow), _tokens); vm.expectEmit(address(escrow)); emit IPaymentsEscrow.Deposit(msgSender, _collector, _receiver, _tokens); escrow.deposit(_collector, _receiver, _tokens); - (uint256 escrowBalanceAfter,,) = escrow.escrowAccounts(msgSender, _collector, _receiver); + (uint256 escrowBalanceAfter, , ) = escrow.escrowAccounts(msgSender, _collector, _receiver); assertEq(escrowBalanceAfter - _tokens, escrowBalanceBefore); } - + function _depositToTokens(address _payer, address _collector, address _receiver, uint256 _tokens) internal { - (uint256 escrowBalanceBefore,,) = escrow.escrowAccounts(_payer, _collector, _receiver); + (uint256 escrowBalanceBefore, , ) = escrow.escrowAccounts(_payer, _collector, _receiver); token.approve(address(escrow), _tokens); vm.expectEmit(address(escrow)); emit IPaymentsEscrow.Deposit(_payer, _collector, _receiver, _tokens); escrow.depositTo(_payer, _collector, _receiver, _tokens); - (uint256 escrowBalanceAfter,,) = escrow.escrowAccounts(_payer, _collector, _receiver); + (uint256 escrowBalanceAfter, , ) = escrow.escrowAccounts(_payer, _collector, _receiver); assertEq(escrowBalanceAfter - _tokens, escrowBalanceBefore); } } diff --git a/packages/horizon/test/staking/HorizonStaking.t.sol b/packages/horizon/test/staking/HorizonStaking.t.sol index d57b1c1b8..5dd4d6153 100644 --- a/packages/horizon/test/staking/HorizonStaking.t.sol +++ b/packages/horizon/test/staking/HorizonStaking.t.sol @@ -59,19 +59,19 @@ contract HorizonStakingTest is HorizonStakingSharedTest { modifier useUndelegate(uint256 shares) { resetPrank(users.delegator); - + DelegationPoolInternalTest memory pool = _getStorage_DelegationPoolInternal( users.indexer, subgraphDataServiceAddress, false ); DelegationInternal memory delegation = _getStorage_Delegation( - users.indexer, - subgraphDataServiceAddress, - users.delegator, + users.indexer, + subgraphDataServiceAddress, + users.delegator, false ); - + shares = bound(shares, 1, delegation.shares); uint256 tokens = (shares * (pool.tokens - pool.tokensThawing)) / pool.shares; if (shares < delegation.shares) { diff --git a/packages/horizon/test/staking/allocation/allocation.t.sol b/packages/horizon/test/staking/allocation/allocation.t.sol index 9e80433b3..189423632 100644 --- a/packages/horizon/test/staking/allocation/allocation.t.sol +++ b/packages/horizon/test/staking/allocation/allocation.t.sol @@ -7,7 +7,6 @@ import { HorizonStakingTest } from "../HorizonStaking.t.sol"; import { IHorizonStakingExtension } from "../../../contracts/interfaces/internal/IHorizonStakingExtension.sol"; contract HorizonStakingAllocationTest is HorizonStakingTest { - /* * TESTS */ @@ -31,4 +30,4 @@ contract HorizonStakingAllocationTest is HorizonStakingTest { bool isAllocation = staking.isAllocation(_allocationId); assertFalse(isAllocation); } -} \ No newline at end of file +} diff --git a/packages/horizon/test/staking/allocation/close.t.sol b/packages/horizon/test/staking/allocation/close.t.sol index 6257e30ec..da2e869a3 100644 --- a/packages/horizon/test/staking/allocation/close.t.sol +++ b/packages/horizon/test/staking/allocation/close.t.sol @@ -38,7 +38,7 @@ contract HorizonStakingCloseAllocationTest is HorizonStakingTest { _closeAllocation(_allocationId, _poi); } - function testCloseAllocation_Operator(uint256 tokens) public useLegacyOperator() useAllocation(1 ether) { + function testCloseAllocation_Operator(uint256 tokens) public useLegacyOperator useAllocation(1 ether) { tokens = bound(tokens, 1, MAX_STAKING_TOKENS); _createProvision(users.indexer, subgraphDataServiceLegacyAddress, tokens, 0, 0); @@ -72,18 +72,20 @@ contract HorizonStakingCloseAllocationTest is HorizonStakingTest { staking.closeAllocation(_allocationId, _poi); } - function testCloseAllocation_AfterMaxEpochs_AnyoneCanClose(uint256 tokens) public useIndexer useAllocation(1 ether) { + function testCloseAllocation_AfterMaxEpochs_AnyoneCanClose( + uint256 tokens + ) public useIndexer useAllocation(1 ether) { tokens = bound(tokens, 1, MAX_STAKING_TOKENS); _createProvision(users.indexer, subgraphDataServiceLegacyAddress, tokens, 0, 0); // Skip to over the max allocation epochs - vm.roll((MAX_ALLOCATION_EPOCHS + 1)* EPOCH_LENGTH + 1); + vm.roll((MAX_ALLOCATION_EPOCHS + 1) * EPOCH_LENGTH + 1); resetPrank(users.delegator); _closeAllocation(_allocationId, 0x0); } - function testCloseAllocation_RevertWhen_ZeroTokensNotAuthorized() public useIndexer useAllocation(1 ether){ + function testCloseAllocation_RevertWhen_ZeroTokensNotAuthorized() public useIndexer useAllocation(1 ether) { _createProvision(users.indexer, subgraphDataServiceLegacyAddress, 100 ether, 0, 0); resetPrank(users.delegator); @@ -91,7 +93,11 @@ contract HorizonStakingCloseAllocationTest is HorizonStakingTest { staking.closeAllocation(_allocationId, 0x0); } - function testCloseAllocation_WithDelegation(uint256 tokens, uint256 delegationTokens, uint32 indexingRewardCut) public useIndexer useAllocation(1 ether) { + function testCloseAllocation_WithDelegation( + uint256 tokens, + uint256 delegationTokens, + uint32 indexingRewardCut + ) public useIndexer useAllocation(1 ether) { tokens = bound(tokens, 2, MAX_STAKING_TOKENS); delegationTokens = bound(delegationTokens, 0, MAX_STAKING_TOKENS); vm.assume(indexingRewardCut <= MAX_PPM); @@ -107,4 +113,4 @@ contract HorizonStakingCloseAllocationTest is HorizonStakingTest { _closeAllocation(_allocationId, _poi); } -} \ No newline at end of file +} diff --git a/packages/horizon/test/staking/allocation/collect.t.sol b/packages/horizon/test/staking/allocation/collect.t.sol index 9b8b1d9e5..6b0c6cfcd 100644 --- a/packages/horizon/test/staking/allocation/collect.t.sol +++ b/packages/horizon/test/staking/allocation/collect.t.sol @@ -14,7 +14,9 @@ contract HorizonStakingCollectAllocationTest is HorizonStakingTest { * TESTS */ - function testCollectAllocation_RevertWhen_InvalidAllocationId(uint256 tokens) public useIndexer useAllocation(1 ether) { + function testCollectAllocation_RevertWhen_InvalidAllocationId( + uint256 tokens + ) public useIndexer useAllocation(1 ether) { vm.expectRevert("!alloc"); staking.collect(tokens, address(0)); } diff --git a/packages/horizon/test/staking/delegation/addToPool.t.sol b/packages/horizon/test/staking/delegation/addToPool.t.sol index 2bd73f28f..7652478e2 100644 --- a/packages/horizon/test/staking/delegation/addToPool.t.sol +++ b/packages/horizon/test/staking/delegation/addToPool.t.sol @@ -7,7 +7,6 @@ import { IHorizonStakingMain } from "../../../contracts/interfaces/internal/IHor import { HorizonStakingTest } from "../HorizonStaking.t.sol"; contract HorizonStakingDelegationAddToPoolTest is HorizonStakingTest { - modifier useValidDelegationAmount(uint256 tokens) { vm.assume(tokens <= MAX_STAKING_TOKENS); vm.assume(tokens >= MIN_DELEGATION); @@ -28,7 +27,13 @@ contract HorizonStakingDelegationAddToPoolTest is HorizonStakingTest { uint256 amount, uint256 delegationAmount, uint256 addToPoolAmount - ) public useIndexer useProvision(amount, 0, 0) useValidDelegationAmount(delegationAmount) useValidAddToPoolAmount(addToPoolAmount) { + ) + public + useIndexer + useProvision(amount, 0, 0) + useValidDelegationAmount(delegationAmount) + useValidAddToPoolAmount(addToPoolAmount) + { delegationAmount = bound(delegationAmount, 1, MAX_STAKING_TOKENS); // Initialize delegation pool @@ -44,11 +49,17 @@ contract HorizonStakingDelegationAddToPoolTest is HorizonStakingTest { function test_Delegation_AddToPool_Payments( uint256 amount, uint256 delegationAmount - ) public useIndexer useProvision(amount, 0, 0) useValidDelegationAmount(delegationAmount) useValidAddToPoolAmount(delegationAmount) { + ) + public + useIndexer + useProvision(amount, 0, 0) + useValidDelegationAmount(delegationAmount) + useValidAddToPoolAmount(delegationAmount) + { // Initialize delegation pool resetPrank(users.delegator); _delegate(users.indexer, subgraphDataServiceAddress, delegationAmount, 0); - + resetPrank(address(payments)); mint(address(payments), delegationAmount); token.approve(address(staking), delegationAmount); @@ -59,7 +70,9 @@ contract HorizonStakingDelegationAddToPoolTest is HorizonStakingTest { uint256 amount ) public useIndexer useProvision(amount, 0, 0) { vm.startPrank(subgraphDataServiceAddress); - bytes memory expectedError = abi.encodeWithSelector(IHorizonStakingMain.HorizonStakingInvalidZeroTokens.selector); + bytes memory expectedError = abi.encodeWithSelector( + IHorizonStakingMain.HorizonStakingInvalidZeroTokens.selector + ); vm.expectRevert(expectedError); staking.addToDelegationPool(users.indexer, subgraphDataServiceAddress, 0); } @@ -92,7 +105,7 @@ contract HorizonStakingDelegationAddToPoolTest is HorizonStakingTest { uint256 tokens, uint256 delegationTokens, uint256 recoverAmount - ) public useIndexer useProvision(tokens, 0, 0) useDelegationSlashing() { + ) public useIndexer useProvision(tokens, 0, 0) useDelegationSlashing { recoverAmount = bound(recoverAmount, 1, MAX_STAKING_TOKENS); delegationTokens = bound(delegationTokens, MIN_DELEGATION, MAX_STAKING_TOKENS); @@ -110,12 +123,11 @@ contract HorizonStakingDelegationAddToPoolTest is HorizonStakingTest { _addToDelegationPool(users.indexer, subgraphDataServiceAddress, recoverAmount); } - function test_Delegation_AddToPool_WhenInvalidPool_RevertWhen_PoolHasNoShares( uint256 tokens, uint256 delegationTokens, uint256 recoverAmount - ) public useIndexer useProvision(tokens, 0, 0) useDelegationSlashing() { + ) public useIndexer useProvision(tokens, 0, 0) useDelegationSlashing { recoverAmount = bound(recoverAmount, 1, MAX_STAKING_TOKENS); delegationTokens = bound(delegationTokens, MIN_DELEGATION, MAX_STAKING_TOKENS); @@ -146,4 +158,4 @@ contract HorizonStakingDelegationAddToPoolTest is HorizonStakingTest { vm.expectRevert(expectedError); staking.addToDelegationPool(users.indexer, subgraphDataServiceAddress, 1); } -} \ No newline at end of file +} diff --git a/packages/horizon/test/staking/delegation/legacyWithdraw.t.sol b/packages/horizon/test/staking/delegation/legacyWithdraw.t.sol index c90fa1200..0e1e353fe 100644 --- a/packages/horizon/test/staking/delegation/legacyWithdraw.t.sol +++ b/packages/horizon/test/staking/delegation/legacyWithdraw.t.sol @@ -49,7 +49,10 @@ contract HorizonStakingLegacyWithdrawDelegationTest is HorizonStakingTest { function _legacyWithdrawDelegated(address _indexer) internal { (, address delegator, ) = vm.readCallers(); - IHorizonStakingTypes.DelegationPool memory pool = staking.getDelegationPool(_indexer, subgraphDataServiceLegacyAddress); + IHorizonStakingTypes.DelegationPool memory pool = staking.getDelegationPool( + _indexer, + subgraphDataServiceLegacyAddress + ); uint256 beforeStakingBalance = token.balanceOf(address(staking)); uint256 beforeDelegatorBalance = token.balanceOf(users.delegator); diff --git a/packages/horizon/test/staking/delegation/redelegate.t.sol b/packages/horizon/test/staking/delegation/redelegate.t.sol index 6e30348c4..a4d9c8e03 100644 --- a/packages/horizon/test/staking/delegation/redelegate.t.sol +++ b/packages/horizon/test/staking/delegation/redelegate.t.sol @@ -8,12 +8,11 @@ import { IHorizonStakingMain } from "../../../contracts/interfaces/internal/IHor import { HorizonStakingTest } from "../HorizonStaking.t.sol"; contract HorizonStakingWithdrawDelegationTest is HorizonStakingTest { - /* * HELPERS */ - function _setupNewIndexer(uint256 tokens) private returns(address) { + function _setupNewIndexer(uint256 tokens) private returns (address) { (, address msgSender, ) = vm.readCallers(); address newIndexer = createUser("newIndexer"); @@ -23,9 +22,9 @@ contract HorizonStakingWithdrawDelegationTest is HorizonStakingTest { vm.startPrank(msgSender); return newIndexer; } - - function _setupNewIndexerAndVerifier(uint256 tokens) private returns(address, address) { - (, address msgSender,) = vm.readCallers(); + + function _setupNewIndexerAndVerifier(uint256 tokens) private returns (address, address) { + (, address msgSender, ) = vm.readCallers(); address newIndexer = createUser("newIndexer"); address newVerifier = makeAddr("newVerifier"); @@ -104,7 +103,9 @@ contract HorizonStakingWithdrawDelegationTest is HorizonStakingTest { // Setup new verifier address newVerifier = makeAddr("newVerifier"); - vm.expectRevert(abi.encodeWithSelector(IHorizonStakingMain.HorizonStakingInvalidServiceProviderZeroAddress.selector)); + vm.expectRevert( + abi.encodeWithSelector(IHorizonStakingMain.HorizonStakingInvalidServiceProviderZeroAddress.selector) + ); staking.redelegate(users.indexer, subgraphDataServiceAddress, address(0), newVerifier, 0, 0); } @@ -123,11 +124,11 @@ contract HorizonStakingWithdrawDelegationTest is HorizonStakingTest { uint256 previousBalance = token.balanceOf(users.delegator); _redelegate(users.indexer, subgraphDataServiceAddress, newIndexer, newVerifier, 0, 0); - + uint256 newBalance = token.balanceOf(users.delegator); assertEq(newBalance, previousBalance); uint256 delegatedTokens = staking.getDelegatedTokensAvailable(newIndexer, newVerifier); assertEq(delegatedTokens, 0); } -} \ No newline at end of file +} diff --git a/packages/horizon/test/staking/delegation/undelegate.t.sol b/packages/horizon/test/staking/delegation/undelegate.t.sol index af9e7b319..54ad91cff 100644 --- a/packages/horizon/test/staking/delegation/undelegate.t.sol +++ b/packages/horizon/test/staking/delegation/undelegate.t.sol @@ -48,12 +48,7 @@ contract HorizonStakingUndelegateTest is HorizonStakingTest { _undelegate(users.indexer, subgraphDataServiceAddress, undelegateAmount); } - delegation = _getStorage_Delegation( - users.indexer, - subgraphDataServiceAddress, - users.delegator, - false - ); + delegation = _getStorage_Delegation(users.indexer, subgraphDataServiceAddress, users.delegator, false); _undelegate(users.indexer, subgraphDataServiceAddress, delegation.shares); } @@ -150,7 +145,7 @@ contract HorizonStakingUndelegateTest is HorizonStakingTest { function testUndelegate_RevertWhen_InvalidPool( uint256 tokens, uint256 delegationTokens - ) public useIndexer useProvision(tokens, 0, 0) useDelegationSlashing() { + ) public useIndexer useProvision(tokens, 0, 0) useDelegationSlashing { delegationTokens = bound(delegationTokens, MIN_DELEGATION, MAX_STAKING_TOKENS); resetPrank(users.delegator); diff --git a/packages/horizon/test/staking/delegation/withdraw.t.sol b/packages/horizon/test/staking/delegation/withdraw.t.sol index 010f710a5..bbf7ecd1b 100644 --- a/packages/horizon/test/staking/delegation/withdraw.t.sol +++ b/packages/horizon/test/staking/delegation/withdraw.t.sol @@ -10,7 +10,6 @@ import { LinkedList } from "../../../contracts/libraries/LinkedList.sol"; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; contract HorizonStakingWithdrawDelegationTest is HorizonStakingTest { - /* * TESTS */ @@ -31,7 +30,10 @@ contract HorizonStakingWithdrawDelegationTest is HorizonStakingTest { subgraphDataServiceAddress, users.delegator ); - ThawRequest memory thawRequest = staking.getThawRequest(IHorizonStakingTypes.ThawRequestType.Delegation, thawingRequests.tail); + ThawRequest memory thawRequest = staking.getThawRequest( + IHorizonStakingTypes.ThawRequestType.Delegation, + thawingRequests.tail + ); skip(thawRequest.thawingUntil + 1); @@ -57,7 +59,7 @@ contract HorizonStakingWithdrawDelegationTest is HorizonStakingTest { { uint256 previousBalance = token.balanceOf(users.delegator); _withdrawDelegated(users.indexer, subgraphDataServiceAddress, 0); - + // Nothing changed since thawing period hasn't finished uint256 newBalance = token.balanceOf(users.delegator); assertEq(newBalance, previousBalance); @@ -83,7 +85,10 @@ contract HorizonStakingWithdrawDelegationTest is HorizonStakingTest { subgraphDataServiceLegacyAddress, users.delegator ); - ThawRequest memory thawRequest = staking.getThawRequest(IHorizonStakingTypes.ThawRequestType.Delegation, thawingRequests.tail); + ThawRequest memory thawRequest = staking.getThawRequest( + IHorizonStakingTypes.ThawRequestType.Delegation, + thawingRequests.tail + ); skip(thawRequest.thawingUntil + 1); @@ -93,7 +98,7 @@ contract HorizonStakingWithdrawDelegationTest is HorizonStakingTest { function testWithdrawDelegation_RevertWhen_InvalidPool( uint256 tokens, uint256 delegationTokens - ) public useIndexer useProvision(tokens, 0, MAX_THAWING_PERIOD) useDelegationSlashing() { + ) public useIndexer useProvision(tokens, 0, MAX_THAWING_PERIOD) useDelegationSlashing { delegationTokens = bound(delegationTokens, MIN_DELEGATION * 2, MAX_STAKING_TOKENS); resetPrank(users.delegator); @@ -115,15 +120,17 @@ contract HorizonStakingWithdrawDelegationTest is HorizonStakingTest { // fast forward in time and attempt to withdraw skip(MAX_THAWING_PERIOD + 1); resetPrank(users.delegator); - vm.expectRevert(abi.encodeWithSelector( - IHorizonStakingMain.HorizonStakingInvalidDelegationPoolState.selector, - users.indexer, - subgraphDataServiceAddress - )); + vm.expectRevert( + abi.encodeWithSelector( + IHorizonStakingMain.HorizonStakingInvalidDelegationPoolState.selector, + users.indexer, + subgraphDataServiceAddress + ) + ); staking.withdrawDelegated(users.indexer, subgraphDataServiceAddress, 0); } - function testWithdrawDelegation_AfterRecoveringPool( + function testWithdrawDelegation_AfterRecoveringPool( uint256 tokens ) public useIndexer useProvision(tokens, 0, MAX_THAWING_PERIOD) useDelegationSlashing { uint256 delegationTokens = MAX_STAKING_TOKENS / 10; diff --git a/packages/horizon/test/staking/governance/governance.t.sol b/packages/horizon/test/staking/governance/governance.t.sol index 434364a80..2fe4a46da 100644 --- a/packages/horizon/test/staking/governance/governance.t.sol +++ b/packages/horizon/test/staking/governance/governance.t.sol @@ -6,12 +6,11 @@ import "forge-std/Test.sol"; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; contract HorizonStakingGovernanceTest is HorizonStakingTest { - /* * MODIFIERS */ - modifier useGovernor { + modifier useGovernor() { vm.startPrank(users.governor); _; } @@ -43,7 +42,7 @@ contract HorizonStakingGovernanceTest is HorizonStakingTest { function testGovernance_ClearThawingPeriod(uint32 thawingPeriod) public useGovernor { // simulate previous thawing period _setStorage_DeprecatedThawingPeriod(thawingPeriod); - + _clearThawingPeriod(); } @@ -62,4 +61,4 @@ contract HorizonStakingGovernanceTest is HorizonStakingTest { vm.expectRevert(expectedError); staking.setMaxThawingPeriod(MAX_THAWING_PERIOD); } -} \ No newline at end of file +} diff --git a/packages/horizon/test/staking/operator/locked.t.sol b/packages/horizon/test/staking/operator/locked.t.sol index 3d9b5f1e6..0568e8cb3 100644 --- a/packages/horizon/test/staking/operator/locked.t.sol +++ b/packages/horizon/test/staking/operator/locked.t.sol @@ -6,7 +6,6 @@ import "forge-std/Test.sol"; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; contract HorizonStakingOperatorLockedTest is HorizonStakingTest { - /* * TESTS */ @@ -16,18 +15,29 @@ contract HorizonStakingOperatorLockedTest is HorizonStakingTest { } function testOperatorLocked_RevertWhen_VerifierNotAllowed() public useIndexer { - bytes memory expectedError = abi.encodeWithSignature("HorizonStakingVerifierNotAllowed(address)", subgraphDataServiceAddress); + bytes memory expectedError = abi.encodeWithSignature( + "HorizonStakingVerifierNotAllowed(address)", + subgraphDataServiceAddress + ); vm.expectRevert(expectedError); staking.setOperatorLocked(subgraphDataServiceAddress, users.operator, true); } - function testOperatorLocked_RevertWhen_CallerIsServiceProvider() public useIndexer useLockedVerifier(subgraphDataServiceAddress) { + function testOperatorLocked_RevertWhen_CallerIsServiceProvider() + public + useIndexer + useLockedVerifier(subgraphDataServiceAddress) + { bytes memory expectedError = abi.encodeWithSignature("HorizonStakingCallerIsServiceProvider()"); vm.expectRevert(expectedError); staking.setOperatorLocked(subgraphDataServiceAddress, users.indexer, true); } - function testOperatorLocked_SetLegacySubgraphService() public useIndexer useLockedVerifier(subgraphDataServiceLegacyAddress) { + function testOperatorLocked_SetLegacySubgraphService() + public + useIndexer + useLockedVerifier(subgraphDataServiceLegacyAddress) + { _setOperatorLocked(subgraphDataServiceLegacyAddress, users.operator, true); } -} \ No newline at end of file +} diff --git a/packages/horizon/test/staking/operator/operator.t.sol b/packages/horizon/test/staking/operator/operator.t.sol index a821e561d..664414047 100644 --- a/packages/horizon/test/staking/operator/operator.t.sol +++ b/packages/horizon/test/staking/operator/operator.t.sol @@ -6,7 +6,6 @@ import "forge-std/Test.sol"; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; contract HorizonStakingOperatorTest is HorizonStakingTest { - /* * TESTS */ @@ -25,4 +24,4 @@ contract HorizonStakingOperatorTest is HorizonStakingTest { _setOperator(subgraphDataServiceAddress, users.operator, true); _setOperator(subgraphDataServiceAddress, users.operator, false); } -} \ No newline at end of file +} diff --git a/packages/horizon/test/staking/provision/locked.t.sol b/packages/horizon/test/staking/provision/locked.t.sol index 2dcae964a..bc44a32f1 100644 --- a/packages/horizon/test/staking/provision/locked.t.sol +++ b/packages/horizon/test/staking/provision/locked.t.sol @@ -6,7 +6,6 @@ import "forge-std/Test.sol"; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; contract HorizonStakingProvisionLockedTest is HorizonStakingTest { - /* * TESTS */ @@ -20,13 +19,7 @@ contract HorizonStakingProvisionLockedTest is HorizonStakingTest { _setOperatorLocked(subgraphDataServiceAddress, users.operator, true); vm.startPrank(users.operator); - _provisionLocked( - users.indexer, - subgraphDataServiceAddress, - amount, - MAX_PPM, - MAX_THAWING_PERIOD - ); + _provisionLocked(users.indexer, subgraphDataServiceAddress, amount, MAX_PPM, MAX_THAWING_PERIOD); provisionTokens = staking.getProviderTokensAvailable(users.indexer, subgraphDataServiceAddress); assertEq(provisionTokens, amount); @@ -46,15 +39,12 @@ contract HorizonStakingProvisionLockedTest is HorizonStakingTest { _setAllowedLockedVerifier(subgraphDataServiceAddress, false); vm.startPrank(users.operator); - bytes memory expectedError = abi.encodeWithSignature("HorizonStakingVerifierNotAllowed(address)", subgraphDataServiceAddress); - vm.expectRevert(expectedError); - staking.provisionLocked( - users.indexer, - subgraphDataServiceAddress, - amount, - MAX_PPM, - MAX_THAWING_PERIOD + bytes memory expectedError = abi.encodeWithSignature( + "HorizonStakingVerifierNotAllowed(address)", + subgraphDataServiceAddress ); + vm.expectRevert(expectedError); + staking.provisionLocked(users.indexer, subgraphDataServiceAddress, amount, MAX_PPM, MAX_THAWING_PERIOD); } function testProvisionLocked_RevertWhen_OperatorNotAllowed( @@ -71,12 +61,6 @@ contract HorizonStakingProvisionLockedTest is HorizonStakingTest { users.operator ); vm.expectRevert(expectedError); - staking.provisionLocked( - users.indexer, - subgraphDataServiceAddress, - amount, - MAX_PPM, - MAX_THAWING_PERIOD - ); + staking.provisionLocked(users.indexer, subgraphDataServiceAddress, amount, MAX_PPM, MAX_THAWING_PERIOD); } -} \ No newline at end of file +} diff --git a/packages/horizon/test/staking/provision/parameters.t.sol b/packages/horizon/test/staking/provision/parameters.t.sol index 377684630..f132a73b6 100644 --- a/packages/horizon/test/staking/provision/parameters.t.sol +++ b/packages/horizon/test/staking/provision/parameters.t.sol @@ -7,7 +7,6 @@ import { HorizonStakingTest } from "../HorizonStaking.t.sol"; import { IHorizonStakingMain } from "../../../contracts/interfaces/internal/IHorizonStakingMain.sol"; contract HorizonStakingProvisionParametersTest is HorizonStakingTest { - /* * MODIFIERS */ @@ -91,10 +90,7 @@ contract HorizonStakingProvisionParametersTest is HorizonStakingTest { maxVerifierCut = uint32(bound(maxVerifierCut, MAX_PPM + 1, type(uint32).max)); vm.assume(thawingPeriod <= MAX_THAWING_PERIOD); vm.expectRevert( - abi.encodeWithSelector( - IHorizonStakingMain.HorizonStakingInvalidMaxVerifierCut.selector, - maxVerifierCut - ) + abi.encodeWithSelector(IHorizonStakingMain.HorizonStakingInvalidMaxVerifierCut.selector, maxVerifierCut) ); staking.setProvisionParameters(users.indexer, subgraphDataServiceAddress, maxVerifierCut, thawingPeriod); } diff --git a/packages/horizon/test/staking/provision/thaw.t.sol b/packages/horizon/test/staking/provision/thaw.t.sol index eb58e8e86..a16dd7253 100644 --- a/packages/horizon/test/staking/provision/thaw.t.sol +++ b/packages/horizon/test/staking/provision/thaw.t.sol @@ -94,7 +94,7 @@ contract HorizonStakingThawTest is HorizonStakingTest { staking.thaw(users.indexer, subgraphDataServiceAddress, thawAmount); } - function testThaw_RevertWhen_ProvisionFullySlashed ( + function testThaw_RevertWhen_ProvisionFullySlashed( uint256 amount, uint64 thawingPeriod, uint256 thawAmount @@ -107,7 +107,11 @@ contract HorizonStakingThawTest is HorizonStakingTest { // Attempt to thaw on a provision that has been fully slashed resetPrank(users.indexer); - bytes memory expectedError = abi.encodeWithSignature("HorizonStakingInsufficientTokens(uint256,uint256)", 0, thawAmount); + bytes memory expectedError = abi.encodeWithSignature( + "HorizonStakingInsufficientTokens(uint256,uint256)", + 0, + thawAmount + ); vm.expectRevert(expectedError); staking.thaw(users.indexer, subgraphDataServiceAddress, thawAmount); } diff --git a/packages/horizon/test/staking/serviceProvider/serviceProvider.t.sol b/packages/horizon/test/staking/serviceProvider/serviceProvider.t.sol index 9f4893942..6c5fe4904 100644 --- a/packages/horizon/test/staking/serviceProvider/serviceProvider.t.sol +++ b/packages/horizon/test/staking/serviceProvider/serviceProvider.t.sol @@ -9,7 +9,6 @@ import { IGraphPayments } from "../../../contracts/interfaces/IGraphPayments.sol import { HorizonStakingTest } from "../HorizonStaking.t.sol"; contract HorizonStakingServiceProviderTest is HorizonStakingTest { - /* * TESTS */ @@ -33,10 +32,7 @@ contract HorizonStakingServiceProviderTest is HorizonStakingTest { assertEq(sp.tokensProvisioned, amount); } - function testServiceProvider_SetDelegationFeeCut( - uint256 feeCut, - uint8 paymentTypeInput - ) public useIndexer { + function testServiceProvider_SetDelegationFeeCut(uint256 feeCut, uint8 paymentTypeInput) public useIndexer { vm.assume(paymentTypeInput < 3); IGraphPayments.PaymentTypes paymentType = IGraphPayments.PaymentTypes(paymentTypeInput); feeCut = bound(feeCut, 0, MAX_PPM); @@ -85,7 +81,11 @@ contract HorizonStakingServiceProviderTest is HorizonStakingTest { uint256 delegationAmount, uint32 delegationRatio ) public useIndexer useProvision(amount, MAX_PPM, MAX_THAWING_PERIOD) useDelegation(delegationAmount) { - uint256 tokensAvailable = staking.getTokensAvailable(users.indexer, subgraphDataServiceAddress, delegationRatio); + uint256 tokensAvailable = staking.getTokensAvailable( + users.indexer, + subgraphDataServiceAddress, + delegationRatio + ); uint256 tokensDelegatedMax = amount * (uint256(delegationRatio)); uint256 tokensDelegatedCapacity = delegationAmount > tokensDelegatedMax ? tokensDelegatedMax : delegationAmount; @@ -139,10 +139,9 @@ contract HorizonStakingServiceProviderTest is HorizonStakingTest { vm.assume(paymentTypeInput < 3); IGraphPayments.PaymentTypes paymentType = IGraphPayments.PaymentTypes(paymentTypeInput); cut = bound(cut, MAX_PPM + 1, MAX_PPM + 100); - vm.expectRevert(abi.encodeWithSelector( - IHorizonStakingMain.HorizonStakingInvalidDelegationFeeCut.selector, - cut - )); + vm.expectRevert( + abi.encodeWithSelector(IHorizonStakingMain.HorizonStakingInvalidDelegationFeeCut.selector, cut) + ); staking.setDelegationFeeCut(users.indexer, subgraphDataServiceAddress, paymentType, cut); } -} \ No newline at end of file +} diff --git a/packages/horizon/test/staking/slash/legacySlash.t.sol b/packages/horizon/test/staking/slash/legacySlash.t.sol index f5595fdac..5ff8edb00 100644 --- a/packages/horizon/test/staking/slash/legacySlash.t.sol +++ b/packages/horizon/test/staking/slash/legacySlash.t.sol @@ -8,7 +8,6 @@ import { IHorizonStakingExtension } from "../../../contracts/interfaces/internal import { HorizonStakingTest } from "../HorizonStaking.t.sol"; contract HorizonStakingLegacySlashTest is HorizonStakingTest { - /* * MODIFIERS */ @@ -74,7 +73,7 @@ contract HorizonStakingLegacySlashTest is HorizonStakingTest { reward = bound(reward, 0, slashTokens); _createProvision(users.indexer, subgraphDataServiceLegacyAddress, tokens, 0, 0); - + resetPrank(users.legacySlasher); _legacySlash(users.indexer, slashTokens, reward, makeAddr("fisherman")); } @@ -120,7 +119,7 @@ contract HorizonStakingLegacySlashTest is HorizonStakingTest { ) public useIndexer { vm.assume(tokens > 0); _createProvision(users.indexer, subgraphDataServiceLegacyAddress, tokens, 0, 0); - + vm.expectRevert("!slasher"); staking.legacySlash(users.indexer, slashTokens, reward, makeAddr("fisherman")); } @@ -135,7 +134,7 @@ contract HorizonStakingLegacySlashTest is HorizonStakingTest { vm.assume(reward > slashTokens); _createProvision(users.indexer, subgraphDataServiceLegacyAddress, tokens, 0, 0); - + resetPrank(users.legacySlasher); vm.expectRevert("rewards>slash"); staking.legacySlash(users.indexer, slashTokens, reward, makeAddr("fisherman")); @@ -159,7 +158,7 @@ contract HorizonStakingLegacySlashTest is HorizonStakingTest { vm.assume(tokens > 0); _createProvision(users.indexer, subgraphDataServiceLegacyAddress, tokens, 0, 0); - + resetPrank(users.legacySlasher); vm.expectRevert("!tokens"); staking.legacySlash(users.indexer, 0, 0, makeAddr("fisherman")); @@ -175,7 +174,7 @@ contract HorizonStakingLegacySlashTest is HorizonStakingTest { reward = bound(reward, 0, slashTokens); _createProvision(users.indexer, subgraphDataServiceLegacyAddress, tokens, 0, 0); - + resetPrank(users.legacySlasher); vm.expectRevert("!beneficiary"); staking.legacySlash(users.indexer, slashTokens, reward, address(0)); @@ -193,10 +192,10 @@ contract HorizonStakingLegacySlashTest is HorizonStakingTest { // This means tokensUsed (1100 GRT) > tokensStaked (1000 GRT) _setIndexer( users.indexer, - 1000 ether, // tokensStaked - 800 ether, // tokensAllocated - 300 ether, // tokensLocked - 0 // tokensLockedUntil + 1000 ether, // tokensStaked + 800 ether, // tokensAllocated + 300 ether, // tokensLocked + 0 // tokensLockedUntil ); // Send tokens manually to staking diff --git a/packages/horizon/test/staking/slash/slash.t.sol b/packages/horizon/test/staking/slash/slash.t.sol index fc5676b0f..3f67a9e59 100644 --- a/packages/horizon/test/staking/slash/slash.t.sol +++ b/packages/horizon/test/staking/slash/slash.t.sol @@ -70,7 +70,7 @@ contract HorizonStakingSlashTest is HorizonStakingTest { uint256 slashTokens, uint256 verifierCutAmount, uint256 delegationTokens - ) public useIndexer useProvision(tokens, MAX_PPM, 0) useDelegationSlashing() { + ) public useIndexer useProvision(tokens, MAX_PPM, 0) useDelegationSlashing { delegationTokens = bound(delegationTokens, MIN_DELEGATION, MAX_STAKING_TOKENS); slashTokens = bound(slashTokens, tokens + 1, tokens + 1 + delegationTokens); verifierCutAmount = bound(verifierCutAmount, 0, tokens); diff --git a/packages/horizon/test/staking/stake/stake.t.sol b/packages/horizon/test/staking/stake/stake.t.sol index 55474245c..bf62de8b7 100644 --- a/packages/horizon/test/staking/stake/stake.t.sol +++ b/packages/horizon/test/staking/stake/stake.t.sol @@ -6,7 +6,6 @@ import "forge-std/Test.sol"; import { HorizonStakingTest } from "../HorizonStaking.t.sol"; contract HorizonStakingStakeTest is HorizonStakingTest { - /* * TESTS */ @@ -32,4 +31,4 @@ contract HorizonStakingStakeTest is HorizonStakingTest { vm.expectRevert(expectedError); staking.stakeTo(users.indexer, 0); } -} \ No newline at end of file +} diff --git a/packages/horizon/test/utils/Constants.sol b/packages/horizon/test/utils/Constants.sol index df7e78e6d..0aa53700d 100644 --- a/packages/horizon/test/utils/Constants.sol +++ b/packages/horizon/test/utils/Constants.sol @@ -20,4 +20,4 @@ abstract contract Constants { uint256 internal constant ALLOCATIONS_REWARD_CUT = 100 ether; // GraphTallyCollector uint256 internal constant revokeSignerThawingPeriod = 7 days; -} \ No newline at end of file +} diff --git a/packages/horizon/test/utils/Users.sol b/packages/horizon/test/utils/Users.sol index ecd3927ab..6213e4e82 100644 --- a/packages/horizon/test/utils/Users.sol +++ b/packages/horizon/test/utils/Users.sol @@ -10,4 +10,4 @@ struct Users { address verifier; address delegator; address legacySlasher; -} \ No newline at end of file +} diff --git a/packages/horizon/test/utils/Utils.sol b/packages/horizon/test/utils/Utils.sol index 5aae4de3f..be42f269f 100644 --- a/packages/horizon/test/utils/Utils.sol +++ b/packages/horizon/test/utils/Utils.sol @@ -9,4 +9,4 @@ abstract contract Utils is Test { vm.stopPrank(); vm.startPrank(msgSender); } -} \ No newline at end of file +} diff --git a/packages/subgraph-service/package.json b/packages/subgraph-service/package.json index d021abf7e..ade35a093 100644 --- a/packages/subgraph-service/package.json +++ b/packages/subgraph-service/package.json @@ -12,7 +12,7 @@ ], "scripts": { "lint:ts": "eslint '**/*.{js,ts}' --fix", - "lint:sol": "prettier --write contracts/**/*.sol && solhint --noPrompt --fix contracts/**/*.sol --config node_modules/solhint-graph-config/index.js", + "lint:sol": "prettier --write contracts/**/*.sol test/**/*.sol && solhint --noPrompt --fix contracts/**/*.sol --config node_modules/solhint-graph-config/index.js", "lint": "yarn lint:ts && yarn lint:sol", "clean": "rm -rf build dist cache cache_forge typechain-types", "build": "forge build --skip test && BUILD_RUN=true hardhat compile", diff --git a/packages/subgraph-service/test/SubgraphBaseTest.t.sol b/packages/subgraph-service/test/SubgraphBaseTest.t.sol index 176129ec2..7742e6696 100644 --- a/packages/subgraph-service/test/SubgraphBaseTest.t.sol +++ b/packages/subgraph-service/test/SubgraphBaseTest.t.sol @@ -29,7 +29,6 @@ import { MockRewardsManager } from "./mocks/MockRewardsManager.sol"; import { MockEpochManager } from "./mocks/MockEpochManager.sol"; abstract contract SubgraphBaseTest is Utils, Constants { - /* * VARIABLES */ @@ -89,7 +88,7 @@ abstract contract SubgraphBaseTest is Utils, Constants { resetPrank(users.governor); proxyAdmin = new GraphProxyAdmin(); controller = new Controller(); - + resetPrank(users.deployer); GraphProxy stakingProxy = new GraphProxy(address(0), address(proxyAdmin)); rewardsManager = new MockRewardsManager(token, rewardsPerSignal, rewardsPerSubgraphAllocationUpdate); @@ -98,30 +97,27 @@ abstract contract SubgraphBaseTest is Utils, Constants { // GraphPayments predict address bytes32 saltGraphPayments = keccak256("GraphPaymentsSalt"); - bytes32 paymentsHash = keccak256(bytes.concat( - vm.getCode("GraphPayments.sol:GraphPayments"), - abi.encode(address(controller), protocolPaymentCut) - )); + bytes32 paymentsHash = keccak256( + bytes.concat( + vm.getCode("GraphPayments.sol:GraphPayments"), + abi.encode(address(controller), protocolPaymentCut) + ) + ); address predictedGraphPaymentsAddress = vm.computeCreate2Address( saltGraphPayments, paymentsHash, users.deployer ); - + // GraphEscrow predict address bytes32 saltEscrow = keccak256("GraphEscrowSalt"); - bytes32 escrowHash = keccak256(bytes.concat( - vm.getCode("PaymentsEscrow.sol:PaymentsEscrow"), - abi.encode( - address(controller), - withdrawEscrowThawingPeriod + bytes32 escrowHash = keccak256( + bytes.concat( + vm.getCode("PaymentsEscrow.sol:PaymentsEscrow"), + abi.encode(address(controller), withdrawEscrowThawingPeriod) ) - )); - address predictedEscrowAddress = vm.computeCreate2Address( - saltEscrow, - escrowHash, - users.deployer ); + address predictedEscrowAddress = vm.computeCreate2Address(saltEscrow, escrowHash, users.deployer); resetPrank(users.governor); controller.setContractProxy(keccak256("GraphToken"), address(token)); @@ -147,9 +143,19 @@ abstract contract SubgraphBaseTest is Utils, Constants { disputeManager = DisputeManager(disputeManagerProxy); disputeManager.transferOwnership(users.governor); - graphTallyCollector = new GraphTallyCollector("GraphTallyCollector", "1", address(controller), revokeSignerThawingPeriod); + graphTallyCollector = new GraphTallyCollector( + "GraphTallyCollector", + "1", + address(controller), + revokeSignerThawingPeriod + ); address subgraphServiceImplementation = address( - new SubgraphService(address(controller), address(disputeManager), address(graphTallyCollector), address(curation)) + new SubgraphService( + address(controller), + address(disputeManager), + address(graphTallyCollector), + address(curation) + ) ); address subgraphServiceProxy = UnsafeUpgrades.deployTransparentProxy( subgraphServiceImplementation, @@ -158,24 +164,11 @@ abstract contract SubgraphBaseTest is Utils, Constants { ); subgraphService = SubgraphService(subgraphServiceProxy); - stakingExtension = new HorizonStakingExtension( - address(controller), - address(subgraphService) - ); - stakingBase = new HorizonStaking( - address(controller), - address(stakingExtension), - address(subgraphService) - ); + stakingExtension = new HorizonStakingExtension(address(controller), address(subgraphService)); + stakingBase = new HorizonStaking(address(controller), address(stakingExtension), address(subgraphService)); - graphPayments = new GraphPayments{salt: saltGraphPayments}( - address(controller), - protocolPaymentCut - ); - escrow = new PaymentsEscrow{salt: saltEscrow}( - address(controller), - withdrawEscrowThawingPeriod - ); + graphPayments = new GraphPayments{ salt: saltGraphPayments }(address(controller), protocolPaymentCut); + escrow = new PaymentsEscrow{ salt: saltEscrow }(address(controller), withdrawEscrowThawingPeriod); resetPrank(users.governor); disputeManager.setSubgraphService(address(subgraphService)); @@ -215,4 +208,4 @@ abstract contract SubgraphBaseTest is Utils, Constants { function burn(address _from, uint256 amount) internal { token.burnFrom(_from, amount); } -} \ No newline at end of file +} diff --git a/packages/subgraph-service/test/disputeManager/DisputeManager.t.sol b/packages/subgraph-service/test/disputeManager/DisputeManager.t.sol index 0349fe7da..cfd5882b9 100644 --- a/packages/subgraph-service/test/disputeManager/DisputeManager.t.sol +++ b/packages/subgraph-service/test/disputeManager/DisputeManager.t.sol @@ -344,9 +344,7 @@ contract DisputeManagerTest is SubgraphServiceSharedTest { disputeManager.acceptDispute(_disputeId, _tokensSlash); // Check fisherman's got their reward and their deposit (if any) back - uint256 fishermanExpectedBalance = fishermanPreviousBalance + - fishermanReward + - disputeDeposit; + uint256 fishermanExpectedBalance = fishermanPreviousBalance + fishermanReward + disputeDeposit; assertEq( token.balanceOf(fisherman), fishermanExpectedBalance, @@ -387,11 +385,19 @@ contract DisputeManagerTest is SubgraphServiceSharedTest { uint256 expectedBalance; } - function _acceptDisputeConflict(bytes32 _disputeId, uint256 _tokensSlash, bool _acceptRelatedDispute, uint256 _tokensRelatedSlash) internal { + function _acceptDisputeConflict( + bytes32 _disputeId, + uint256 _tokensSlash, + bool _acceptRelatedDispute, + uint256 _tokensRelatedSlash + ) internal { IDisputeManager.Dispute memory dispute = _getDispute(_disputeId); IDisputeManager.Dispute memory relatedDispute = _getDispute(dispute.relatedDisputeId); uint256 indexerTokensAvailable = staking.getProviderTokensAvailable(dispute.indexer, address(subgraphService)); - uint256 relatedIndexerTokensAvailable = staking.getProviderTokensAvailable(relatedDispute.indexer, address(subgraphService)); + uint256 relatedIndexerTokensAvailable = staking.getProviderTokensAvailable( + relatedDispute.indexer, + address(subgraphService) + ); FishermanParams memory params; params.fisherman = dispute.fisherman; @@ -431,7 +437,8 @@ contract DisputeManagerTest is SubgraphServiceSharedTest { disputeManager.acceptDisputeConflict(_disputeId, _tokensSlash, _acceptRelatedDispute, _tokensRelatedSlash); // Check fisherman's got their reward and their deposit back - params.expectedBalance = params.previousBalance + + params.expectedBalance = + params.previousBalance + params.totalReward + params.disputeDeposit + params.relatedDisputeDeposit; @@ -486,7 +493,6 @@ contract DisputeManagerTest is SubgraphServiceSharedTest { } } - // Check dispute status dispute = _getDispute(_disputeId); assertEq( @@ -500,8 +506,8 @@ contract DisputeManagerTest is SubgraphServiceSharedTest { assertEq( uint8(relatedDispute.status), _acceptRelatedDispute - ? uint8(IDisputeManager.DisputeStatus.Accepted) - : uint8(IDisputeManager.DisputeStatus.Drawn), + ? uint8(IDisputeManager.DisputeStatus.Accepted) + : uint8(IDisputeManager.DisputeStatus.Drawn), "Related dispute status should be drawn" ); } diff --git a/packages/subgraph-service/test/disputeManager/constructor/constructor.t.sol b/packages/subgraph-service/test/disputeManager/constructor/constructor.t.sol index c9166719f..2261c9284 100644 --- a/packages/subgraph-service/test/disputeManager/constructor/constructor.t.sol +++ b/packages/subgraph-service/test/disputeManager/constructor/constructor.t.sol @@ -35,14 +35,15 @@ contract DisputeManagerConstructorTest is DisputeManagerTest { uint32 fishermanRewardPercentage, uint32 maxSlashingPercentage ) private returns (address) { - return UnsafeUpgrades.deployTransparentProxy( - implementation, - users.governor, - abi.encodeCall( - DisputeManager.initialize, - (arbitrator, disputePeriod, disputeDeposit, fishermanRewardPercentage, maxSlashingPercentage) - ) - ); + return + UnsafeUpgrades.deployTransparentProxy( + implementation, + users.governor, + abi.encodeCall( + DisputeManager.initialize, + (arbitrator, disputePeriod, disputeDeposit, fishermanRewardPercentage, maxSlashingPercentage) + ) + ); } /* @@ -83,9 +84,7 @@ contract DisputeManagerConstructorTest is DisputeManagerTest { function test_DisputeManager_Constructor_RevertIf_ArbitratorAddressIsZero() public useDeployer { address disputeManagerImplementation = address(new DisputeManager(address(controller))); - bytes memory expectedError = abi.encodeWithSelector( - IDisputeManager.DisputeManagerInvalidZeroAddress.selector - ); + bytes memory expectedError = abi.encodeWithSelector(IDisputeManager.DisputeManagerInvalidZeroAddress.selector); vm.expectRevert(expectedError); _initializeDisputeManager( disputeManagerImplementation, @@ -99,9 +98,7 @@ contract DisputeManagerConstructorTest is DisputeManagerTest { function test_DisputeManager_Constructor_RevertIf_InvalidDisputePeriod() public useDeployer { address disputeManagerImplementation = address(new DisputeManager(address(controller))); - bytes memory expectedError = abi.encodeWithSelector( - IDisputeManager.DisputeManagerDisputePeriodZero.selector - ); + bytes memory expectedError = abi.encodeWithSelector(IDisputeManager.DisputeManagerDisputePeriodZero.selector); vm.expectRevert(expectedError); _initializeDisputeManager( disputeManagerImplementation, @@ -130,7 +127,9 @@ contract DisputeManagerConstructorTest is DisputeManagerTest { ); } - function test_DisputeManager_Constructor_RevertIf_InvalidFishermanRewardPercentage(uint32 _fishermanRewardPercentage) public useDeployer { + function test_DisputeManager_Constructor_RevertIf_InvalidFishermanRewardPercentage( + uint32 _fishermanRewardPercentage + ) public useDeployer { vm.assume(_fishermanRewardPercentage > disputeManager.MAX_FISHERMAN_REWARD_CUT()); address disputeManagerImplementation = address(new DisputeManager(address(controller))); bytes memory expectedError = abi.encodeWithSelector( @@ -148,7 +147,9 @@ contract DisputeManagerConstructorTest is DisputeManagerTest { ); } - function test_DisputeManager_Constructor_RevertIf_InvalidMaxSlashingPercentage(uint32 _maxSlashingPercentage) public useDeployer { + function test_DisputeManager_Constructor_RevertIf_InvalidMaxSlashingPercentage( + uint32 _maxSlashingPercentage + ) public useDeployer { vm.assume(_maxSlashingPercentage > PPMMath.MAX_PPM); address disputeManagerImplementation = address(new DisputeManager(address(controller))); bytes memory expectedError = abi.encodeWithSelector( diff --git a/packages/subgraph-service/test/disputeManager/disputes/disputes.t.sol b/packages/subgraph-service/test/disputeManager/disputes/disputes.t.sol index b6b4a6890..efcf49bc4 100644 --- a/packages/subgraph-service/test/disputeManager/disputes/disputes.t.sol +++ b/packages/subgraph-service/test/disputeManager/disputes/disputes.t.sol @@ -23,49 +23,36 @@ contract DisputeManagerDisputeTest is DisputeManagerTest { bytes32 disputeID = bytes32("0x0"); resetPrank(users.arbitrator); - vm.expectRevert(abi.encodeWithSelector( - IDisputeManager.DisputeManagerInvalidDispute.selector, - disputeID - )); + vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerInvalidDispute.selector, disputeID)); disputeManager.acceptDispute(disputeID, tokensSlash); } - function test_Dispute_Accept_RevertIf_SlashZeroTokens( - uint256 tokens - ) public useIndexer useAllocation(tokens) { + function test_Dispute_Accept_RevertIf_SlashZeroTokens(uint256 tokens) public useIndexer useAllocation(tokens) { resetPrank(users.fisherman); - bytes32 disputeID =_createIndexingDispute(allocationID, bytes32("POI101")); + bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI101")); // attempt to accept dispute with 0 tokens slashed resetPrank(users.arbitrator); uint256 maxTokensToSlash = uint256(maxSlashingPercentage).mulPPM(tokens); - vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerInvalidTokensSlash.selector, 0, maxTokensToSlash)); + vm.expectRevert( + abi.encodeWithSelector(IDisputeManager.DisputeManagerInvalidTokensSlash.selector, 0, maxTokensToSlash) + ); disputeManager.acceptDispute(disputeID, 0); } - function test_Dispute_Reject_RevertIf_DisputeDoesNotExist( - uint256 tokens - ) public useIndexer useAllocation(tokens) { + function test_Dispute_Reject_RevertIf_DisputeDoesNotExist(uint256 tokens) public useIndexer useAllocation(tokens) { bytes32 disputeID = bytes32("0x0"); resetPrank(users.arbitrator); - vm.expectRevert(abi.encodeWithSelector( - IDisputeManager.DisputeManagerInvalidDispute.selector, - disputeID - )); + vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerInvalidDispute.selector, disputeID)); disputeManager.rejectDispute(disputeID); } - function test_Dispute_Draw_RevertIf_DisputeDoesNotExist( - uint256 tokens - ) public useIndexer useAllocation(tokens) { + function test_Dispute_Draw_RevertIf_DisputeDoesNotExist(uint256 tokens) public useIndexer useAllocation(tokens) { bytes32 disputeID = bytes32("0x0"); resetPrank(users.arbitrator); - vm.expectRevert(abi.encodeWithSelector( - IDisputeManager.DisputeManagerInvalidDispute.selector, - disputeID - )); + vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerInvalidDispute.selector, disputeID)); disputeManager.drawDispute(disputeID); } } diff --git a/packages/subgraph-service/test/disputeManager/disputes/indexing/accept.t.sol b/packages/subgraph-service/test/disputeManager/disputes/indexing/accept.t.sol index f1d1dc24f..901508bda 100644 --- a/packages/subgraph-service/test/disputeManager/disputes/indexing/accept.t.sol +++ b/packages/subgraph-service/test/disputeManager/disputes/indexing/accept.t.sol @@ -14,15 +14,12 @@ contract DisputeManagerIndexingAcceptDisputeTest is DisputeManagerTest { * TESTS */ - function test_Indexing_Accept_Dispute( - uint256 tokens, - uint256 tokensSlash - ) public useIndexer useAllocation(tokens) { + function test_Indexing_Accept_Dispute(uint256 tokens, uint256 tokensSlash) public useIndexer useAllocation(tokens) { tokensSlash = bound(tokensSlash, 1, uint256(maxSlashingPercentage).mulPPM(tokens)); resetPrank(users.fisherman); bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1")); - + resetPrank(users.arbitrator); _acceptDispute(disputeID, tokensSlash); } @@ -35,7 +32,7 @@ contract DisputeManagerIndexingAcceptDisputeTest is DisputeManagerTest { resetPrank(users.fisherman); bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1")); - + resetPrank(users.arbitrator); // clear subgraph service address from storage _setStorage_SubgraphService(address(0)); @@ -52,7 +49,7 @@ contract DisputeManagerIndexingAcceptDisputeTest is DisputeManagerTest { resetPrank(users.fisherman); bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1")); - + resetPrank(users.arbitrator); _acceptDispute(disputeID, tokensSlash); } @@ -84,7 +81,7 @@ contract DisputeManagerIndexingAcceptDisputeTest is DisputeManagerTest { resetPrank(users.arbitrator); uint256 maxTokensToSlash = uint256(maxSlashingPercentage).mulPPM(tokens); bytes memory expectedError = abi.encodeWithSelector( - IDisputeManager.DisputeManagerInvalidTokensSlash.selector, + IDisputeManager.DisputeManagerInvalidTokensSlash.selector, tokensSlash, maxTokensToSlash ); diff --git a/packages/subgraph-service/test/disputeManager/disputes/indexing/cancel.t.sol b/packages/subgraph-service/test/disputeManager/disputes/indexing/cancel.t.sol index 1639f2cad..e2aaaa541 100644 --- a/packages/subgraph-service/test/disputeManager/disputes/indexing/cancel.t.sol +++ b/packages/subgraph-service/test/disputeManager/disputes/indexing/cancel.t.sol @@ -7,14 +7,13 @@ import { IDisputeManager } from "../../../../contracts/interfaces/IDisputeManage import { DisputeManagerTest } from "../../DisputeManager.t.sol"; contract DisputeManagerIndexingCancelDisputeTest is DisputeManagerTest { - /* * TESTS */ function test_Indexing_Cancel_Dispute(uint256 tokens) public useIndexer useAllocation(tokens) { resetPrank(users.fisherman); - bytes32 disputeID =_createIndexingDispute(allocationID, bytes32("POI1")); + bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1")); _cancelDispute(disputeID); } @@ -23,7 +22,7 @@ contract DisputeManagerIndexingCancelDisputeTest is DisputeManagerTest { uint256 tokens ) public useIndexer useAllocation(tokens) { resetPrank(users.fisherman); - bytes32 disputeID =_createIndexingDispute(allocationID, bytes32("POI1")); + bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1")); resetPrank(users.arbitrator); vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerNotFisherman.selector)); @@ -34,7 +33,7 @@ contract DisputeManagerIndexingCancelDisputeTest is DisputeManagerTest { uint256 tokens ) public useIndexer useAllocation(tokens) { resetPrank(users.fisherman); - bytes32 disputeID =_createIndexingDispute(allocationID, bytes32("POI1")); + bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1")); vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerDisputePeriodNotFinished.selector)); disputeManager.cancelDispute(disputeID); diff --git a/packages/subgraph-service/test/disputeManager/disputes/indexing/draw.t.sol b/packages/subgraph-service/test/disputeManager/disputes/indexing/draw.t.sol index 7ce70d962..0f7dc6699 100644 --- a/packages/subgraph-service/test/disputeManager/disputes/indexing/draw.t.sol +++ b/packages/subgraph-service/test/disputeManager/disputes/indexing/draw.t.sol @@ -8,24 +8,21 @@ import { IDisputeManager } from "../../../../contracts/interfaces/IDisputeManage import { DisputeManagerTest } from "../../DisputeManager.t.sol"; contract DisputeManagerIndexingDrawDisputeTest is DisputeManagerTest { - /* * TESTS */ function test_Indexing_Draw_Dispute(uint256 tokens) public useIndexer useAllocation(tokens) { resetPrank(users.fisherman); - bytes32 disputeID =_createIndexingDispute(allocationID, bytes32("POI32")); + bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI32")); resetPrank(users.arbitrator); _drawDispute(disputeID); } - function test_Indexing_Draw_RevertIf_CallerIsNotArbitrator( - uint256 tokens - ) public useIndexer useAllocation(tokens) { + function test_Indexing_Draw_RevertIf_CallerIsNotArbitrator(uint256 tokens) public useIndexer useAllocation(tokens) { resetPrank(users.fisherman); - bytes32 disputeID = _createIndexingDispute(allocationID,bytes32("POI1")); + bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1")); // attempt to draw dispute as fisherman vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerNotArbitrator.selector)); diff --git a/packages/subgraph-service/test/disputeManager/disputes/indexing/reject.t.sol b/packages/subgraph-service/test/disputeManager/disputes/indexing/reject.t.sol index 41b5adabc..ed91c70c0 100644 --- a/packages/subgraph-service/test/disputeManager/disputes/indexing/reject.t.sol +++ b/packages/subgraph-service/test/disputeManager/disputes/indexing/reject.t.sol @@ -7,7 +7,6 @@ import { IDisputeManager } from "../../../../contracts/interfaces/IDisputeManage import { DisputeManagerTest } from "../../DisputeManager.t.sol"; contract DisputeManagerIndexingRejectDisputeTest is DisputeManagerTest { - /* * TESTS */ @@ -24,7 +23,7 @@ contract DisputeManagerIndexingRejectDisputeTest is DisputeManagerTest { uint256 tokens ) public useIndexer useAllocation(tokens) { resetPrank(users.fisherman); - bytes32 disputeID =_createIndexingDispute(allocationID, bytes32("POI1")); + bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1")); // attempt to accept dispute as fisherman resetPrank(users.fisherman); diff --git a/packages/subgraph-service/test/disputeManager/disputes/query/accept.t.sol b/packages/subgraph-service/test/disputeManager/disputes/query/accept.t.sol index 7262dadb9..9cfbaae10 100644 --- a/packages/subgraph-service/test/disputeManager/disputes/query/accept.t.sol +++ b/packages/subgraph-service/test/disputeManager/disputes/query/accept.t.sol @@ -19,10 +19,7 @@ contract DisputeManagerQueryAcceptDisputeTest is DisputeManagerTest { * TESTS */ - function test_Query_Accept_Dispute( - uint256 tokens, - uint256 tokensSlash - ) public useIndexer useAllocation(tokens) { + function test_Query_Accept_Dispute(uint256 tokens, uint256 tokensSlash) public useIndexer useAllocation(tokens) { tokensSlash = bound(tokensSlash, 1, uint256(maxSlashingPercentage).mulPPM(tokens)); resetPrank(users.fisherman); @@ -98,7 +95,7 @@ contract DisputeManagerQueryAcceptDisputeTest is DisputeManagerTest { resetPrank(users.arbitrator); uint256 maxTokensToSlash = uint256(maxSlashingPercentage).mulPPM(tokens); bytes memory expectedError = abi.encodeWithSelector( - IDisputeManager.DisputeManagerInvalidTokensSlash.selector, + IDisputeManager.DisputeManagerInvalidTokensSlash.selector, tokensSlash, maxTokensToSlash ); @@ -118,10 +115,7 @@ contract DisputeManagerQueryAcceptDisputeTest is DisputeManagerTest { bytes32 disputeID = _createQueryDispute(attestationData); resetPrank(users.arbitrator); - vm.expectRevert(abi.encodeWithSelector( - IDisputeManager.DisputeManagerDisputeNotInConflict.selector, - disputeID - )); + vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerDisputeNotInConflict.selector, disputeID)); disputeManager.acceptDisputeConflict(disputeID, tokensSlash, true, 0); } } diff --git a/packages/subgraph-service/test/disputeManager/disputes/query/cancel.t.sol b/packages/subgraph-service/test/disputeManager/disputes/query/cancel.t.sol index 5a70e2f70..471d1620a 100644 --- a/packages/subgraph-service/test/disputeManager/disputes/query/cancel.t.sol +++ b/packages/subgraph-service/test/disputeManager/disputes/query/cancel.t.sol @@ -8,7 +8,6 @@ import { IDisputeManager } from "../../../../contracts/interfaces/IDisputeManage import { DisputeManagerTest } from "../../DisputeManager.t.sol"; contract DisputeManagerQueryCancelDisputeTest is DisputeManagerTest { - bytes32 private requestCID = keccak256(abi.encodePacked("Request CID")); bytes32 private responseCID = keccak256(abi.encodePacked("Response CID")); bytes32 private subgraphDeploymentId = keccak256(abi.encodePacked("Subgraph Deployment ID")); @@ -26,9 +25,7 @@ contract DisputeManagerQueryCancelDisputeTest is DisputeManagerTest { _cancelDispute(disputeID); } - function test_Query_Cancel_RevertIf_CallerIsNotFisherman( - uint256 tokens - ) public useIndexer useAllocation(tokens) { + function test_Query_Cancel_RevertIf_CallerIsNotFisherman(uint256 tokens) public useIndexer useAllocation(tokens) { resetPrank(users.fisherman); Attestation.Receipt memory receipt = _createAttestationReceipt(requestCID, responseCID, subgraphDeploymentId); bytes memory attestationData = _createAtestationData(receipt, allocationIDPrivateKey); @@ -39,9 +36,7 @@ contract DisputeManagerQueryCancelDisputeTest is DisputeManagerTest { disputeManager.cancelDispute(disputeID); } - function test_Query_Cancel_RevertIf_DisputePeriodNotOver( - uint256 tokens - ) public useIndexer useAllocation(tokens) { + function test_Query_Cancel_RevertIf_DisputePeriodNotOver(uint256 tokens) public useIndexer useAllocation(tokens) { resetPrank(users.fisherman); Attestation.Receipt memory receipt = _createAttestationReceipt(requestCID, responseCID, subgraphDeploymentId); bytes memory attestationData = _createAtestationData(receipt, allocationIDPrivateKey); diff --git a/packages/subgraph-service/test/disputeManager/disputes/query/create.t.sol b/packages/subgraph-service/test/disputeManager/disputes/query/create.t.sol index 3dd4f7bbf..843318995 100644 --- a/packages/subgraph-service/test/disputeManager/disputes/query/create.t.sol +++ b/packages/subgraph-service/test/disputeManager/disputes/query/create.t.sol @@ -8,7 +8,6 @@ import { Attestation } from "../../../../contracts/libraries/Attestation.sol"; import { DisputeManagerTest } from "../../DisputeManager.t.sol"; contract DisputeManagerQueryCreateDisputeTest is DisputeManagerTest { - bytes32 private requestCID = keccak256(abi.encodePacked("Request CID")); bytes32 private responseCID = keccak256(abi.encodePacked("Response CID")); bytes32 private subgraphDeploymentId = keccak256(abi.encodePacked("Subgraph Deployment ID")); @@ -24,7 +23,9 @@ contract DisputeManagerQueryCreateDisputeTest is DisputeManagerTest { _createQueryDispute(attestationData); } - function test_Query_Create_Dispute_RevertWhen_SubgraphServiceNotSet(uint256 tokens) public useIndexer useAllocation(tokens) { + function test_Query_Create_Dispute_RevertWhen_SubgraphServiceNotSet( + uint256 tokens + ) public useIndexer useAllocation(tokens) { resetPrank(users.fisherman); Attestation.Receipt memory receipt = _createAttestationReceipt(requestCID, responseCID, subgraphDeploymentId); bytes memory attestationData = _createAtestationData(receipt, allocationIDPrivateKey); @@ -51,8 +52,15 @@ contract DisputeManagerQueryCreateDisputeTest is DisputeManagerTest { address otherFisherman = makeAddr("otherFisherman"); resetPrank(otherFisherman); mint(otherFisherman, MAX_TOKENS); - Attestation.Receipt memory otherFishermanReceipt = _createAttestationReceipt(requestCID, responseCID, subgraphDeploymentId); - bytes memory otherFishermanAttestationData = _createAtestationData(otherFishermanReceipt, allocationIDPrivateKey); + Attestation.Receipt memory otherFishermanReceipt = _createAttestationReceipt( + requestCID, + responseCID, + subgraphDeploymentId + ); + bytes memory otherFishermanAttestationData = _createAtestationData( + otherFishermanReceipt, + allocationIDPrivateKey + ); _createQueryDispute(otherFishermanAttestationData); } @@ -87,13 +95,16 @@ contract DisputeManagerQueryCreateDisputeTest is DisputeManagerTest { bytes memory attestationData = _createAtestationData(receipt, allocationIDPrivateKey); bytes32 disputeID = _createQueryDispute(attestationData); - Attestation.Receipt memory newReceipt = _createAttestationReceipt(requestCID, responseCID, subgraphDeploymentId); + Attestation.Receipt memory newReceipt = _createAttestationReceipt( + requestCID, + responseCID, + subgraphDeploymentId + ); bytes memory newAttestationData = _createAtestationData(newReceipt, allocationIDPrivateKey); token.approve(address(disputeManager), disputeDeposit); - vm.expectRevert(abi.encodeWithSelector( - IDisputeManager.DisputeManagerDisputeAlreadyCreated.selector, - disputeID - )); + vm.expectRevert( + abi.encodeWithSelector(IDisputeManager.DisputeManagerDisputeAlreadyCreated.selector, disputeID) + ); disputeManager.createQueryDispute(newAttestationData); } @@ -113,9 +124,7 @@ contract DisputeManagerQueryCreateDisputeTest is DisputeManagerTest { disputeManager.createQueryDispute(attestationData); } - function test_Query_Create_RevertIf_AllocationDoesNotExist( - uint256 tokens - ) public useFisherman { + function test_Query_Create_RevertIf_AllocationDoesNotExist(uint256 tokens) public useFisherman { tokens = bound(tokens, disputeDeposit, 10_000_000_000 ether); Attestation.Receipt memory receipt = _createAttestationReceipt(requestCID, responseCID, subgraphDeploymentId); bytes memory attestationData = _createAtestationData(receipt, allocationIDPrivateKey); @@ -129,17 +138,15 @@ contract DisputeManagerQueryCreateDisputeTest is DisputeManagerTest { vm.stopPrank(); } - function test_Query_Create_RevertIf_IndexerIsBelowStake( - uint256 tokens - ) public useIndexer useAllocation(tokens) { + function test_Query_Create_RevertIf_IndexerIsBelowStake(uint256 tokens) public useIndexer useAllocation(tokens) { // Close allocation bytes memory data = abi.encode(allocationID); _stopService(users.indexer, data); - + // Thaw, deprovision and unstake address subgraphDataServiceAddress = address(subgraphService); _thawDeprovisionAndUnstake(users.indexer, subgraphDataServiceAddress, tokens); - + // Atempt to create dispute resetPrank(users.fisherman); token.approve(address(disputeManager), tokens); diff --git a/packages/subgraph-service/test/disputeManager/disputes/query/draw.t.sol b/packages/subgraph-service/test/disputeManager/disputes/query/draw.t.sol index 2ff182378..59eaee991 100644 --- a/packages/subgraph-service/test/disputeManager/disputes/query/draw.t.sol +++ b/packages/subgraph-service/test/disputeManager/disputes/query/draw.t.sol @@ -9,7 +9,6 @@ import { IDisputeManager } from "../../../../contracts/interfaces/IDisputeManage import { DisputeManagerTest } from "../../DisputeManager.t.sol"; contract DisputeManagerQueryDrawDisputeTest is DisputeManagerTest { - bytes32 private requestCID = keccak256(abi.encodePacked("Request CID")); bytes32 private responseCID = keccak256(abi.encodePacked("Response CID")); bytes32 private subgraphDeploymentId = keccak256(abi.encodePacked("Subgraph Deployment ID")); @@ -18,9 +17,7 @@ contract DisputeManagerQueryDrawDisputeTest is DisputeManagerTest { * TESTS */ - function test_Query_Draw_Dispute( - uint256 tokens - ) public useIndexer useAllocation(tokens) { + function test_Query_Draw_Dispute(uint256 tokens) public useIndexer useAllocation(tokens) { resetPrank(users.fisherman); Attestation.Receipt memory receipt = _createAttestationReceipt(requestCID, responseCID, subgraphDeploymentId); bytes memory attestationData = _createAtestationData(receipt, allocationIDPrivateKey); @@ -30,9 +27,7 @@ contract DisputeManagerQueryDrawDisputeTest is DisputeManagerTest { _drawDispute(disputeID); } - function test_Query_Draw_RevertIf_CallerIsNotArbitrator( - uint256 tokens - ) public useIndexer useAllocation(tokens) { + function test_Query_Draw_RevertIf_CallerIsNotArbitrator(uint256 tokens) public useIndexer useAllocation(tokens) { resetPrank(users.fisherman); Attestation.Receipt memory receipt = _createAttestationReceipt(requestCID, responseCID, subgraphDeploymentId); bytes memory attestationData = _createAtestationData(receipt, allocationIDPrivateKey); diff --git a/packages/subgraph-service/test/disputeManager/disputes/query/reject.t.sol b/packages/subgraph-service/test/disputeManager/disputes/query/reject.t.sol index fff210ea6..4752ed423 100644 --- a/packages/subgraph-service/test/disputeManager/disputes/query/reject.t.sol +++ b/packages/subgraph-service/test/disputeManager/disputes/query/reject.t.sol @@ -8,7 +8,6 @@ import { IDisputeManager } from "../../../../contracts/interfaces/IDisputeManage import { DisputeManagerTest } from "../../DisputeManager.t.sol"; contract DisputeManagerQueryRejectDisputeTest is DisputeManagerTest { - bytes32 private requestCID = keccak256(abi.encodePacked("Request CID")); bytes32 private responseCID = keccak256(abi.encodePacked("Response CID")); bytes32 private subgraphDeploymentId = keccak256(abi.encodePacked("Subgraph Deployment ID")); @@ -17,9 +16,7 @@ contract DisputeManagerQueryRejectDisputeTest is DisputeManagerTest { * TESTS */ - function test_Query_Reject_Dispute( - uint256 tokens - ) public useIndexer useAllocation(tokens) { + function test_Query_Reject_Dispute(uint256 tokens) public useIndexer useAllocation(tokens) { resetPrank(users.fisherman); Attestation.Receipt memory receipt = _createAttestationReceipt(requestCID, responseCID, subgraphDeploymentId); bytes memory attestationData = _createAtestationData(receipt, allocationIDPrivateKey); @@ -29,9 +26,7 @@ contract DisputeManagerQueryRejectDisputeTest is DisputeManagerTest { _rejectDispute(disputeID); } - function test_Query_Reject_RevertIf_CallerIsNotArbitrator( - uint256 tokens - ) public useIndexer useAllocation(tokens) { + function test_Query_Reject_RevertIf_CallerIsNotArbitrator(uint256 tokens) public useIndexer useAllocation(tokens) { resetPrank(users.fisherman); Attestation.Receipt memory receipt = _createAttestationReceipt(requestCID, responseCID, subgraphDeploymentId); bytes memory attestationData = _createAtestationData(receipt, allocationIDPrivateKey); diff --git a/packages/subgraph-service/test/disputeManager/disputes/queryConflict/cancel.t.sol b/packages/subgraph-service/test/disputeManager/disputes/queryConflict/cancel.t.sol index 36d14fab2..a368fc443 100644 --- a/packages/subgraph-service/test/disputeManager/disputes/queryConflict/cancel.t.sol +++ b/packages/subgraph-service/test/disputeManager/disputes/queryConflict/cancel.t.sol @@ -7,7 +7,6 @@ import { IDisputeManager } from "../../../../contracts/interfaces/IDisputeManage import { DisputeManagerTest } from "../../DisputeManager.t.sol"; contract DisputeManagerQueryConflictCancelDisputeTest is DisputeManagerTest { - bytes32 private requestCID = keccak256(abi.encodePacked("Request CID")); bytes32 private responseCID1 = keccak256(abi.encodePacked("Response CID 1")); bytes32 private responseCID2 = keccak256(abi.encodePacked("Response CID 2")); @@ -16,9 +15,7 @@ contract DisputeManagerQueryConflictCancelDisputeTest is DisputeManagerTest { * TESTS */ - function test_Query_Conflict_Cancel_Dispute( - uint256 tokens - ) public useIndexer useAllocation(tokens) { + function test_Query_Conflict_Cancel_Dispute(uint256 tokens) public useIndexer useAllocation(tokens) { (bytes memory attestationData1, bytes memory attestationData2) = _createConflictingAttestations( requestCID, subgraphDeployment, @@ -29,7 +26,7 @@ contract DisputeManagerQueryConflictCancelDisputeTest is DisputeManagerTest { ); resetPrank(users.fisherman); - (bytes32 disputeID1,) = _createQueryDisputeConflict(attestationData1, attestationData2); + (bytes32 disputeID1, ) = _createQueryDisputeConflict(attestationData1, attestationData2); _cancelDispute(disputeID1); } @@ -47,7 +44,7 @@ contract DisputeManagerQueryConflictCancelDisputeTest is DisputeManagerTest { ); resetPrank(users.fisherman); - (bytes32 disputeID1,) = _createQueryDisputeConflict(attestationData1, attestationData2); + (bytes32 disputeID1, ) = _createQueryDisputeConflict(attestationData1, attestationData2); resetPrank(users.indexer); vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerNotFisherman.selector)); @@ -67,7 +64,7 @@ contract DisputeManagerQueryConflictCancelDisputeTest is DisputeManagerTest { ); resetPrank(users.fisherman); - (bytes32 disputeID1,) = _createQueryDisputeConflict(attestationData1, attestationData2); + (bytes32 disputeID1, ) = _createQueryDisputeConflict(attestationData1, attestationData2); resetPrank(users.fisherman); vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerDisputePeriodNotFinished.selector)); diff --git a/packages/subgraph-service/test/disputeManager/disputes/queryConflict/create.t.sol b/packages/subgraph-service/test/disputeManager/disputes/queryConflict/create.t.sol index edd2d545b..de08a7de4 100644 --- a/packages/subgraph-service/test/disputeManager/disputes/queryConflict/create.t.sol +++ b/packages/subgraph-service/test/disputeManager/disputes/queryConflict/create.t.sol @@ -8,7 +8,6 @@ import { Attestation } from "../../../../contracts/libraries/Attestation.sol"; import { DisputeManagerTest } from "../../DisputeManager.t.sol"; contract DisputeManagerQueryConflictCreateDisputeTest is DisputeManagerTest { - bytes32 private requestCID = keccak256(abi.encodePacked("Request CID")); bytes32 private responseCID1 = keccak256(abi.encodePacked("Response CID 1")); bytes32 private responseCID2 = keccak256(abi.encodePacked("Response CID 2")); @@ -17,9 +16,7 @@ contract DisputeManagerQueryConflictCreateDisputeTest is DisputeManagerTest { * TESTS */ - function test_Query_Conflict_Create_DisputeAttestation( - uint256 tokens - ) public useIndexer useAllocation(tokens) { + function test_Query_Conflict_Create_DisputeAttestation(uint256 tokens) public useIndexer useAllocation(tokens) { resetPrank(users.fisherman); (bytes memory attestationData1, bytes memory attestationData2) = _createConflictingAttestations( requestCID, @@ -85,11 +82,15 @@ contract DisputeManagerQueryConflictCreateDisputeTest is DisputeManagerTest { function test_Query_Conflict_Create_RevertIf_AttestationsHaveDifferentSubgraph() public useFisherman { bytes32 subgraphDeploymentId2 = keccak256(abi.encodePacked("Subgraph Deployment ID 2")); - + Attestation.Receipt memory receipt1 = _createAttestationReceipt(requestCID, responseCID1, subgraphDeployment); bytes memory attestationData1 = _createAtestationData(receipt1, allocationIDPrivateKey); - Attestation.Receipt memory receipt2 = _createAttestationReceipt(requestCID, responseCID2, subgraphDeploymentId2); + Attestation.Receipt memory receipt2 = _createAttestationReceipt( + requestCID, + responseCID2, + subgraphDeploymentId2 + ); bytes memory attestationData2 = _createAtestationData(receipt2, allocationIDPrivateKey); bytes memory expectedError = abi.encodeWithSelector( diff --git a/packages/subgraph-service/test/disputeManager/disputes/queryConflict/draw.t.sol b/packages/subgraph-service/test/disputeManager/disputes/queryConflict/draw.t.sol index 5444936cc..35875408b 100644 --- a/packages/subgraph-service/test/disputeManager/disputes/queryConflict/draw.t.sol +++ b/packages/subgraph-service/test/disputeManager/disputes/queryConflict/draw.t.sol @@ -8,7 +8,6 @@ import { IDisputeManager } from "../../../../contracts/interfaces/IDisputeManage import { DisputeManagerTest } from "../../DisputeManager.t.sol"; contract DisputeManagerQueryConflictDrawDisputeTest is DisputeManagerTest { - bytes32 private requestCID = keccak256(abi.encodePacked("Request CID")); bytes32 private responseCID1 = keccak256(abi.encodePacked("Response CID 1")); bytes32 private responseCID2 = keccak256(abi.encodePacked("Response CID 2")); @@ -17,9 +16,7 @@ contract DisputeManagerQueryConflictDrawDisputeTest is DisputeManagerTest { * TESTS */ - function test_Query_Conflict_Draw_Dispute( - uint256 tokens - ) public useIndexer useAllocation(tokens) { + function test_Query_Conflict_Draw_Dispute(uint256 tokens) public useIndexer useAllocation(tokens) { (bytes memory attestationData1, bytes memory attestationData2) = _createConflictingAttestations( requestCID, subgraphDeployment, @@ -30,7 +27,7 @@ contract DisputeManagerQueryConflictDrawDisputeTest is DisputeManagerTest { ); resetPrank(users.fisherman); - (bytes32 disputeID1,) = _createQueryDisputeConflict(attestationData1, attestationData2); + (bytes32 disputeID1, ) = _createQueryDisputeConflict(attestationData1, attestationData2); resetPrank(users.arbitrator); _drawDispute(disputeID1); @@ -49,7 +46,7 @@ contract DisputeManagerQueryConflictDrawDisputeTest is DisputeManagerTest { ); resetPrank(users.fisherman); - (bytes32 disputeID1,) = _createQueryDisputeConflict(attestationData1, attestationData2); + (bytes32 disputeID1, ) = _createQueryDisputeConflict(attestationData1, attestationData2); // attempt to draw dispute as fisherman resetPrank(users.fisherman); diff --git a/packages/subgraph-service/test/disputeManager/governance/arbitrator.t.sol b/packages/subgraph-service/test/disputeManager/governance/arbitrator.t.sol index 1277235fd..34b1f1322 100644 --- a/packages/subgraph-service/test/disputeManager/governance/arbitrator.t.sol +++ b/packages/subgraph-service/test/disputeManager/governance/arbitrator.t.sol @@ -8,7 +8,6 @@ import { DisputeManagerTest } from "../DisputeManager.t.sol"; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; contract DisputeManagerGovernanceArbitratorTest is DisputeManagerTest { - /* * TESTS */ @@ -26,7 +25,9 @@ contract DisputeManagerGovernanceArbitratorTest is DisputeManagerTest { function test_Governance_RevertWhen_NotGovernor() public useFisherman { address arbitrator = makeAddr("newArbitrator"); - vm.expectRevert(abi.encodeWithSelector(OwnableUpgradeable.OwnableUnauthorizedAccount.selector, users.fisherman)); + vm.expectRevert( + abi.encodeWithSelector(OwnableUpgradeable.OwnableUnauthorizedAccount.selector, users.fisherman) + ); disputeManager.setArbitrator(arbitrator); } } diff --git a/packages/subgraph-service/test/disputeManager/governance/disputeDeposit.t.sol b/packages/subgraph-service/test/disputeManager/governance/disputeDeposit.t.sol index bfd97f731..c7221e690 100644 --- a/packages/subgraph-service/test/disputeManager/governance/disputeDeposit.t.sol +++ b/packages/subgraph-service/test/disputeManager/governance/disputeDeposit.t.sol @@ -8,7 +8,6 @@ import { DisputeManagerTest } from "../DisputeManager.t.sol"; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; contract DisputeManagerGovernanceDisputeDepositTest is DisputeManagerTest { - /* * TESTS */ @@ -20,13 +19,17 @@ contract DisputeManagerGovernanceDisputeDepositTest is DisputeManagerTest { function test_Governance_RevertWhen_DepositTooLow(uint256 disputeDeposit) public useGovernor { vm.assume(disputeDeposit < MIN_DISPUTE_DEPOSIT); - vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerInvalidDisputeDeposit.selector, disputeDeposit)); + vm.expectRevert( + abi.encodeWithSelector(IDisputeManager.DisputeManagerInvalidDisputeDeposit.selector, disputeDeposit) + ); disputeManager.setDisputeDeposit(disputeDeposit); } function test_Governance_RevertWhen_NotGovernor() public useFisherman { uint256 disputeDeposit = 100 ether; - vm.expectRevert(abi.encodeWithSelector(OwnableUpgradeable.OwnableUnauthorizedAccount.selector, users.fisherman)); + vm.expectRevert( + abi.encodeWithSelector(OwnableUpgradeable.OwnableUnauthorizedAccount.selector, users.fisherman) + ); disputeManager.setDisputeDeposit(disputeDeposit); } } diff --git a/packages/subgraph-service/test/disputeManager/governance/fishermanRewardCut.t.sol b/packages/subgraph-service/test/disputeManager/governance/fishermanRewardCut.t.sol index 3eddddc37..b274ff6df 100644 --- a/packages/subgraph-service/test/disputeManager/governance/fishermanRewardCut.t.sol +++ b/packages/subgraph-service/test/disputeManager/governance/fishermanRewardCut.t.sol @@ -8,7 +8,6 @@ import { DisputeManagerTest } from "../DisputeManager.t.sol"; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; contract DisputeManagerGovernanceFishermanRewardCutTest is DisputeManagerTest { - /* * TESTS */ @@ -20,13 +19,17 @@ contract DisputeManagerGovernanceFishermanRewardCutTest is DisputeManagerTest { function test_Governance_RevertWhen_OverMaximumValue(uint32 fishermanRewardCut) public useGovernor { vm.assume(fishermanRewardCut > disputeManager.MAX_FISHERMAN_REWARD_CUT()); - vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerInvalidFishermanReward.selector, fishermanRewardCut)); + vm.expectRevert( + abi.encodeWithSelector(IDisputeManager.DisputeManagerInvalidFishermanReward.selector, fishermanRewardCut) + ); disputeManager.setFishermanRewardCut(fishermanRewardCut); } function test_Governance_RevertWhen_NotGovernor() public useFisherman { uint32 fishermanRewardCut = 1000; - vm.expectRevert(abi.encodeWithSelector(OwnableUpgradeable.OwnableUnauthorizedAccount.selector, users.fisherman)); + vm.expectRevert( + abi.encodeWithSelector(OwnableUpgradeable.OwnableUnauthorizedAccount.selector, users.fisherman) + ); disputeManager.setFishermanRewardCut(fishermanRewardCut); } -} \ No newline at end of file +} diff --git a/packages/subgraph-service/test/disputeManager/governance/maxSlashingCut.t.sol b/packages/subgraph-service/test/disputeManager/governance/maxSlashingCut.t.sol index a554f774c..5f0820241 100644 --- a/packages/subgraph-service/test/disputeManager/governance/maxSlashingCut.t.sol +++ b/packages/subgraph-service/test/disputeManager/governance/maxSlashingCut.t.sol @@ -8,7 +8,6 @@ import { DisputeManagerTest } from "../DisputeManager.t.sol"; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; contract DisputeManagerGovernanceMaxSlashingCutTest is DisputeManagerTest { - /* * TESTS */ @@ -20,13 +19,17 @@ contract DisputeManagerGovernanceMaxSlashingCutTest is DisputeManagerTest { function test_Governance_RevertWhen_NotPPM(uint32 maxSlashingCut) public useGovernor { vm.assume(maxSlashingCut > MAX_PPM); - vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerInvalidMaxSlashingCut.selector, maxSlashingCut)); + vm.expectRevert( + abi.encodeWithSelector(IDisputeManager.DisputeManagerInvalidMaxSlashingCut.selector, maxSlashingCut) + ); disputeManager.setMaxSlashingCut(maxSlashingCut); } function test_Governance_RevertWhen_NotGovernor() public useFisherman { uint32 maxSlashingCut = 1000; - vm.expectRevert(abi.encodeWithSelector(OwnableUpgradeable.OwnableUnauthorizedAccount.selector, users.fisherman)); + vm.expectRevert( + abi.encodeWithSelector(OwnableUpgradeable.OwnableUnauthorizedAccount.selector, users.fisherman) + ); disputeManager.setMaxSlashingCut(maxSlashingCut); } } diff --git a/packages/subgraph-service/test/disputeManager/governance/subgraphService.t.sol b/packages/subgraph-service/test/disputeManager/governance/subgraphService.t.sol index 8f39d48c3..2934af577 100644 --- a/packages/subgraph-service/test/disputeManager/governance/subgraphService.t.sol +++ b/packages/subgraph-service/test/disputeManager/governance/subgraphService.t.sol @@ -7,7 +7,6 @@ import { IDisputeManager } from "../../../contracts/interfaces/IDisputeManager.s import { DisputeManagerTest } from "../DisputeManager.t.sol"; contract DisputeManagerGovernanceSubgraphService is DisputeManagerTest { - /* * TESTS */ diff --git a/packages/subgraph-service/test/mocks/MockCuration.sol b/packages/subgraph-service/test/mocks/MockCuration.sol index e0158a99e..0fb417c6d 100644 --- a/packages/subgraph-service/test/mocks/MockCuration.sol +++ b/packages/subgraph-service/test/mocks/MockCuration.sol @@ -8,4 +8,4 @@ contract MockCuration { } function collect(bytes32, uint256) external {} -} \ No newline at end of file +} diff --git a/packages/subgraph-service/test/mocks/MockGRTToken.sol b/packages/subgraph-service/test/mocks/MockGRTToken.sol index c54f4e24c..cce7f717c 100644 --- a/packages/subgraph-service/test/mocks/MockGRTToken.sol +++ b/packages/subgraph-service/test/mocks/MockGRTToken.sol @@ -45,4 +45,4 @@ contract MockGRTToken is ERC20, IGraphToken { function increaseAllowance(address spender, uint256 addedValue) external returns (bool) {} function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) {} -} \ No newline at end of file +} diff --git a/packages/subgraph-service/test/mocks/MockRewardsManager.sol b/packages/subgraph-service/test/mocks/MockRewardsManager.sol index 9e0047a89..dd94d6a2c 100644 --- a/packages/subgraph-service/test/mocks/MockRewardsManager.sol +++ b/packages/subgraph-service/test/mocks/MockRewardsManager.sol @@ -61,7 +61,7 @@ contract MockRewardsManager is IRewardsManager { function getAccRewardsPerAllocatedToken(bytes32) external view returns (uint256, uint256) {} - function getRewards(address,address) external view returns (uint256) {} + function getRewards(address, address) external view returns (uint256) {} function calcRewards(uint256, uint256) external pure returns (uint256) {} @@ -71,12 +71,9 @@ contract MockRewardsManager is IRewardsManager { function takeRewards(address _allocationID) external returns (uint256) { address rewardsIssuer = msg.sender; - ( - , - , - uint256 tokens, - uint256 accRewardsPerAllocatedToken - ) = IRewardsIssuer(rewardsIssuer).getAllocationData(_allocationID); + (, , uint256 tokens, uint256 accRewardsPerAllocatedToken) = IRewardsIssuer(rewardsIssuer).getAllocationData( + _allocationID + ); uint256 accRewardsPerTokens = tokens.mulPPM(rewardsPerSignal); uint256 rewards = accRewardsPerTokens - accRewardsPerAllocatedToken; @@ -96,4 +93,4 @@ contract MockRewardsManager is IRewardsManager { subgraphs[_subgraphDeploymentID] = true; return 0; } -} \ No newline at end of file +} diff --git a/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol b/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol index aecc2e5ea..a3e3040bd 100644 --- a/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol +++ b/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol @@ -219,9 +219,21 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { CollectPaymentData memory collectPaymentDataAfter = _collectPaymentDataAfter(_indexer); if (_paymentType == IGraphPayments.PaymentTypes.QueryFee) { - _verifyQueryFeeCollection(_indexer, paymentCollected, _data, collectPaymentDataBefore, collectPaymentDataAfter); + _verifyQueryFeeCollection( + _indexer, + paymentCollected, + _data, + collectPaymentDataBefore, + collectPaymentDataAfter + ); } else if (_paymentType == IGraphPayments.PaymentTypes.IndexingRewards) { - _verifyIndexingRewardsCollection(_indexer, allocationId, indexingRewardsData, collectPaymentDataBefore, collectPaymentDataAfter); + _verifyIndexingRewardsCollection( + _indexer, + allocationId, + indexingRewardsData, + collectPaymentDataBefore, + collectPaymentDataAfter + ); } } @@ -261,9 +273,14 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { return collectPaymentDataAfter; } - function _handleQueryFeeCollection(address _indexer, bytes memory _data) private returns (uint256 paymentCollected) { + function _handleQueryFeeCollection( + address _indexer, + bytes memory _data + ) private returns (uint256 paymentCollected) { IGraphTallyCollector.SignedRAV memory signedRav = abi.decode(_data, (IGraphTallyCollector.SignedRAV)); - Allocation.State memory allocation = subgraphService.getAllocation(address(uint160(uint256(signedRav.rav.collectionId)))); + Allocation.State memory allocation = subgraphService.getAllocation( + address(uint160(uint256(signedRav.rav.collectionId))) + ); (address payer, , ) = graphTallyCollector.authorizedSigners(_recoverRAVSigner(signedRav)); uint256 tokensCollected = graphTallyCollector.tokensCollected( @@ -292,7 +309,9 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { return queryFeeData; } - function _handleIndexingRewardsCollection(bytes memory _data) private returns (uint256 paymentCollected, address allocationId, IndexingRewardsData memory indexingRewardsData) { + function _handleIndexingRewardsCollection( + bytes memory _data + ) private returns (uint256 paymentCollected, address allocationId, IndexingRewardsData memory indexingRewardsData) { (allocationId, indexingRewardsData.poi) = abi.decode(_data, (address, bytes32)); Allocation.State memory allocation = subgraphService.getAllocation(allocationId); @@ -309,8 +328,13 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { address(subgraphService), IGraphPayments.PaymentTypes.IndexingRewards ); - IHorizonStakingTypes.DelegationPool memory delegationPool = staking.getDelegationPool(allocation.indexer, address(subgraphService)); - indexingRewardsData.tokensDelegationRewards = delegationPool.shares > 0 ? paymentCollected.mulPPM(delegatorCut) : 0; + IHorizonStakingTypes.DelegationPool memory delegationPool = staking.getDelegationPool( + allocation.indexer, + address(subgraphService) + ); + indexingRewardsData.tokensDelegationRewards = delegationPool.shares > 0 + ? paymentCollected.mulPPM(delegatorCut) + : 0; indexingRewardsData.tokensIndexerRewards = paymentCollected - indexingRewardsData.tokensDelegationRewards; vm.expectEmit(address(subgraphService)); @@ -336,7 +360,9 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { CollectPaymentData memory collectPaymentDataAfter ) private view { IGraphTallyCollector.SignedRAV memory signedRav = abi.decode(_data, (IGraphTallyCollector.SignedRAV)); - Allocation.State memory allocation = subgraphService.getAllocation(address(uint160(uint256(signedRav.rav.collectionId)))); + Allocation.State memory allocation = subgraphService.getAllocation( + address(uint160(uint256(signedRav.rav.collectionId))) + ); QueryFeeData memory queryFeeData = _queryFeeData(allocation.subgraphDeploymentId); uint256 tokensProtocol = _paymentCollected.mulPPMRoundUp(queryFeeData.protocolPaymentCut); uint256 curationTokens = (_paymentCollected - tokensProtocol).mulPPMRoundUp(queryFeeData.curationCut); @@ -346,10 +372,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { collectPaymentDataAfter.indexerBalance, collectPaymentDataBefore.indexerBalance + expectedIndexerTokensPayment ); - assertEq( - collectPaymentDataAfter.curationBalance, - collectPaymentDataBefore.curationBalance + curationTokens - ); + assertEq(collectPaymentDataAfter.curationBalance, collectPaymentDataBefore.curationBalance + curationTokens); // Check locked tokens uint256 tokensToLock = _paymentCollected * subgraphService.stakeToFeesRatio(); diff --git a/packages/subgraph-service/test/subgraphService/allocation/overDelegated.t.sol b/packages/subgraph-service/test/subgraphService/allocation/overDelegated.t.sol index c9e58355b..d1f2f5ff0 100644 --- a/packages/subgraph-service/test/subgraphService/allocation/overDelegated.t.sol +++ b/packages/subgraph-service/test/subgraphService/allocation/overDelegated.t.sol @@ -11,7 +11,6 @@ import { ISubgraphService } from "../../../contracts/interfaces/ISubgraphService import { SubgraphServiceTest } from "../SubgraphService.t.sol"; contract SubgraphServiceAllocationOverDelegatedTest is SubgraphServiceTest { - /* * TESTS */ diff --git a/packages/subgraph-service/test/subgraphService/allocation/resize.t.sol b/packages/subgraph-service/test/subgraphService/allocation/resize.t.sol index ff8c504a9..9667309a1 100644 --- a/packages/subgraph-service/test/subgraphService/allocation/resize.t.sol +++ b/packages/subgraph-service/test/subgraphService/allocation/resize.t.sol @@ -10,12 +10,14 @@ import { ISubgraphService } from "../../../contracts/interfaces/ISubgraphService import { IGraphPayments } from "@graphprotocol/horizon/contracts/interfaces/IGraphPayments.sol"; contract SubgraphServiceAllocationResizeTest is SubgraphServiceTest { - /* * TESTS */ - function test_SubgraphService_Allocation_Resize(uint256 tokens, uint256 resizeTokens) public useIndexer useAllocation(tokens) { + function test_SubgraphService_Allocation_Resize( + uint256 tokens, + uint256 resizeTokens + ) public useIndexer useAllocation(tokens) { resizeTokens = bound(resizeTokens, 1, MAX_TOKENS); vm.assume(resizeTokens != tokens); @@ -24,7 +26,10 @@ contract SubgraphServiceAllocationResizeTest is SubgraphServiceTest { _resizeAllocation(users.indexer, allocationID, resizeTokens); } - function test_SubgraphService_Allocation_Resize_AfterCollectingIndexingRewards(uint256 tokens, uint256 resizeTokens) public useIndexer useAllocation(tokens) { + function test_SubgraphService_Allocation_Resize_AfterCollectingIndexingRewards( + uint256 tokens, + uint256 resizeTokens + ) public useIndexer useAllocation(tokens) { resizeTokens = bound(resizeTokens, 1, MAX_TOKENS); vm.assume(resizeTokens != tokens); @@ -40,7 +45,11 @@ contract SubgraphServiceAllocationResizeTest is SubgraphServiceTest { _resizeAllocation(users.indexer, allocationID, resizeTokens); } - function test_SubgraphService_Allocation_Resize_SecondTime(uint256 tokens, uint256 firstResizeTokens, uint256 secondResizeTokens) public useIndexer useAllocation(tokens) { + function test_SubgraphService_Allocation_Resize_SecondTime( + uint256 tokens, + uint256 firstResizeTokens, + uint256 secondResizeTokens + ) public useIndexer useAllocation(tokens) { firstResizeTokens = bound(firstResizeTokens, 1, MAX_TOKENS); secondResizeTokens = bound(secondResizeTokens, 1, MAX_TOKENS); vm.assume(firstResizeTokens != tokens); @@ -55,36 +64,43 @@ contract SubgraphServiceAllocationResizeTest is SubgraphServiceTest { _resizeAllocation(users.indexer, allocationID, secondResizeTokens); } - function test_SubgraphService_Allocation_Resize_RevertWhen_NotAuthorized(uint256 tokens, uint256 resizeTokens) public useIndexer useAllocation(tokens) { + function test_SubgraphService_Allocation_Resize_RevertWhen_NotAuthorized( + uint256 tokens, + uint256 resizeTokens + ) public useIndexer useAllocation(tokens) { resizeTokens = bound(resizeTokens, tokens + 1, MAX_TOKENS); address newIndexer = makeAddr("newIndexer"); _createAndStartAllocation(newIndexer, tokens); - vm.expectRevert(abi.encodeWithSelector( - ISubgraphService.SubgraphServiceAllocationNotAuthorized.selector, - newIndexer, - allocationID - )); + vm.expectRevert( + abi.encodeWithSelector( + ISubgraphService.SubgraphServiceAllocationNotAuthorized.selector, + newIndexer, + allocationID + ) + ); subgraphService.resizeAllocation(newIndexer, allocationID, resizeTokens); } - function test_SubgraphService_Allocation_Resize_RevertWhen_SameSize(uint256 tokens) public useIndexer useAllocation(tokens) { - vm.expectRevert(abi.encodeWithSelector( - AllocationManager.AllocationManagerAllocationSameSize.selector, - allocationID, - tokens - )); + function test_SubgraphService_Allocation_Resize_RevertWhen_SameSize( + uint256 tokens + ) public useIndexer useAllocation(tokens) { + vm.expectRevert( + abi.encodeWithSelector(AllocationManager.AllocationManagerAllocationSameSize.selector, allocationID, tokens) + ); subgraphService.resizeAllocation(users.indexer, allocationID, tokens); } - function test_SubgraphService_Allocation_Resize_RevertIf_AllocationIsClosed(uint256 tokens, uint256 resizeTokens) public useIndexer useAllocation(tokens) { + function test_SubgraphService_Allocation_Resize_RevertIf_AllocationIsClosed( + uint256 tokens, + uint256 resizeTokens + ) public useIndexer useAllocation(tokens) { resizeTokens = bound(resizeTokens, tokens + 1, MAX_TOKENS); bytes memory data = abi.encode(allocationID); _stopService(users.indexer, data); - vm.expectRevert(abi.encodeWithSelector( - AllocationManager.AllocationManagerAllocationClosed.selector, - allocationID - )); + vm.expectRevert( + abi.encodeWithSelector(AllocationManager.AllocationManagerAllocationClosed.selector, allocationID) + ); subgraphService.resizeAllocation(users.indexer, allocationID, resizeTokens); } } diff --git a/packages/subgraph-service/test/subgraphService/allocation/start.t.sol b/packages/subgraph-service/test/subgraphService/allocation/start.t.sol index a7df1f1a8..15e48dc66 100644 --- a/packages/subgraph-service/test/subgraphService/allocation/start.t.sol +++ b/packages/subgraph-service/test/subgraphService/allocation/start.t.sol @@ -14,7 +14,6 @@ import { LegacyAllocation } from "../../../contracts/libraries/LegacyAllocation. import { SubgraphServiceTest } from "../SubgraphService.t.sol"; contract SubgraphServiceAllocationStartTest is SubgraphServiceTest { - /* * TESTS */ @@ -29,7 +28,7 @@ contract SubgraphServiceAllocationStartTest is SubgraphServiceTest { _startService(users.indexer, data); } - function test_SubgraphService_Allocation_Start_AllowsZeroTokens(uint256 tokens) public useIndexer { + function test_SubgraphService_Allocation_Start_AllowsZeroTokens(uint256 tokens) public useIndexer { tokens = bound(tokens, minimumProvisionTokens, MAX_TOKENS); _createProvision(users.indexer, tokens, maxSlashingPercentage, disputePeriod); @@ -57,22 +56,23 @@ contract SubgraphServiceAllocationStartTest is SubgraphServiceTest { resetPrank(users.operator); bytes memory data = _generateData(tokens); - vm.expectRevert(abi.encodeWithSelector( - ProvisionManager.ProvisionManagerNotAuthorized.selector, - users.indexer, - users.operator - )); + vm.expectRevert( + abi.encodeWithSelector( + ProvisionManager.ProvisionManagerNotAuthorized.selector, + users.indexer, + users.operator + ) + ); subgraphService.startService(users.indexer, data); } function test_SubgraphService_Allocation_Start_RevertWhen_NoValidProvision(uint256 tokens) public useIndexer { tokens = bound(tokens, minimumProvisionTokens, MAX_TOKENS); - + bytes memory data = _generateData(tokens); - vm.expectRevert(abi.encodeWithSelector( - ProvisionManager.ProvisionManagerProvisionNotFound.selector, - users.indexer - )); + vm.expectRevert( + abi.encodeWithSelector(ProvisionManager.ProvisionManagerProvisionNotFound.selector, users.indexer) + ); subgraphService.startService(users.indexer, data); } @@ -82,10 +82,9 @@ contract SubgraphServiceAllocationStartTest is SubgraphServiceTest { _createProvision(users.indexer, tokens, maxSlashingPercentage, disputePeriod); bytes memory data = _generateData(tokens); - vm.expectRevert(abi.encodeWithSelector( - ISubgraphService.SubgraphServiceIndexerNotRegistered.selector, - users.indexer - )); + vm.expectRevert( + abi.encodeWithSelector(ISubgraphService.SubgraphServiceIndexerNotRegistered.selector, users.indexer) + ); subgraphService.startService(users.indexer, data); } @@ -98,9 +97,7 @@ contract SubgraphServiceAllocationStartTest is SubgraphServiceTest { bytes32 digest = subgraphService.encodeAllocationProof(users.indexer, address(0)); (uint8 v, bytes32 r, bytes32 s) = vm.sign(allocationIDPrivateKey, digest); bytes memory data = abi.encode(subgraphDeployment, tokens, address(0), abi.encodePacked(r, s, v)); - vm.expectRevert(abi.encodeWithSelector( - AllocationManager.AllocationManagerInvalidZeroAllocationId.selector - )); + vm.expectRevert(abi.encodeWithSelector(AllocationManager.AllocationManagerInvalidZeroAllocationId.selector)); subgraphService.startService(users.indexer, data); } @@ -114,11 +111,13 @@ contract SubgraphServiceAllocationStartTest is SubgraphServiceTest { bytes32 digest = subgraphService.encodeAllocationProof(users.indexer, allocationID); (uint8 v, bytes32 r, bytes32 s) = vm.sign(signerPrivateKey, digest); bytes memory data = abi.encode(subgraphDeployment, tokens, allocationID, abi.encodePacked(r, s, v)); - vm.expectRevert(abi.encodeWithSelector( - AllocationManager.AllocationManagerInvalidAllocationProof.selector, - signer, - allocationID - )); + vm.expectRevert( + abi.encodeWithSelector( + AllocationManager.AllocationManagerInvalidAllocationProof.selector, + signer, + allocationID + ) + ); subgraphService.startService(users.indexer, data); } @@ -129,14 +128,13 @@ contract SubgraphServiceAllocationStartTest is SubgraphServiceTest { _register(users.indexer, abi.encode("url", "geoHash", address(0))); bytes memory data = abi.encode(subgraphDeployment, tokens, allocationID, _generateRandomHexBytes(32)); - vm.expectRevert(abi.encodeWithSelector( - ECDSA.ECDSAInvalidSignatureLength.selector, - 32 - )); + vm.expectRevert(abi.encodeWithSelector(ECDSA.ECDSAInvalidSignatureLength.selector, 32)); subgraphService.startService(users.indexer, data); } - function test_SubgraphService_Allocation_Start_RevertWhen_AlreadyExists_SubgraphService(uint256 tokens) public useIndexer { + function test_SubgraphService_Allocation_Start_RevertWhen_AlreadyExists_SubgraphService( + uint256 tokens + ) public useIndexer { tokens = bound(tokens, minimumProvisionTokens, MAX_TOKENS); _createProvision(users.indexer, tokens, maxSlashingPercentage, disputePeriod); @@ -145,10 +143,7 @@ contract SubgraphServiceAllocationStartTest is SubgraphServiceTest { bytes memory data = _generateData(tokens); _startService(users.indexer, data); - vm.expectRevert(abi.encodeWithSelector( - Allocation.AllocationAlreadyExists.selector, - allocationID - )); + vm.expectRevert(abi.encodeWithSelector(Allocation.AllocationAlreadyExists.selector, allocationID)); subgraphService.startService(users.indexer, data); } @@ -163,10 +158,7 @@ contract SubgraphServiceAllocationStartTest is SubgraphServiceTest { resetPrank(users.indexer); bytes memory data = _generateData(tokens); - vm.expectRevert(abi.encodeWithSelector( - LegacyAllocation.LegacyAllocationAlreadyExists.selector, - allocationID - )); + vm.expectRevert(abi.encodeWithSelector(LegacyAllocation.LegacyAllocationAlreadyExists.selector, allocationID)); subgraphService.startService(users.indexer, data); } @@ -180,10 +172,7 @@ contract SubgraphServiceAllocationStartTest is SubgraphServiceTest { _setStorage_allocation_hardcoded(users.indexer, allocationID, tokens); bytes memory data = _generateData(tokens); - vm.expectRevert(abi.encodeWithSelector( - LegacyAllocation.LegacyAllocationAlreadyExists.selector, - allocationID - )); + vm.expectRevert(abi.encodeWithSelector(LegacyAllocation.LegacyAllocationAlreadyExists.selector, allocationID)); subgraphService.startService(users.indexer, data); } @@ -198,11 +187,9 @@ contract SubgraphServiceAllocationStartTest is SubgraphServiceTest { _register(users.indexer, abi.encode("url", "geoHash", address(0))); bytes memory data = _generateData(lockTokens); - vm.expectRevert(abi.encodeWithSelector( - ProvisionTracker.ProvisionTrackerInsufficientTokens.selector, - tokens, - lockTokens - )); + vm.expectRevert( + abi.encodeWithSelector(ProvisionTracker.ProvisionTrackerInsufficientTokens.selector, tokens, lockTokens) + ); subgraphService.startService(users.indexer, data); } @@ -210,14 +197,16 @@ contract SubgraphServiceAllocationStartTest is SubgraphServiceTest { * PRIVATE FUNCTIONS */ - function _generateData(uint256 tokens) private view returns(bytes memory) { + function _generateData(uint256 tokens) private view returns (bytes memory) { return _createSubgraphAllocationData(users.indexer, subgraphDeployment, allocationIDPrivateKey, tokens); } function _generateRandomHexBytes(uint256 length) private view returns (bytes memory) { bytes memory randomBytes = new bytes(length); for (uint256 i = 0; i < length; i++) { - randomBytes[i] = bytes1(uint8(uint256(keccak256(abi.encodePacked(block.timestamp, block.prevrandao, i))) % 256)); + randomBytes[i] = bytes1( + uint8(uint256(keccak256(abi.encodePacked(block.timestamp, block.prevrandao, i))) % 256) + ); } return randomBytes; } diff --git a/packages/subgraph-service/test/subgraphService/allocation/stop.t.sol b/packages/subgraph-service/test/subgraphService/allocation/stop.t.sol index 8a2b2a284..d861371e5 100644 --- a/packages/subgraph-service/test/subgraphService/allocation/stop.t.sol +++ b/packages/subgraph-service/test/subgraphService/allocation/stop.t.sol @@ -14,7 +14,6 @@ import { LegacyAllocation } from "../../../contracts/libraries/LegacyAllocation. import { SubgraphServiceTest } from "../SubgraphService.t.sol"; contract SubgraphServiceAllocationStopTest is SubgraphServiceTest { - /* * TESTS */ @@ -43,7 +42,9 @@ contract SubgraphServiceAllocationStopTest is SubgraphServiceTest { subgraphService.stopService(newIndexer, data); } - function test_SubgraphService_Allocation_Stop_RevertWhen_NotAuthorized(uint256 tokens) public useIndexer useAllocation(tokens) { + function test_SubgraphService_Allocation_Stop_RevertWhen_NotAuthorized( + uint256 tokens + ) public useIndexer useAllocation(tokens) { resetPrank(users.operator); bytes memory data = abi.encode(allocationID); vm.expectRevert( @@ -64,7 +65,9 @@ contract SubgraphServiceAllocationStopTest is SubgraphServiceTest { subgraphService.stopService(users.indexer, data); } - function test_SubgraphService_Allocation_Stop_RevertWhen_NotOpen(uint256 tokens) public useIndexer useAllocation(tokens) { + function test_SubgraphService_Allocation_Stop_RevertWhen_NotOpen( + uint256 tokens + ) public useIndexer useAllocation(tokens) { bytes memory data = abi.encode(allocationID); _stopService(users.indexer, data); vm.expectRevert(abi.encodeWithSelector(Allocation.AllocationClosed.selector, allocationID, block.timestamp)); diff --git a/packages/subgraph-service/test/subgraphService/collect/collect.t.sol b/packages/subgraph-service/test/subgraphService/collect/collect.t.sol index 9df747b4f..33ba00ff6 100644 --- a/packages/subgraph-service/test/subgraphService/collect/collect.t.sol +++ b/packages/subgraph-service/test/subgraphService/collect/collect.t.sol @@ -9,12 +9,13 @@ import { ISubgraphService } from "../../../contracts/interfaces/ISubgraphService import { SubgraphServiceTest } from "../SubgraphService.t.sol"; contract SubgraphServiceCollectTest is SubgraphServiceTest { - /* * TESTS */ - function test_SubgraphService_Collect_RevertWhen_InvalidPayment(uint256 tokens) public useIndexer useAllocation(tokens) { + function test_SubgraphService_Collect_RevertWhen_InvalidPayment( + uint256 tokens + ) public useIndexer useAllocation(tokens) { IGraphPayments.PaymentTypes invalidPaymentType = IGraphPayments.PaymentTypes.IndexingFee; vm.expectRevert( abi.encodeWithSelector(ISubgraphService.SubgraphServiceInvalidPaymentType.selector, invalidPaymentType) diff --git a/packages/subgraph-service/test/subgraphService/collect/indexing/indexing.t.sol b/packages/subgraph-service/test/subgraphService/collect/indexing/indexing.t.sol index 48eb36eb8..a35f37ecc 100644 --- a/packages/subgraph-service/test/subgraphService/collect/indexing/indexing.t.sol +++ b/packages/subgraph-service/test/subgraphService/collect/indexing/indexing.t.sol @@ -9,14 +9,11 @@ import { ISubgraphService } from "../../../../contracts/interfaces/ISubgraphServ import { SubgraphServiceTest } from "../../SubgraphService.t.sol"; contract SubgraphServiceCollectIndexingTest is SubgraphServiceTest { - /* * TESTS */ - function test_SubgraphService_Collect_Indexing( - uint256 tokens - ) public useIndexer useAllocation(tokens) { + function test_SubgraphService_Collect_Indexing(uint256 tokens) public useIndexer useAllocation(tokens) { IGraphPayments.PaymentTypes paymentType = IGraphPayments.PaymentTypes.IndexingRewards; bytes memory data = abi.encode(allocationID, bytes32("POI")); @@ -39,7 +36,6 @@ contract SubgraphServiceCollectIndexingTest is SubgraphServiceTest { delegationFeeCut ); - // skip time to ensure allocation gets rewards vm.roll(block.number + EPOCH_LENGTH); @@ -84,14 +80,16 @@ contract SubgraphServiceCollectIndexingTest is SubgraphServiceTest { _collect(users.indexer, paymentType, data); } - function test_subgraphService_Collect_Indexing_MultipleOverTime(uint256 tokens) public useIndexer useAllocation(tokens) { + function test_subgraphService_Collect_Indexing_MultipleOverTime( + uint256 tokens + ) public useIndexer useAllocation(tokens) { uint8 numberOfPOIs = 20; uint256 timeBetweenPOIs = 5 days; for (uint8 i = 0; i < numberOfPOIs; i++) { // Skip forward skip(timeBetweenPOIs); - + resetPrank(users.indexer); bytes memory data = abi.encode(allocationID, bytes32("POI")); @@ -111,13 +109,13 @@ contract SubgraphServiceCollectIndexingTest is SubgraphServiceTest { IGraphPayments.PaymentTypes.IndexingRewards, delegationFeeCut ); - + uint8 numberOfPOIs = 20; uint256 timeBetweenPOIs = 5 days; for (uint8 i = 0; i < numberOfPOIs; i++) { // Skip forward skip(timeBetweenPOIs); - + resetPrank(users.indexer); bytes memory data = abi.encode(allocationID, bytes32("POI")); @@ -127,11 +125,16 @@ contract SubgraphServiceCollectIndexingTest is SubgraphServiceTest { function test_SubgraphService_Collect_Indexing_OverAllocated(uint256 tokens) public useIndexer { tokens = bound(tokens, minimumProvisionTokens * 2, 10_000_000_000 ether); - + // setup allocation _createProvision(users.indexer, tokens, maxSlashingPercentage, disputePeriod); _register(users.indexer, abi.encode("url", "geoHash", address(0))); - bytes memory data = _createSubgraphAllocationData(users.indexer, subgraphDeployment, allocationIDPrivateKey, tokens); + bytes memory data = _createSubgraphAllocationData( + users.indexer, + subgraphDeployment, + allocationIDPrivateKey, + tokens + ); _startService(users.indexer, data); // thaw some tokens to become over allocated @@ -160,7 +163,11 @@ contract SubgraphServiceCollectIndexingTest is SubgraphServiceTest { // Attempt to collect from other indexer's allocation vm.expectRevert( - abi.encodeWithSelector(ISubgraphService.SubgraphServiceAllocationNotAuthorized.selector, newIndexer, allocationID) + abi.encodeWithSelector( + ISubgraphService.SubgraphServiceAllocationNotAuthorized.selector, + newIndexer, + allocationID + ) ); subgraphService.collect(newIndexer, paymentType, data); } diff --git a/packages/subgraph-service/test/subgraphService/collect/query/query.t.sol b/packages/subgraph-service/test/subgraphService/collect/query/query.t.sol index bec328b6b..b16cccff5 100644 --- a/packages/subgraph-service/test/subgraphService/collect/query/query.t.sol +++ b/packages/subgraph-service/test/subgraphService/collect/query/query.t.sol @@ -25,14 +25,20 @@ contract SubgraphServiceRegisterTest is SubgraphServiceTest { function _getSignerProof(uint256 _proofDeadline, uint256 _signer) private returns (bytes memory) { (, address msgSender, ) = vm.readCallers(); - bytes32 messageHash = keccak256(abi.encodePacked(block.chainid, address(graphTallyCollector), _proofDeadline, msgSender)); + bytes32 messageHash = keccak256( + abi.encodePacked(block.chainid, address(graphTallyCollector), _proofDeadline, msgSender) + ); bytes32 proofToDigest = MessageHashUtils.toEthSignedMessageHash(messageHash); (uint8 v, bytes32 r, bytes32 s) = vm.sign(_signer, proofToDigest); return abi.encodePacked(r, s, v); } function _getQueryFeeEncodedData(address indexer, uint128 tokens) private view returns (bytes memory) { - IGraphTallyCollector.ReceiptAggregateVoucher memory rav = _getRAV(indexer, bytes32(uint256(uint160(allocationID))), tokens); + IGraphTallyCollector.ReceiptAggregateVoucher memory rav = _getRAV( + indexer, + bytes32(uint256(uint160(allocationID))), + tokens + ); bytes32 messageHash = graphTallyCollector.encodeRAV(rav); (uint8 v, bytes32 r, bytes32 s) = vm.sign(signerPrivateKey, messageHash); bytes memory signature = abi.encodePacked(r, s, v); @@ -149,11 +155,7 @@ contract SubgraphServiceRegisterTest is SubgraphServiceTest { resetPrank(newIndexer); vm.expectRevert( - abi.encodeWithSelector( - ISubgraphService.SubgraphServiceInvalidRAV.selector, - newIndexer, - users.indexer - ) + abi.encodeWithSelector(ISubgraphService.SubgraphServiceInvalidRAV.selector, newIndexer, users.indexer) ); subgraphService.collect(newIndexer, paymentType, data); } @@ -180,7 +182,9 @@ contract SubgraphServiceRegisterTest is SubgraphServiceTest { bytes memory signature = abi.encodePacked(r, s, v); IGraphTallyCollector.SignedRAV memory signedRAV = IGraphTallyCollector.SignedRAV(rav, signature); bytes memory data = abi.encode(signedRAV); - vm.expectRevert(abi.encodeWithSelector(ISubgraphService.SubgraphServiceInvalidCollectionId.selector, collectionId)); + vm.expectRevert( + abi.encodeWithSelector(ISubgraphService.SubgraphServiceInvalidCollectionId.selector, collectionId) + ); subgraphService.collect(users.indexer, IGraphPayments.PaymentTypes.QueryFee, data); } } diff --git a/packages/subgraph-service/test/subgraphService/governance/stakeToFeesRatio.t.sol b/packages/subgraph-service/test/subgraphService/governance/stakeToFeesRatio.t.sol index bfd09073e..d1aca8155 100644 --- a/packages/subgraph-service/test/subgraphService/governance/stakeToFeesRatio.t.sol +++ b/packages/subgraph-service/test/subgraphService/governance/stakeToFeesRatio.t.sol @@ -8,7 +8,6 @@ import { SubgraphServiceTest } from "../SubgraphService.t.sol"; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; contract DisputeManagerGovernanceArbitratorTest is SubgraphServiceTest { - /** * ACTIONS */ diff --git a/packages/subgraph-service/test/subgraphService/provider/register.t.sol b/packages/subgraph-service/test/subgraphService/provider/register.t.sol index 6a4a36737..942f2e16a 100644 --- a/packages/subgraph-service/test/subgraphService/provider/register.t.sol +++ b/packages/subgraph-service/test/subgraphService/provider/register.t.sol @@ -8,7 +8,6 @@ import { ISubgraphService } from "../../../contracts/interfaces/ISubgraphService import { SubgraphServiceTest } from "../SubgraphService.t.sol"; contract SubgraphServiceProviderRegisterTest is SubgraphServiceTest { - /* * TESTS */ @@ -29,36 +28,41 @@ contract SubgraphServiceProviderRegisterTest is SubgraphServiceTest { } function test_SubgraphService_Provider_Register_RevertWhen_InvalidProvision() public useIndexer { - vm.expectRevert(abi.encodeWithSelector( - ProvisionManager.ProvisionManagerProvisionNotFound.selector, - users.indexer - )); + vm.expectRevert( + abi.encodeWithSelector(ProvisionManager.ProvisionManagerProvisionNotFound.selector, users.indexer) + ); bytes memory data = abi.encode("url", "geoHash", users.rewardsDestination); subgraphService.register(users.indexer, data); } function test_SubgraphService_Provider_Register_RevertWhen_NotAuthorized() public { resetPrank(users.operator); - vm.expectRevert(abi.encodeWithSelector( - ProvisionManager.ProvisionManagerNotAuthorized.selector, - users.indexer, - users.operator - )); + vm.expectRevert( + abi.encodeWithSelector( + ProvisionManager.ProvisionManagerNotAuthorized.selector, + users.indexer, + users.operator + ) + ); bytes memory data = abi.encode("url", "geoHash", users.rewardsDestination); subgraphService.register(users.indexer, data); } - function test_SubgraphService_Provider_Register_RevertWhen_InvalidProvisionValues(uint256 tokens) public useIndexer { + function test_SubgraphService_Provider_Register_RevertWhen_InvalidProvisionValues( + uint256 tokens + ) public useIndexer { tokens = bound(tokens, 1, minimumProvisionTokens - 1); _createProvision(users.indexer, tokens, maxSlashingPercentage, disputePeriod); - vm.expectRevert(abi.encodeWithSelector( - ProvisionManager.ProvisionManagerInvalidValue.selector, - "tokens", - tokens, - minimumProvisionTokens, - maximumProvisionTokens - )); + vm.expectRevert( + abi.encodeWithSelector( + ProvisionManager.ProvisionManagerInvalidValue.selector, + "tokens", + tokens, + minimumProvisionTokens, + maximumProvisionTokens + ) + ); subgraphService.register(users.indexer, abi.encode("url", "geoHash", address(0))); } diff --git a/packages/subgraph-service/test/subgraphService/provider/rewardsDestination.t.sol b/packages/subgraph-service/test/subgraphService/provider/rewardsDestination.t.sol index 0b4c805b2..600f655b2 100644 --- a/packages/subgraph-service/test/subgraphService/provider/rewardsDestination.t.sol +++ b/packages/subgraph-service/test/subgraphService/provider/rewardsDestination.t.sol @@ -9,7 +9,6 @@ import { ISubgraphService } from "../../../contracts/interfaces/ISubgraphService import { SubgraphServiceTest } from "../SubgraphService.t.sol"; contract SubgraphServiceProviderRewardsDestinationTest is SubgraphServiceTest { - /* * TESTS */ diff --git a/packages/subgraph-service/test/subgraphService/provision/accept.t.sol b/packages/subgraph-service/test/subgraphService/provision/accept.t.sol index f89cb307e..4d421b979 100644 --- a/packages/subgraph-service/test/subgraphService/provision/accept.t.sol +++ b/packages/subgraph-service/test/subgraphService/provision/accept.t.sol @@ -9,7 +9,6 @@ import { ISubgraphService } from "../../../contracts/interfaces/ISubgraphService import { SubgraphServiceTest } from "../SubgraphService.t.sol"; contract SubgraphServiceProvisionAcceptTest is SubgraphServiceTest { - /* * TESTS */ @@ -36,20 +35,21 @@ contract SubgraphServiceProvisionAcceptTest is SubgraphServiceTest { } function test_SubgraphService_Provision_Accept_RevertWhen_NotRegistered() public useIndexer { - vm.expectRevert(abi.encodeWithSelector( - ISubgraphService.SubgraphServiceIndexerNotRegistered.selector, - users.indexer - )); + vm.expectRevert( + abi.encodeWithSelector(ISubgraphService.SubgraphServiceIndexerNotRegistered.selector, users.indexer) + ); subgraphService.acceptProvisionPendingParameters(users.indexer, ""); } function test_SubgraphService_Provision_Accept_RevertWhen_NotAuthorized() public { resetPrank(users.operator); - vm.expectRevert(abi.encodeWithSelector( - ProvisionManager.ProvisionManagerNotAuthorized.selector, - users.indexer, - users.operator - )); + vm.expectRevert( + abi.encodeWithSelector( + ProvisionManager.ProvisionManagerNotAuthorized.selector, + users.indexer, + users.operator + ) + ); subgraphService.acceptProvisionPendingParameters(users.indexer, ""); } @@ -68,13 +68,15 @@ contract SubgraphServiceProvisionAcceptTest is SubgraphServiceTest { _setProvisionParameters(users.indexer, address(subgraphService), newVerifierCut, disputePeriod); // Should revert since newVerifierCut is invalid - vm.expectRevert(abi.encodeWithSelector( - ProvisionManager.ProvisionManagerInvalidValue.selector, - "maxVerifierCut", - newVerifierCut, - fishermanRewardPercentage, - MAX_PPM - )); + vm.expectRevert( + abi.encodeWithSelector( + ProvisionManager.ProvisionManagerInvalidValue.selector, + "maxVerifierCut", + newVerifierCut, + fishermanRewardPercentage, + MAX_PPM + ) + ); subgraphService.acceptProvisionPendingParameters(users.indexer, ""); } @@ -93,13 +95,15 @@ contract SubgraphServiceProvisionAcceptTest is SubgraphServiceTest { _setProvisionParameters(users.indexer, address(subgraphService), fishermanRewardPercentage, newDisputePeriod); // Should revert since newDisputePeriod is invalid - vm.expectRevert(abi.encodeWithSelector( - ProvisionManager.ProvisionManagerInvalidValue.selector, - "thawingPeriod", - newDisputePeriod, - disputePeriod, - type(uint64).max - )); + vm.expectRevert( + abi.encodeWithSelector( + ProvisionManager.ProvisionManagerInvalidValue.selector, + "thawingPeriod", + newDisputePeriod, + disputePeriod, + type(uint64).max + ) + ); subgraphService.acceptProvisionPendingParameters(users.indexer, ""); } } diff --git a/packages/subgraph-service/test/utils/Users.sol b/packages/subgraph-service/test/utils/Users.sol index 0d11fae9e..e0c142fe1 100644 --- a/packages/subgraph-service/test/utils/Users.sol +++ b/packages/subgraph-service/test/utils/Users.sol @@ -13,4 +13,4 @@ struct Users { address fisherman; address rewardsDestination; address pauseGuardian; -} \ No newline at end of file +} diff --git a/packages/subgraph-service/test/utils/Utils.sol b/packages/subgraph-service/test/utils/Utils.sol index 5aae4de3f..be42f269f 100644 --- a/packages/subgraph-service/test/utils/Utils.sol +++ b/packages/subgraph-service/test/utils/Utils.sol @@ -9,4 +9,4 @@ abstract contract Utils is Test { vm.stopPrank(); vm.startPrank(msgSender); } -} \ No newline at end of file +}