mirror of
git://holbrook.no/eth-faucet
synced 2026-05-27 13:17:57 +02:00
Add tests
This commit is contained in:
@@ -8,16 +8,16 @@ contract EthFacuet {
|
||||
address public registry;
|
||||
address public periodChecker;
|
||||
uint256 public sealState;
|
||||
uint256 public value;
|
||||
uint256 public amount;
|
||||
|
||||
uint8 constant REGISTRY_STATE = 1;
|
||||
uint8 constant PERIODCHECKER_STATE = 2;
|
||||
uint8 constant VALUE_STATE = 4;
|
||||
uint256 constant public maxSealState = 7;
|
||||
|
||||
event FaucetUsed(address indexed _recipient, address indexed _token, uint256 _value);
|
||||
event FaucetFail(address indexed _recipient, address indexed _token, uint256 _value);
|
||||
event FaucetAmountChange(uint256 _value);
|
||||
event FaucetUsed(address indexed _recipient, address indexed _token, uint256 _amount);
|
||||
event FaucetFail(address indexed _recipient, address indexed _token, uint256 _amount);
|
||||
event FaucetAmountChange(uint256 _amount);
|
||||
event FaucetStateChange(uint256 indexed _sealState, address _registry, address _periodChecker);
|
||||
|
||||
constructor() {
|
||||
@@ -32,12 +32,12 @@ contract EthFacuet {
|
||||
return uint256(sealState);
|
||||
}
|
||||
|
||||
function setValue(uint256 _v) public returns(uint256) {
|
||||
function setAmount(uint256 _v) public returns(uint256) {
|
||||
require(msg.sender == owner, 'ERR_NOT_OWNER');
|
||||
require(sealState & VALUE_STATE == 0, 'ERR_SEALED');
|
||||
value = _v;
|
||||
emit FaucetAmountChange(value);
|
||||
return value;
|
||||
amount = _v;
|
||||
emit FaucetAmountChange(amount);
|
||||
return amount;
|
||||
}
|
||||
|
||||
function setPeriodChecker(address _checker) public {
|
||||
@@ -74,11 +74,11 @@ contract EthFacuet {
|
||||
|
||||
(_ok, _result) = registry.call(abi.encodeWithSignature("have(address)", _recipient));
|
||||
if (!_ok) {
|
||||
emit FaucetFail(_recipient, address(0), value);
|
||||
emit FaucetFail(_recipient, address(0), amount);
|
||||
revert('ERR_TRANSFER');
|
||||
}
|
||||
|
||||
emit FaucetUsed(_recipient, address(0), value);
|
||||
emit FaucetUsed(_recipient, address(0), amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -93,16 +93,16 @@ contract EthFacuet {
|
||||
}
|
||||
|
||||
|
||||
function get() public returns(uint256) {
|
||||
check(msg.sender);
|
||||
payable(msg.sender).transfer(value);
|
||||
return value;
|
||||
function gimme() public returns(uint256) {
|
||||
require(check(msg.sender));
|
||||
payable(msg.sender).transfer(amount);
|
||||
return amount;
|
||||
}
|
||||
|
||||
function to(address _recipient) public returns(uint256) {
|
||||
check(_recipient);
|
||||
payable(_recipient).transfer(value);
|
||||
return value;
|
||||
function giveTo(address _recipient) public returns(uint256) {
|
||||
require(check(_recipient));
|
||||
payable(_recipient).transfer(amount);
|
||||
return amount;
|
||||
}
|
||||
|
||||
receive () payable external {
|
||||
|
||||
13
solidity/Makefile
Normal file
13
solidity/Makefile
Normal file
@@ -0,0 +1,13 @@
|
||||
SOLC = /usr/bin/solc
|
||||
|
||||
all:
|
||||
$(SOLC) --bin EthFaucet.sol --evm-version byzantium | awk 'NR>3' > EthFaucet.bin
|
||||
truncate -s -1 EthFaucet.bin
|
||||
$(SOLC) --abi EthFaucet.sol --evm-version byzantium | awk 'NR>3' > EthFaucet.json
|
||||
$(SOLC) --bin PeriodSimple.sol --evm-version byzantium | awk 'NR>3' > PeriodSimple.bin
|
||||
truncate -s -1 PeriodSimple.bin
|
||||
$(SOLC) --abi PeriodSimple.sol --evm-version byzantium | awk 'NR==4' > PeriodSimple.json
|
||||
|
||||
install: all
|
||||
cp -v *{json,bin} ../python/eth_faucet/data/
|
||||
|
||||
Reference in New Issue
Block a user