-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathassert_immediate.sol
45 lines (34 loc) · 1.34 KB
/
assert_immediate.sol
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
pragma solidity ^0.8.0;
// This contract includes a function that we will call from TestContract.
contract AnotherContract {
// This function doesn't need to do anything specific for this example.
function externalFunction() public pure returns (string memory) {
return "External function called";
}
}
// This contract ensures the fuzzer can encounter an immediate assertion failure.
contract TestContract {
AnotherContract public anotherContract;
event ValueReceived(uint indexed value, uint second_val);
event ValueNonIndexedReceived(uint firstval, uint secondval);
function internalFunction() public returns (string memory) {
anotherContract.externalFunction();
return "Internal function called";
}
// Deploy AnotherContract within the TestContract
constructor() {
// internalFunction();
anotherContract = new AnotherContract();
}
function callingMeFails(uint value) public {
// Call internalFunction()
internalFunction();
// Call the external function in AnotherContract.
anotherContract.externalFunction();
uint second_val = 2+12;
emit ValueReceived(value, second_val);
emit ValueNonIndexedReceived(111+111, 444+444);
// ASSERTION: We always fail when you call this function.
assert(false);
}
}