-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Tomás Migone <[email protected]>
- Loading branch information
Showing
5 changed files
with
102 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
packages/horizon/test/data-service/DataServiceUpgradeable.tree
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
packages/horizon/test/data-service/extensions/DataServicePausableUpgradeable.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.26; | ||
|
||
import { GraphBaseTest } from "../../GraphBase.t.sol"; | ||
import { DataServiceImpPausableUpgradeable } from "../implementations/DataServiceImpPausableUpgradeable.sol"; | ||
import { UnsafeUpgrades } from "openzeppelin-foundry-upgrades/Upgrades.sol"; | ||
|
||
contract DataServicePausableUpgradeableTest is GraphBaseTest { | ||
function test_WhenTheContractIsDeployed() external { | ||
( | ||
DataServiceImpPausableUpgradeable dataService, | ||
DataServiceImpPausableUpgradeable implementation | ||
) = _deployDataService(); | ||
|
||
// via proxy - ensure that the proxy was initialized correctly | ||
// these calls validate proxy storage was correctly initialized | ||
uint32 delegationRatio = dataService.getDelegationRatio(); | ||
assertEq(delegationRatio, type(uint32).min); | ||
|
||
(uint256 minTokens, uint256 maxTokens) = dataService.getProvisionTokensRange(); | ||
assertEq(minTokens, type(uint256).min); | ||
assertEq(maxTokens, type(uint256).max); | ||
|
||
(uint32 minVerifierCut, uint32 maxVerifierCut) = dataService.getVerifierCutRange(); | ||
assertEq(minVerifierCut, type(uint32).min); | ||
assertEq(maxVerifierCut, type(uint32).max); | ||
|
||
(uint64 minThawingPeriod, uint64 maxThawingPeriod) = dataService.getThawingPeriodRange(); | ||
assertEq(minThawingPeriod, type(uint64).min); | ||
assertEq(maxThawingPeriod, type(uint64).max); | ||
|
||
// this ensures that implementation immutables were correctly initialized | ||
// and they can be read via the proxy | ||
assertEq(implementation.controller(), address(controller)); | ||
assertEq(dataService.controller(), address(controller)); | ||
} | ||
|
||
function _deployDataService() | ||
internal | ||
returns (DataServiceImpPausableUpgradeable, DataServiceImpPausableUpgradeable) | ||
{ | ||
// Deploy implementation | ||
address implementation = address(new DataServiceImpPausableUpgradeable(address(controller))); | ||
|
||
// Deploy proxy | ||
address proxy = UnsafeUpgrades.deployTransparentProxy( | ||
implementation, | ||
users.governor, | ||
abi.encodeCall(DataServiceImpPausableUpgradeable.initialize, ()) | ||
); | ||
|
||
return (DataServiceImpPausableUpgradeable(proxy), DataServiceImpPausableUpgradeable(implementation)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/horizon/test/data-service/implementations/DataServiceImpPausableUpgradeable.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
pragma solidity 0.8.26; | ||
|
||
import { DataService } from "../../../contracts/data-service/DataService.sol"; | ||
import { DataServicePausableUpgradeable } from "../../../contracts/data-service/extensions/DataServicePausableUpgradeable.sol"; | ||
import { IGraphPayments } from "./../../../contracts/interfaces/IGraphPayments.sol"; | ||
|
||
contract DataServiceImpPausableUpgradeable is DataServicePausableUpgradeable { | ||
constructor(address controller) DataService(controller) { | ||
_disableInitializers(); | ||
} | ||
|
||
function initialize() external initializer { | ||
__DataService_init(); | ||
__DataServicePausable_init(); | ||
} | ||
|
||
function register(address serviceProvider, bytes calldata data) external {} | ||
|
||
function acceptProvision(address serviceProvider, bytes calldata data) external {} | ||
|
||
function startService(address serviceProvider, bytes calldata data) external {} | ||
|
||
function stopService(address serviceProvider, bytes calldata data) external {} | ||
|
||
function collect(address serviceProvider, IGraphPayments.PaymentTypes feeType, bytes calldata data) external {} | ||
|
||
function slash(address serviceProvider, bytes calldata data) external {} | ||
|
||
function controller() external view returns (address) { | ||
return address(_graphController()); | ||
} | ||
} |