Skip to content

Commit df61c8b

Browse files
committed
Update Exercise 4 to match files
1 parent 3dc27c4 commit df61c8b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

program-analysis/echidna/exercises/Exercise-4.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ contract Ownable {
2727
}
2828
2929
modifier onlyOwner() {
30-
require(msg.sender == owner, "Ownable: Caller is not the owner");
30+
require(msg.sender == owner, "Ownable: Caller is not the owner.");
3131
_;
3232
}
3333
}
@@ -48,17 +48,20 @@ contract Pausable is Ownable {
4848
}
4949
5050
modifier whenNotPaused() {
51-
require(!_paused, "Pausable: Contract is paused");
51+
require(!_paused, "Pausable: Contract is paused.");
5252
_;
5353
}
5454
}
5555
5656
contract Token is Ownable, Pausable {
5757
mapping(address => uint256) public balances;
5858
59-
function transfer(address to, uint256 value) public whenNotPaused {
60-
balances[msg.sender] -= value;
61-
balances[to] += value;
59+
function transfer(address to, uint256 value) public virtual whenNotPaused {
60+
// unchecked to save gas
61+
unchecked {
62+
balances[msg.sender] -= value;
63+
balances[to] += value;
64+
}
6265
}
6366
}
6467
```
@@ -88,6 +91,10 @@ import "./token.sol";
8891
/// solc-select use 0.8.0
8992
/// echidna program-analysis/echidna/exercises/exercise4/template.sol --contract TestToken --test-mode assertion
9093
/// ```
94+
/// or by providing a config
95+
/// ```
96+
/// echidna program-analysis/echidna/exercises/exercise4/template.sol --contract TestToken --config program-analysis/echidna/exercises/exercise4/config.yaml
97+
/// ```
9198
contract TestToken is Token {
9299
function transfer(address to, uint256 value) public {
93100
// TODO: include `assert(condition)` statements that

0 commit comments

Comments
 (0)