-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'horizon' into tmigone/ignition-v0.15.9
- Loading branch information
Showing
9 changed files
with
104 additions
and
3 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
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,8 @@ | ||
export function mergeABIs(abi1: any[], abi2: any[]) { | ||
for (const item of abi2) { | ||
if (abi1.find((v) => v.name === item.name) === undefined) { | ||
abi1.push(item) | ||
} | ||
} | ||
return abi1 | ||
} |
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
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
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
59 changes: 59 additions & 0 deletions
59
packages/subgraph-service/test/subgraphService/allocation/overDelegated.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,59 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.27; | ||
|
||
import "forge-std/Test.sol"; | ||
|
||
import { IGraphPayments } from "@graphprotocol/horizon/contracts/interfaces/IGraphPayments.sol"; | ||
import { IHorizonStakingTypes } from "@graphprotocol/horizon/contracts/interfaces/internal/IHorizonStakingTypes.sol"; | ||
|
||
import { Allocation } from "../../../contracts/libraries/Allocation.sol"; | ||
import { ISubgraphService } from "../../../contracts/interfaces/ISubgraphService.sol"; | ||
import { SubgraphServiceTest } from "../SubgraphService.t.sol"; | ||
|
||
contract SubgraphServiceAllocationOverDelegatedTest is SubgraphServiceTest { | ||
|
||
/* | ||
* TESTS | ||
*/ | ||
|
||
function test_SubgraphService_Allocation_OverDelegated_NotOverAllocatedAfterUndelegation( | ||
uint256 delegationTokens, | ||
uint256 undelegationTokens | ||
) public useIndexer { | ||
// Use minimum provision tokens | ||
uint256 indexerTokens = minimumProvisionTokens; | ||
uint256 allocationTokens = indexerTokens * delegationRatio; | ||
// Bound delegation tokens to be over delegated | ||
delegationTokens = bound(delegationTokens, allocationTokens, MAX_TOKENS); | ||
// Assume undelegation tokens to still leave indexer over delegated | ||
vm.assume(undelegationTokens > 1); | ||
vm.assume(undelegationTokens < delegationTokens - allocationTokens); | ||
|
||
// Create provision | ||
token.approve(address(staking), indexerTokens); | ||
_createProvision(users.indexer, indexerTokens, maxSlashingPercentage, disputePeriod); | ||
_register(users.indexer, abi.encode("url", "geoHash", address(0))); | ||
|
||
// Delegate so that indexer is over allocated | ||
resetPrank(users.delegator); | ||
token.approve(address(staking), delegationTokens); | ||
_delegate(users.indexer, address(subgraphService), delegationTokens, 0); | ||
|
||
// Create allocation | ||
resetPrank(users.indexer); | ||
bytes memory data = _createSubgraphAllocationData( | ||
users.indexer, | ||
subgraphDeployment, | ||
allocationIDPrivateKey, | ||
allocationTokens | ||
); | ||
_startService(users.indexer, data); | ||
|
||
// Undelegate | ||
resetPrank(users.delegator); | ||
_undelegate(users.indexer, address(subgraphService), undelegationTokens); | ||
|
||
// Check that indexer is not over allocated | ||
assertFalse(subgraphService.isOverAllocated(users.indexer)); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -12,4 +12,5 @@ struct Users { | |
address arbitrator; | ||
address fisherman; | ||
address rewardsDestination; | ||
address pauseGuardian; | ||
} |