Skip to content

Docs: Included foundry specific readme #441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .yarn/install-state.gz
Binary file not shown.
85 changes: 80 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,92 @@ cd push-smart-contracts

3. Install the dependencies:
```sh
npm install
forge install
```

### 🧪 Running Tests
### 🧪 Build the project:
```sh
npx hardhat test
forge build
```
OR
### Testing with Foundry

#### Prerequisites
Ensure you have Foundry installed. If not, install it via:
```sh
curl -L https://foundry.paradigm.xyz | bash
foundryup

```
### Running Tests

1. Running all tests:
```sh
forge test
forge test
```

2. Run specific tests:
```sh
forge test --match-contract <ContractName>
forge test --match-test <TestFunctionName>
```

3. Enable detailed output:
```sh
forge test -vvvv
```

### Example Test File Structure
Tests should be placed in the test/ directory and follow this structure:
```
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {Test} from "forge-std/Test.sol";
import {Your contract name} from "../src/YourContract.sol";

contract YourContractTest is Test {
YourContract yourContract;

function setUp() public {
yourContract = new YourContract();
}

function testExample() public {
assertEq(yourContract.someFunction(), expectedValue);
}
}
```

### Makefile Integration

To streamline development, we recommend using a Makefile for common tasks:

```
.PHONY: install build test clean

install:
@forge install

build:
@forge build

test:
@forge test -vvvv

clean:
@rm -rf out cache
```

### Run commands like this:

```
make install # Install dependencies
make build # Build contracts
make test # Run tests with verbose output
make clean # Clean build artifacts
```


---

## Resources
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"watch": "node scripts/watch.js",
"accounts": "hardhat accounts",
"balance": "hardhat balance",
"send": "hardhat send"
"send": "hardhat send",
"cz": "cz"
},
"dependencies": {
"@nomiclabs/hardhat-ethers": "^2.0.2",
Expand All @@ -41,6 +42,8 @@
},
"devDependencies": {
"@nomicfoundation/hardhat-verify": "^2.0.4",
"commitizen": "^4.3.1",
"cz-git": "^1.11.0",
"hardhat-contract-sizer": "^2.8.0",
"moment": "^2.29.1",
"prettier": "^2.3.2",
Expand Down