mirror of https://github.com/crytic/slither
parent
46d0cb13db
commit
7045cb82d8
@ -1,66 +1,6 @@ |
||||
## Foundry |
||||
|
||||
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** |
||||
|
||||
Foundry consists of: |
||||
|
||||
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools). |
||||
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data. |
||||
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network. |
||||
- **Chisel**: Fast, utilitarian, and verbose solidity REPL. |
||||
|
||||
## Documentation |
||||
|
||||
https://book.getfoundry.sh/ |
||||
|
||||
## Usage |
||||
|
||||
### Build |
||||
|
||||
```shell |
||||
$ forge build |
||||
``` |
||||
|
||||
### Test |
||||
|
||||
```shell |
||||
$ forge test |
||||
``` |
||||
|
||||
### Format |
||||
|
||||
```shell |
||||
$ forge fmt |
||||
``` |
||||
|
||||
### Gas Snapshots |
||||
|
||||
```shell |
||||
$ forge snapshot |
||||
``` |
||||
|
||||
### Anvil |
||||
|
||||
```shell |
||||
$ anvil |
||||
``` |
||||
|
||||
### Deploy |
||||
|
||||
```shell |
||||
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key> |
||||
``` |
||||
|
||||
### Cast |
||||
|
||||
```shell |
||||
$ cast <subcommand> |
||||
``` |
||||
|
||||
### Help |
||||
# Counter |
||||
|
||||
Init using : |
||||
```shell |
||||
$ forge --help |
||||
$ anvil --help |
||||
$ cast --help |
||||
forge install foundry-rs/forge-std |
||||
``` |
@ -0,0 +1,14 @@ |
||||
// SPDX-License-Identifier: UNLICENSED |
||||
pragma solidity ^0.8.13; |
||||
|
||||
contract Counter { |
||||
uint256 public number; |
||||
|
||||
function setNumber(uint256 newNumber) public { |
||||
number = newNumber; |
||||
} |
||||
|
||||
function increment() public { |
||||
number++; |
||||
} |
||||
} |
@ -1,8 +0,0 @@ |
||||
// SPDX-License-Identifier: UNLICENSED |
||||
pragma solidity ^0.8.0; |
||||
|
||||
contract Vault { |
||||
constructor(){ |
||||
|
||||
} |
||||
} |
@ -0,0 +1,36 @@ |
||||
// SPDX-License-Identifier: UNLICENSED |
||||
pragma solidity ^0.8.13; |
||||
|
||||
import "forge-std/Test.sol"; |
||||
import "../src/Counter.sol"; |
||||
|
||||
contract CounterTest is Test { |
||||
Counter public counter; |
||||
|
||||
address public alice = address(0x42); |
||||
address public bob = address(0x43); |
||||
|
||||
function difficulty(uint256 value) public { |
||||
// empty |
||||
} |
||||
|
||||
function setUp() public { |
||||
counter = new Counter(); |
||||
counter.setNumber(0); |
||||
|
||||
vm.deal(alice, 1 ether); |
||||
vm.deal(bob, 2 ether); |
||||
|
||||
difficulty(1); |
||||
} |
||||
|
||||
function testIncrement() public { |
||||
vm.prank(alice); |
||||
counter.increment(); |
||||
assertEq(counter.number(), 1); |
||||
|
||||
vm.prank(bob); |
||||
counter.increment(); |
||||
assertEq(counter.number(), 2); |
||||
} |
||||
} |
@ -1,32 +0,0 @@ |
||||
// SPDX-License-Identifier: UNLICENSED |
||||
pragma solidity ^0.8.0; |
||||
|
||||
import "forge-std/Test.sol"; |
||||
import "../src/Vault.sol"; |
||||
|
||||
contract VaultTest is Test { |
||||
|
||||
Vault public vault; |
||||
|
||||
address public alice = address(0x42); |
||||
|
||||
function broadcast() pure public {} |
||||
|
||||
function setUp() public { |
||||
vm.prank(alice); |
||||
vm.deal(alice, 1000 ether); |
||||
|
||||
uint256 value = 123; |
||||
|
||||
vm.warp(1641070800); |
||||
vm.roll(100); |
||||
vm.fee(25 gwei); |
||||
|
||||
// Not a cheatcode |
||||
broadcast(); |
||||
} |
||||
|
||||
function test_deal() public { |
||||
|
||||
} |
||||
} |
Loading…
Reference in new issue