I am writing an auction type application with Substrate runtime. In writing test case, how can I fast forward the blockchain time (what's retrieved from <timestamp::Module<T>>::get()
) so I can reach the auction closing time and test the closing logic?
Thanks.
You can just use Timestamp::set_timestamp
to change the timestamp to whatever value you want. e.g. Timestamp::set_timestamp(42);
You can check the tests for srml-timestamp
for examples
Note that this does not trigger any other functions like
on_finalize
oron_initialize
. You will have to do that manually.Tracking issue for fast forward blocks (instead of time): github.com/paritytech/substrate/issues/2818
Additionally, you might need to call
session::rotate_session()
as well.