laconicd/tests-solidity/suites/basic/contracts/Counter.sol
Brett Sun c9639c3860
tests: add solidity test suites (#487)
* tests: add solidity test suite

* tests: remove require strings

* Update tests-solidity/init-test-node.sh

* Update tests-solidity/init-test-node.sh

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
2020-09-01 17:16:28 -04:00

25 lines
496 B
Solidity

pragma solidity ^0.5.11;
contract Counter {
uint256 counter = 0;
string internal constant ERROR_TOO_LOW = "COUNTER_TOO_LOW";
event Changed(uint256 counter);
event Added(uint256 counter);
function add() public {
counter++;
emit Added(counter);
emit Changed(counter);
}
function subtract() public {
require(counter > 0, ERROR_TOO_LOW);
counter--;
emit Changed(counter);
}
function getCounter() public view returns (uint256) {
return counter;
}
}