Foundry init.
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
[profile.default]
|
||||||
|
src = "src"
|
||||||
|
out = "out"
|
||||||
|
libs = ["lib"]
|
||||||
|
|
||||||
|
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
|
pragma solidity ^0.8.13;
|
||||||
|
|
||||||
|
import {Script, console} from "forge-std/Script.sol";
|
||||||
|
import {Counter} from "../src/Counter.sol";
|
||||||
|
|
||||||
|
contract CounterScript is Script {
|
||||||
|
Counter public counter;
|
||||||
|
|
||||||
|
function setUp() public {}
|
||||||
|
|
||||||
|
function run() public {
|
||||||
|
vm.startBroadcast();
|
||||||
|
|
||||||
|
counter = new Counter();
|
||||||
|
|
||||||
|
vm.stopBroadcast();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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++;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
|
pragma solidity ^0.8.13;
|
||||||
|
|
||||||
|
import {Test, console} from "forge-std/Test.sol";
|
||||||
|
import {Counter} from "../src/Counter.sol";
|
||||||
|
|
||||||
|
contract CounterTest is Test {
|
||||||
|
Counter public counter;
|
||||||
|
|
||||||
|
function setUp() public {
|
||||||
|
counter = new Counter();
|
||||||
|
counter.setNumber(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_Increment() public {
|
||||||
|
counter.increment();
|
||||||
|
assertEq(counter.number(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testFuzz_SetNumber(uint256 x) public {
|
||||||
|
counter.setNumber(x);
|
||||||
|
assertEq(counter.number(), x);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user