This repository has been archived by the owner on May 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracted common tests for bonding abstract contract
- Loading branch information
Showing
7 changed files
with
1,009 additions
and
655 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
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,26 @@ | ||
pragma solidity 0.5.17; | ||
|
||
import "../../contracts/AbstractBonding.sol"; | ||
|
||
contract AbstractBondingStub is AbstractBonding { | ||
constructor( | ||
address registryAddress, | ||
address authorizationsAddress, | ||
address stakeDelegatableAddress | ||
) | ||
public | ||
AbstractBonding( | ||
registryAddress, | ||
authorizationsAddress, | ||
stakeDelegatableAddress | ||
) | ||
{} | ||
|
||
function withdraw(uint256 amount, address operator) public { | ||
revert("abstract function"); | ||
} | ||
|
||
function withdrawBondExposed(uint256 amount, address operator) public { | ||
withdrawBond(amount, operator); | ||
} | ||
} |
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,38 @@ | ||
pragma solidity 0.5.17; | ||
|
||
import "@keep-network/keep-core/contracts/Authorizations.sol"; | ||
import "@keep-network/keep-core/contracts/KeepRegistry.sol"; | ||
import "openzeppelin-solidity/contracts/math/SafeMath.sol"; | ||
|
||
/// @title Authorizations Stub | ||
/// @dev This contract is for testing purposes only. | ||
contract AuthorizationsStub is Authorizations { | ||
// Authorized operator contracts. | ||
mapping(address => mapping(address => bool)) internal authorizations; | ||
|
||
address public delegatedAuthority; | ||
|
||
constructor(KeepRegistry _registry) public Authorizations(_registry) {} | ||
|
||
function authorizeOperatorContract( | ||
address _operator, | ||
address _operatorContract | ||
) public { | ||
authorizations[_operatorContract][_operator] = true; | ||
} | ||
|
||
function isAuthorizedForOperator( | ||
address _operator, | ||
address _operatorContract | ||
) public view returns (bool) { | ||
return authorizations[_operatorContract][_operator]; | ||
} | ||
|
||
function authorizerOf(address _operator) public view returns (address) { | ||
revert("abstract function"); | ||
} | ||
|
||
function claimDelegatedAuthority(address delegatedAuthoritySource) public { | ||
delegatedAuthority = delegatedAuthoritySource; | ||
} | ||
} |
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,51 @@ | ||
pragma solidity 0.5.17; | ||
|
||
import "@keep-network/keep-core/contracts/StakeDelegatable.sol"; | ||
|
||
/// @title Stake Delegatable Stub | ||
/// @dev This contract is for testing purposes only. | ||
contract StakeDelegatableStub is StakeDelegatable { | ||
mapping(address => uint256) stakes; | ||
|
||
mapping(address => address) operatorToOwner; | ||
mapping(address => address payable) operatorToBeneficiary; | ||
mapping(address => address) operatorToAuthorizer; | ||
|
||
function setBalance(address _operator, uint256 _balance) public { | ||
stakes[_operator] = _balance; | ||
} | ||
|
||
function balanceOf(address _address) public view returns (uint256 balance) { | ||
return stakes[_address]; | ||
} | ||
|
||
function setOwner(address _operator, address _owner) public { | ||
operatorToOwner[_operator] = _owner; | ||
} | ||
|
||
function ownerOf(address _operator) public view returns (address) { | ||
return operatorToOwner[_operator]; | ||
} | ||
|
||
function setBeneficiary(address _operator, address payable _beneficiary) | ||
public | ||
{ | ||
operatorToBeneficiary[_operator] = _beneficiary; | ||
} | ||
|
||
function beneficiaryOf(address _operator) | ||
public | ||
view | ||
returns (address payable) | ||
{ | ||
return operatorToBeneficiary[_operator]; | ||
} | ||
|
||
function setAuthorizer(address _operator, address _authorizer) public { | ||
operatorToAuthorizer[_operator] = _authorizer; | ||
} | ||
|
||
function authorizerOf(address _operator) public view returns (address) { | ||
return operatorToAuthorizer[_operator]; | ||
} | ||
} |
Oops, something went wrong.