Skip to content

Commit

Permalink
docs: small fixes for getting-started.md (a16z#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
cos authored and fubuloubu committed Apr 11, 2024
1 parent f5e77fc commit 76eaa16
Showing 1 changed file with 5 additions and 3 deletions.
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);
// 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

0 comments on commit 76eaa16

Please sign in to comment.