chore: forge init
This commit is contained in:
parent
f22910069a
commit
8549b848b8
5 changed files with 98 additions and 0 deletions
34
onchain/.github/workflows/test.yml
vendored
Normal file
34
onchain/.github/workflows/test.yml
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
name: test
|
||||||
|
|
||||||
|
on: workflow_dispatch
|
||||||
|
|
||||||
|
env:
|
||||||
|
FOUNDRY_PROFILE: ci
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
|
||||||
|
name: Foundry project
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Install Foundry
|
||||||
|
uses: foundry-rs/foundry-toolchain@v1
|
||||||
|
with:
|
||||||
|
version: nightly
|
||||||
|
|
||||||
|
- name: Run Forge build
|
||||||
|
run: |
|
||||||
|
forge --version
|
||||||
|
forge build --sizes
|
||||||
|
id: build
|
||||||
|
|
||||||
|
- name: Run Forge tests
|
||||||
|
run: |
|
||||||
|
forge test -vvv
|
||||||
|
id: test
|
||||||
14
onchain/.gitignore
vendored
Normal file
14
onchain/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
# Compiler files
|
||||||
|
cache/
|
||||||
|
out/
|
||||||
|
|
||||||
|
# Ignores development broadcast logs
|
||||||
|
!/broadcast
|
||||||
|
/broadcast/*/31337/
|
||||||
|
/broadcast/**/dry-run/
|
||||||
|
|
||||||
|
# Docs
|
||||||
|
docs/
|
||||||
|
|
||||||
|
# Dotenv file
|
||||||
|
.env
|
||||||
12
onchain/script/Counter.s.sol
Normal file
12
onchain/script/Counter.s.sol
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
|
pragma solidity ^0.8.13;
|
||||||
|
|
||||||
|
import "forge-std/Script.sol";
|
||||||
|
|
||||||
|
contract CounterScript is Script {
|
||||||
|
function setUp() public {}
|
||||||
|
|
||||||
|
function run() public {
|
||||||
|
vm.broadcast();
|
||||||
|
}
|
||||||
|
}
|
||||||
14
onchain/src/Counter.sol
Normal file
14
onchain/src/Counter.sol
Normal file
|
|
@ -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++;
|
||||||
|
}
|
||||||
|
}
|
||||||
24
onchain/test/Counter.t.sol
Normal file
24
onchain/test/Counter.t.sol
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
function setUp() public {
|
||||||
|
counter = new Counter();
|
||||||
|
counter.setNumber(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testIncrement() public {
|
||||||
|
counter.increment();
|
||||||
|
assertEq(counter.number(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testSetNumber(uint256 x) public {
|
||||||
|
counter.setNumber(x);
|
||||||
|
assertEq(counter.number(), x);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue