Skip to content
This repository was archived by the owner on May 22, 2023. It is now read-only.

Commit 00aebb4

Browse files
committed
Extracted common tests for bonding abstract contract
1 parent b271730 commit 00aebb4

File tree

5 files changed

+1002
-650
lines changed

5 files changed

+1002
-650
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
pragma solidity 0.5.17;
2+
3+
import "../../contracts/AbstractBonding.sol";
4+
5+
contract AbstractBondingStub is AbstractBonding {
6+
constructor(
7+
address registryAddress,
8+
address authorizationsAddress,
9+
address stakeDelegatableAddress
10+
)
11+
public
12+
AbstractBonding(
13+
registryAddress,
14+
authorizationsAddress,
15+
stakeDelegatableAddress
16+
)
17+
{}
18+
19+
function withdraw(uint256 amount, address operator) public {
20+
revert("abstract function");
21+
}
22+
23+
function withdrawBondExposed(uint256 amount, address operator) public {
24+
withdrawBond(amount, operator);
25+
}
26+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
pragma solidity 0.5.17;
2+
3+
import "@keep-network/keep-core/contracts/Authorizations.sol";
4+
import "@keep-network/keep-core/contracts/KeepRegistry.sol";
5+
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
6+
7+
/// @title Authorizations Stub
8+
/// @dev This contract is for testing purposes only.
9+
contract AuthorizationsStub is Authorizations {
10+
// Authorized operator contracts.
11+
mapping(address => mapping(address => bool)) internal authorizations;
12+
13+
address public delegatedAuthority;
14+
15+
constructor(KeepRegistry _registry) public Authorizations(_registry) {}
16+
17+
function authorizeOperatorContract(
18+
address _operator,
19+
address _operatorContract
20+
) public {
21+
authorizations[_operatorContract][_operator] = true;
22+
}
23+
24+
function isAuthorizedForOperator(
25+
address _operator,
26+
address _operatorContract
27+
) public view returns (bool) {
28+
return authorizations[_operatorContract][_operator];
29+
}
30+
31+
function authorizerOf(address _operator) public view returns (address) {
32+
revert("abstract function");
33+
}
34+
35+
function claimDelegatedAuthority(address delegatedAuthoritySource) public {
36+
delegatedAuthority = delegatedAuthoritySource;
37+
}
38+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
pragma solidity 0.5.17;
2+
3+
import "@keep-network/keep-core/contracts/StakeDelegatable.sol";
4+
5+
/// @title Stake Delegatable Stub
6+
/// @dev This contract is for testing purposes only.
7+
contract StakeDelegatableStub is StakeDelegatable {
8+
mapping(address => uint256) stakes;
9+
10+
mapping(address => address) operatorToOwner;
11+
mapping(address => address payable) operatorToBeneficiary;
12+
mapping(address => address) operatorToAuthorizer;
13+
14+
function setBalance(address _operator, uint256 _balance) public {
15+
stakes[_operator] = _balance;
16+
}
17+
18+
function balanceOf(address _address) public view returns (uint256 balance) {
19+
return stakes[_address];
20+
}
21+
22+
function setOwner(address _operator, address _owner) public {
23+
operatorToOwner[_operator] = _owner;
24+
}
25+
26+
function ownerOf(address _operator) public view returns (address) {
27+
return operatorToOwner[_operator];
28+
}
29+
30+
function setBeneficiary(address _operator, address payable _beneficiary)
31+
public
32+
{
33+
operatorToBeneficiary[_operator] = _beneficiary;
34+
}
35+
36+
function beneficiaryOf(address _operator)
37+
public
38+
view
39+
returns (address payable)
40+
{
41+
return operatorToBeneficiary[_operator];
42+
}
43+
44+
function setAuthorizer(address _operator, address _authorizer) public {
45+
operatorToAuthorizer[_operator] = _authorizer;
46+
}
47+
48+
function authorizerOf(address _operator) public view returns (address) {
49+
return operatorToAuthorizer[_operator];
50+
}
51+
}

0 commit comments

Comments
 (0)