-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add data service framework tests
Signed-off-by: Tomás Migone <[email protected]>
- Loading branch information
Showing
11 changed files
with
589 additions
and
74 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,71 @@ | ||
DataService | ||
DataServiceTest::constructor_ | ||
└── when the contract is deployed with a valid controller | ||
└── it should set all it's ranges to max | ||
└── it should set all it's ranges to max | ||
|
||
DataServiceTest::delegationRatio_ | ||
├── when setting the delegation ratio | ||
│ ├── it should emit an event | ||
│ └── it should set the range | ||
└── when getting the delegation ratio | ||
└── it should return the correct value | ||
|
||
DataServiceTest::provisionTokens_ | ||
├── when setting a valid range | ||
│ ├── it should emit an event | ||
│ └── it should set the range | ||
├── when setting an invalid range | ||
│ └── it should revert | ||
├── when getting the range | ||
│ └── it should return the correct value | ||
├── when getting the range with an overriden getter | ||
│ └── it should return the correct value | ||
├── when checking a valid provision | ||
│ └── it should not revert | ||
├── when checking with an overriden checker | ||
│ └── it should not revert | ||
└── when checking an invalid provision | ||
└── it should revert | ||
|
||
DataServiceTest::verifierCut_ | ||
├── when setting a valid range | ||
│ ├── it should emit an event | ||
│ └── it should set the range | ||
├── when setting an invalid range | ||
│ └── it should revert | ||
├── when getting the range | ||
│ └── it should return the correct value | ||
├── when getting the range with an overriden getter | ||
│ └── it should return the correct value | ||
├── when checking a valid provision | ||
│ └── it should not revert | ||
├── when checking with an overriden checker | ||
│ └── it should not revert | ||
└── when checking an invalid provision | ||
└── it should revert | ||
|
||
DataServiceTest::thawingPeriod_ | ||
├── when setting a valid range | ||
│ ├── it should emit an event | ||
│ └── it should set the range | ||
├── when setting an invalid range | ||
│ └── it should revert | ||
├── when getting the range | ||
│ └── it should return the correct value | ||
├── when getting the range with an overriden getter | ||
│ └── it should return the correct value | ||
├── when checking a valid provision | ||
│ └── it should not revert | ||
├── when checking with an overriden checker | ||
│ └── it should not revert | ||
└── when checking an invalid provision | ||
└── it should revert | ||
|
||
DataServiceTest::provisionParameters_ | ||
└── given provision parameters changed | ||
├── when the new parameters are valid | ||
│ ├── it should emit an event | ||
│ └── it should set the new parameters | ||
├── when the new thawing period is invalid | ||
│ └── it should revert | ||
└── when the new verifier cut is invalid | ||
└── it should revert |
This file was deleted.
Oops, something went wrong.
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: 3 additions & 0 deletions
3
packages/horizon/test/data-service/DataServiceUpgradeable.tree
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,3 @@ | ||
DataServiceUpgradeableTest | ||
└── when the contract is deployed with a valid controller | ||
└── it should set all it's ranges to max |
59 changes: 59 additions & 0 deletions
59
packages/horizon/test/data-service/implementations/DataServiceBase.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,59 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
pragma solidity 0.8.26; | ||
|
||
import { DataService } from "../../../contracts/data-service/DataService.sol"; | ||
import { IGraphPayments } from "./../../../contracts/interfaces/IGraphPayments.sol"; | ||
|
||
contract DataServiceBase is DataService { | ||
uint32 public constant DELEGATION_RATIO = 100; | ||
uint256 public constant PROVISION_TOKENS_MIN = 50; | ||
uint256 public constant PROVISION_TOKENS_MAX = 5000; | ||
uint32 public constant VERIFIER_CUT_MIN = 5; | ||
uint32 public constant VERIFIER_CUT_MAX = 100000; | ||
uint64 public constant THAWING_PERIOD_MIN = 15; | ||
uint64 public constant THAWING_PERIOD_MAX = 76; | ||
|
||
constructor(address controller) DataService(controller) initializer { | ||
__DataService_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 setDelegationRatio(uint32 ratio) external { | ||
_setDelegationRatio(ratio); | ||
} | ||
|
||
function setProvisionTokensRange(uint256 min, uint256 max) external { | ||
_setProvisionTokensRange(min, max); | ||
} | ||
|
||
function setVerifierCutRange(uint32 min, uint32 max) external { | ||
_setVerifierCutRange(min, max); | ||
} | ||
|
||
function setThawingPeriodRange(uint64 min, uint64 max) external { | ||
_setThawingPeriodRange(min, max); | ||
} | ||
|
||
function checkProvisionTokens(address serviceProvider) external view { | ||
_checkProvisionTokens(serviceProvider); | ||
} | ||
|
||
function checkProvisionParameters(address serviceProvider, bool pending) external view { | ||
_checkProvisionParameters(serviceProvider, pending); | ||
} | ||
|
||
function acceptProvisionParameters(address serviceProvider) external { | ||
_acceptProvisionParameters(serviceProvider); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...ta-service/DataServiceBaseUpgradeable.sol → ...mentations/DataServiceBaseUpgradeable.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
25 changes: 25 additions & 0 deletions
25
packages/horizon/test/data-service/implementations/DataServiceOverride.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,25 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
pragma solidity 0.8.26; | ||
|
||
import { DataServiceBase } from "./DataServiceBase.sol"; | ||
|
||
contract DataServiceOverride is DataServiceBase { | ||
constructor(address controller) DataServiceBase(controller) initializer { | ||
__DataService_init(); | ||
} | ||
|
||
function _getProvisionTokensRange() internal pure override returns (uint256, uint256) { | ||
return (PROVISION_TOKENS_MIN, PROVISION_TOKENS_MAX); | ||
} | ||
|
||
function _getVerifierCutRange() internal pure override returns (uint32, uint32) { | ||
return (VERIFIER_CUT_MIN, VERIFIER_CUT_MAX); | ||
} | ||
|
||
function _getThawingPeriodRange() internal pure override returns (uint64, uint64) { | ||
return (THAWING_PERIOD_MIN, THAWING_PERIOD_MAX); | ||
} | ||
|
||
function _checkProvisionTokens(address _serviceProvider) internal pure override {} | ||
function _checkProvisionParameters(address _serviceProvider, bool pending) internal pure override {} | ||
} |
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
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