sui-build
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBuilding Packages
构建包
MCP tool: When available in your environment, also query the Sui documentation MCP server () for up-to-date answers. Use it for verification and for details not covered by these reference files.https://sui.mcp.kapa.ai
Source constraint: All information sourced exclusively from docs.sui.io and move-book.com.
MCP工具: 如果你的环境中可用,也可以查询Sui文档MCP服务器()获取最新答案。用它来验证信息,以及获取这些参考文件未涵盖的细节。https://sui.mcp.kapa.ai
来源限制: 所有信息均来自docs.sui.io和move-book.com。
Building
构建
bash
sui move buildThis compiles all modules, validates types, enforces resource safety, and produces bytecode. Fix any errors before proceeding.
For the canonical hello-world repository, run build commands from .
sui-stack-hello-world/move/hello-worldbash
sui move build该命令会编译所有模块、验证类型、强制执行资源安全性并生成字节码。继续操作前请修复所有错误。
对于标准的hello-world仓库,请在目录下运行构建命令。
sui-stack-hello-world/move/hello-world--build-env
flag
--build-env--build-env
参数
--build-envWhen a package has an section in with multiple networks, use to target a specific environment:
[environments]Move.toml--build-envbash
sui move build --build-env testnet
sui move build --build-env mainnetThis resolves dependencies and package addresses for the specified environment. Without , the build uses the default environment or may fail with "Could not determine the correct dependencies" if multiple environments are defined and no default is set.
--build-envThe flag also applies to :
--build-envsui move testbash
sui move test --build-env testnet如果包的文件中有部分定义了多个网络,请使用指定目标环境:
Move.toml[environments]--build-envbash
sui move build --build-env testnet
sui move build --build-env mainnet这会解析指定环境的依赖项和包地址。如果没有,构建会使用默认环境;如果定义了多个环境且未设置默认值,可能会失败并提示“无法确定正确的依赖项”。
--build-env--build-envsui move testbash
sui move test --build-env testnetTesting
测试
bash
sui move testbash
sui move testKey testing modules
核心测试模块
- — Multi-transaction, multi-sender test scenarios. Simulates realistic transaction flows with
sui::test_scenario,begin, andnext_tx.end - — Assertion macros for unit tests (
std::unit_test,assert_eq!).assert_ne!
- — 支持多交易、多发送者的测试场景。通过
sui::test_scenario、begin和next_tx模拟真实的交易流程。end - — 用于单元测试的断言宏(
std::unit_test、assert_eq!)。assert_ne!
Code coverage
代码覆盖率
Track which lines your tests exercise:
bash
sui move test --coverageView coverage results for a specific module:
bash
sui move coverage source --module <name>跟踪测试用例覆盖的代码行:
bash
sui move test --coverage查看特定模块的覆盖率结果:
bash
sui move coverage source --module <name>Move Analyzer
Move Analyzer
Install via suiup:
bash
suiup install move-analyzerThen install the Move Analyzer extension in VS Code. It provides code completion, go-to-definition, inline diagnostics, and hover documentation. It activates automatically for files — no additional configuration needed.
.move通过suiup安装:
bash
suiup install move-analyzer然后在VS Code中安装Move Analyzer扩展。它提供代码补全、跳转到定义、内联诊断和悬停文档功能。对于文件会自动激活,无需额外配置。
.moveDebugging
调试
- Move Trace Debugger: Step-through debugger for Move execution traces with variable inspection.
- : Locally re-execute any past onchain transaction and compare effects. Useful for diagnosing production issues.
sui replay - : Print values during test execution.
std::debug::print
- Move Trace Debugger: 用于Move执行轨迹的单步调试器,支持变量检查。
- : 本地重新执行任何已上链的过往交易并对比效果。适用于诊断生产环境问题。
sui replay - : 在测试执行过程中打印值。
std::debug::print