Currently, in the ink test environment (ink_env::test), the default block time is 6 (see https://github.com/paritytech/ink/blame/50b32f4e49d4072f3d28009eb517475b68bec56b/crates/engine/src/ext.rs#L147) as mentionned in the code, this is arbitrary, but this value is not close to any real value (as it is expressed in ms...)

So currently, to do some testing when I need to test timestamps from the environment I have to do something like this :

        fn sign_up_after_end_of_sign_up_period_returns_error() {

            // preparing the test

            //default block time is 6 (in ms)
            for _ in 0..10000 {

            //acting and asserting the test

I wonder if there is a way to (simply) override the DefaultEnvironment's blocktime without to creating my own test environment type just to control that value.

This is because it would make sense in my tests to use the block_time value (that cannot be extracted from ink_env::test). To have a more precise way to advance blocks and test the usage of the block timestamp.

  • 1
    It's not yet possible, but we can implement it. I've created this issue for it: github.com/paritytech/ink/issues/1713.
    – cmichi
    Mar 14, 2023 at 10:03
  • 1
    Wow, thanks a lot. If I have some time to spare, I'll definitly open a PR with an implementation for it.
    – Cromm
    Mar 14, 2023 at 12:26

1 Answer 1


We just published ink! 4.1. It allows for this feature now.

The feature was actually added by the very own original poster :-). So I hope he accepts this as a solution!

let new_block_timestamp: u64 = 1000;
  • 1
    I will definitely use it in my tests :)
    – Cromm
    Mar 30, 2023 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.