如何在JavaScript中控制Solana-Test-Test-validator时钟?

发布于 2025-01-22 08:33:31 字数 349 浏览 2 评论 0原文

我的程序逻辑取决于时钟 sysvar。为了正确测试我的代码,我需要“快速”群集超出某个时间点。

我有找到可以使用JavaScript执行此操作,因为我已经有很多JS测试代码 +一个非常方便的JavaScript客户端可以与我的程序进行交互。

solana-test-validator上有---扭曲选项验证器)

I have program logic that depends on the Clock sysvar. In order to properly test my code I need to "fast-forward" the cluster beyond a certain point in time.

I have found that this is possible in Rust but I would like to be able to do this using javascript as I have a lot of js test code already + a very convenient javascript client to interact with my program.

There is the ---warp-slot option on the solana-test-validator but that requires restarting the validator which isn't very convenient (I am using Anchor which manages the validator)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野生奥特曼 2025-01-29 08:33:31

不幸的是,正如您发现的那样,在JavaScript中不可能。您当前唯一的选择是使用- Warp-Slot参数重新启动验证器,在测试环境中这不是很实际。

旁注:这种行为的公关将不胜感激! You'd need to expose some endpoint to tell the validator to move forward, similar to the logic done for the program-test framework: https://github.com/solana-labs/solana/blob/dd15193c69f5292ff566b84837516097bc0b8f57/program-test/src/lib.rs#L1101< /a>

It's unfortunately not possible in JavaScript, as you discovered. Your only option currently is to restart the validator with the --warp-slot argument, which is not very practical in a testing environment.

Side note: a PR for this behavior would be very appreciated! You'd need to expose some endpoint to tell the validator to move forward, similar to the logic done for the program-test framework: https://github.com/solana-labs/solana/blob/dd15193c69f5292ff566b84837516097bc0b8f57/program-test/src/lib.rs#L1101

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文