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)
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