Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes for getting-started.md #258

Merged
merged 4 commits into from
Mar 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ contract MyToken is ERC20 {
Then you can write a `setUp()` function that creates a new token contract with a _symbolic_ initial supply, as follows:
```solidity
import {SymTest} from "halmos-cheatcodes/SymTest.sol";
import {Test} from "forge-std/Test.sol";
import {MyToken} from "../src/MyToken.sol";

contract MyTokenTest is SymTest {
contract MyTokenTest is SymTest, Test {
MyToken token;

function setUp() public {
Expand Down Expand Up @@ -104,7 +106,7 @@ Below is an example symbolic test for the token transfer function:
function check_transfer(address sender, address receiver, uint256 amount) public {
// specify input conditions
vm.assume(receiver != address(0));
vm.assume(token.balance(sender) >= amount);
vm.assume(token.balanceOf(sender) >= amount);
cos marked this conversation as resolved.
Show resolved Hide resolved

// record the current balance of sender and receiver
uint256 balanceOfSender = token.balanceOf(sender);
Expand Down Expand Up @@ -179,7 +181,7 @@ Recall that symbolic tests take into account all possible input combinations. Ho
In our example, the conditions for the valid sender and receiver addresses are specified as follows:
```solidity
vm.assume(receiver != address(0));
vm.assume(token.balance(sender) >= amount);
vm.assume(token.balanceOf(sender) >= amount);
```
Like fuzz tests, any input combinations that don't satisfy the `assume()` conditions are disregarded. This means that, after executing the above `assume()` statements, only the input combinations in which the receiver is non-zero and the sender has sufficient balance are considered. Other input combinations that violate these conditions are ignored.

Expand Down
Loading