Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/brevityPublic template

Commitf6f9907

Browse files
committed
chore: forge init
0 parents  commitf6f9907

File tree

7 files changed

+104
-0
lines changed

7 files changed

+104
-0
lines changed

‎.github/workflows/test.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name:test
2+
3+
on:workflow_dispatch
4+
5+
env:
6+
FOUNDRY_PROFILE:ci
7+
8+
jobs:
9+
check:
10+
strategy:
11+
fail-fast:true
12+
13+
name:Foundry project
14+
runs-on:ubuntu-latest
15+
steps:
16+
-uses:actions/checkout@v3
17+
with:
18+
submodules:recursive
19+
20+
-name:Install Foundry
21+
uses:foundry-rs/foundry-toolchain@v1
22+
with:
23+
version:nightly
24+
25+
-name:Run Forge build
26+
run:|
27+
forge --version
28+
forge build --sizes
29+
id:build
30+
31+
-name:Run Forge tests
32+
run:|
33+
forge test -vvv
34+
id:test

‎.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Compiler files
2+
cache/
3+
out/
4+
5+
# Ignores development broadcast logs
6+
!/broadcast
7+
/broadcast/*/31337/
8+
/broadcast/**/dry-run/
9+
10+
# Docs
11+
docs/
12+
13+
# Dotenv file
14+
.env

‎README.md

Whitespace-only changes.

‎foundry.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[profile.default]
2+
src ="src"
3+
out ="out"
4+
libs = ["lib"]
5+
6+
# See more config options https://github.com/foundry-rs/foundry/tree/master/config

‎script/Counter.s.sol

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity^0.8.13;
3+
4+
import"forge-std/Script.sol";
5+
6+
contractCounterScriptisScript {
7+
function setUp()public {}
8+
9+
function run()public {
10+
vm.broadcast();
11+
}
12+
}

‎src/Counter.sol

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity^0.8.13;
3+
4+
contractCounter {
5+
uint256public number;
6+
7+
function setNumber(uint256newNumber)public {
8+
number= newNumber;
9+
}
10+
11+
function increment()public {
12+
number++;
13+
}
14+
}

‎test/Counter.t.sol

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity^0.8.13;
3+
4+
import"forge-std/Test.sol";
5+
import"../src/Counter.sol";
6+
7+
contractCounterTestisTest {
8+
Counterpublic counter;
9+
10+
function setUp()public {
11+
counter=newCounter();
12+
counter.setNumber(0);
13+
}
14+
15+
function testIncrement()public {
16+
counter.increment();
17+
assertEq(counter.number(),1);
18+
}
19+
20+
function testSetNumber(uint256x)public {
21+
counter.setNumber(x);
22+
assertEq(counter.number(), x);
23+
}
24+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp