Skip to content
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
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,27 @@
- [LockstakeEngine multicall](https://etherscan.io/tx/0x4b049eef5530930673ed21c3c7b4c47daceb3ee492c1d8f2c86d0623965b43c5)
- [LockstakeEngine getReward + lock](https://etherscan.io/tx/0x2b85425949094b36528c92ee6b913974f374a1a7399ed546036148783b460c6b)
- [VoteDelegateFactory create](https://etherscan.io/tx/0x1cf5f9999f05343cc8d3e6afaa392bf8a00824b1d972bc3bca9371d212f6286c)
- [Sky buy back](https://etherscan.io/tx/0x7a1d70e7a0e989cdaca487cc5ff04dc8ae042dbf44f6f18b021ff54deb1f0f74)
## Running Tests

- TODO: update to sol 0.8.34
Tests require a connection to Ethereum mainnet to fork and test against real state.

### Setup

1. Get an Ethereum RPC URL:
- [Alchemy](https://www.alchemy.com/) (recommended)
- [Infura](https://www.infura.io/)
- Local Anvil instance

2. Configure the fork URL:
```bash
cd foundry
cp .env.sample .env
# Edit .env and add your RPC URL
```

3. Run tests:
```bash
forge test
```

All test contracts inherit from `BaseTest` which automatically handles fork setup when `FORK_URL` is configured.
4 changes: 3 additions & 1 deletion foundry/.env.sample
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
FORK_URL=
# Ethereum mainnet RPC URL for test forking
# Required to run tests against mainnet state (Alchemy, Infura, etc.)
FORK_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY
15 changes: 15 additions & 0 deletions foundry/test/BaseTest.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.8.33;

import {Test} from "forge-std/Test.sol";

/// @notice Base test contract that handles mainnet fork setup
/// Automatically forks Ethereum mainnet if FORK_URL is set
contract BaseTest is Test {
function setUp() public virtual {
string memory forkUrl = vm.envString("FORK_URL");
if (bytes(forkUrl).length > 0) {
vm.createSelectFork(forkUrl);
}
}
}