编写测试示例
此页面展示了如何为在Blueprint SDK(Sandbox)中创建的FunC合约编写测试。
测试套件为演示合约fireworks构建。Fireworks是一个通过set_first消息初始化运行的智能合约。
通过npm create ton@latest创建一个新的FunC项目后,测试文件tests/contract.spec.ts将自动生成在项目目录中,用于测试合约:
import ...
describe('Fireworks', () => {
...
        expect(deployResult.transactions).toHaveTransaction({
...
        });
});
it('should deploy', async () => {
    // the check is done inside beforeEach
    // blockchain and fireworks are ready to use
});
使用以下命令运行测试:
npx blueprint test
可以通过blockchain.verbosity指定附加选项和vmLogs:
blockchain.verbosity = {
    ...blockchain.verbosity,
    blockchainLogs: true,
    vmLogs: 'vm_logs_full',
    debugLogs: true,
    print: false,
}