-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
agreements: implement intergration tests
- Loading branch information
1 parent
4e58952
commit fea4106
Showing
15 changed files
with
549 additions
and
57 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
43 changes: 43 additions & 0 deletions
43
apps/agreement/contracts/test/mocks/TokenBalanceOracle.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,43 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "@aragon/os/contracts/acl/IACLOracle.sol"; | ||
import "@aragon/os/contracts/lib/token/ERC20.sol"; | ||
|
||
|
||
contract TokenBalanceOracle is IACLOracle { | ||
string private constant ERROR_SENDER_ZERO = "TOKEN_BALANCE_ORACLE_SENDER_ZERO"; | ||
string private constant ERROR_SENDER_TOO_BIG = "TOKEN_BALANCE_ORACLE_SENDER_TOO_BIG"; | ||
string private constant ERROR_SENDER_MISSING = "TOKEN_BALANCE_ORACLE_SENDER_MISSING"; | ||
string private constant ERROR_TOKEN_NOT_CONTRACT = "TOKEN_BALANCE_ORACLE_TOKEN_NOT_CONTRACT"; | ||
|
||
uint8 private constant ORACLE_PARAM_ID = 203; | ||
|
||
enum Op { NONE, EQ, NEQ, GT, LT, GTE, LTE, RET, NOT, AND, OR, XOR, IF_ELSE } | ||
|
||
ERC20 public token; | ||
uint256 public minBalance; | ||
|
||
constructor(ERC20 _token, uint256 _minBalance) public { | ||
token = _token; | ||
minBalance = _minBalance; | ||
} | ||
|
||
function canPerform(address, address, bytes32, uint256[] _how) external view returns (bool) { | ||
require(_how.length > 0, ERROR_SENDER_MISSING); | ||
require(_how[0] < 2**160, ERROR_SENDER_TOO_BIG); | ||
require(_how[0] != 0, ERROR_SENDER_ZERO); | ||
|
||
address sender = address(_how[0]); | ||
|
||
uint256 senderBalance = token.balanceOf(sender); | ||
return senderBalance >= minBalance; | ||
} | ||
|
||
function getPermissionParam() external view returns (uint256) { | ||
return _paramsTo256(ORACLE_PARAM_ID, uint8(Op.EQ), uint240(address(this))); | ||
} | ||
|
||
function _paramsTo256(uint8 _id,uint8 _op, uint240 _value) private pure returns (uint256) { | ||
return (uint256(_id) << 248) + (uint256(_op) << 240) + _value; | ||
} | ||
} |
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
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
Oops, something went wrong.