Update nexus wiki content

This commit is contained in:
2026-05-03 05:42:06 +08:00
parent 90f3811b83
commit 111bc65b7b
707 changed files with 32306 additions and 7289 deletions

35
wiki/entities/Foundry.md Normal file
View File

@@ -0,0 +1,35 @@
---
title: "Foundry"
type: entity
tags: []
last_updated: 2026-05-01
---
## Overview
Foundry 是最流行的 Solidity 开发框架之一(由 Paradigm 开发),提供 Forge测试、Cast合约交互、ChiselSolidity REPL等工具链。与 Hardhat 相比Foundry 以速度快Rust 实现)、内置 Fuzz 测试和 Invariant 测试著称。
## Key Tools
### Forge
- Solidity 测试框架,类比 Hardhat + Mocha
- 支持 `vm.prank()` / `vm.startPrank()` 模拟调用者
- 支持 `vm.expectRevert()` 验证 revert 行为
- 内置 `testFuzz_*` 模糊测试和 `testInvariant_*` 不变测试
- `forge snapshot` 生成 Gas 消耗快照
### Cast
- 命令行合约交互工具
- 发送交易、调用视图函数、解码事件
- 访问链上数据
### Anvil
- 本地 EVM 测试网络
- 可分叉主网进行集成测试
## 与 Solidity Smart Contract Engineer 的关系
- [[engineering-solidity-smart-contract-engineer]] 要求所有合约配备 Foundry 测试套件,分支覆盖率 >95%
- Foundry 的 Fuzz 测试是发现边界条件和算术漏洞的关键工具
- Gas 快照用于持续跟踪 Gas 优化效果
## Sources
- [[engineering-solidity-smart-contract-engineer]]