diff --git a/.yarn/install-state.gz b/.yarn/install-state.gz new file mode 100644 index 00000000..e078bdf9 Binary files /dev/null and b/.yarn/install-state.gz differ diff --git a/README.md b/README.md index f09b3c44..2fa7ab26 100644 --- a/README.md +++ b/README.md @@ -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 +forge test --match-test +``` + +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 diff --git a/package.json b/package.json index 64065a69..191249b7 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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",