-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathasserter.sol
More file actions
46 lines (37 loc) · 941 Bytes
/
asserter.sol
File metadata and controls
46 lines (37 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
pragma solidity 0.8;
// asserts in many ways
contract asserter {
event AssertionFailed(string msg);
event AssertionFailed(uint256);
event AssertionFailed();
event RandomEvent();
event Panic(uint256);
function random_event() public {
emit RandomEvent();
}
function panic_event() public {
emit Panic(0x11);
}
function underflow(uint256 i) public returns (uint256) {
require(i != 0);
uint256 x = 0;
x = x - i;
return x;
}
function builtin_assert(bool x) public returns (bool) {
assert(false);
return x;
}
function event_with_string(bool x) public {
emit AssertionFailed("bar");
revert();
}
function event_only(bool x) public {
emit AssertionFailed();
revert();
}
function event_with_code(bool x) public {
emit AssertionFailed(0x42);
revert();
}
}