完整的、可运行的示例,演示 litesvm-go 的用法。每个示例都是一个独立的 Go 测试,可直接放入包中并使用 go test 运行。
SOL 转账
构建并发送 System Program 转账
账户设置
初始化测试账户的 seed 及程序数据状态
程序测试
加载并测试自定义 SBF 程序
基于时间的测试
使用 WarpToSlot / SetClock 测试时间相关逻辑
运行示例
# 1) Initialize a Go module (skip if you already have a go.mod)go mod init mytest# 2) Add the dependencies to your Go projectgo get github.com/LiteSVM/litesvm-gogo get github.com/gagliardetto/solana-go# 3) Drop an example into a _test.go file and rungo test ./...
在 Alpine / musl 环境下,请在 go test 命令中添加 -tags musl,以链接正确的预编译归档文件。
如需独立的命令行示例(无需测试运行器),请参阅 litesvm-go 仓库中的
examples/transfer/main.go。
Is this page helpful?