如何在JavaScript中控制Solana-Test-Test-validator时钟?
我的程序逻辑取决于时钟
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,正如您发现的那样,在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