Search code examples
nearprotocol

Updating the block_timestamp after each function call


I want to update the block_timestamp after each function call. This is how I am updating the context after each function call in tests.

#[test]
    fn set_then_get_greeting() {
        let context = get_context(vec![], false);
        testing_env!(context);
        let mut contract = Welcome::new();
        contract.set_record("7dd".to_owned());
        let context = get_context(vec![], false);
        testing_env!(context);
        contract.update_record("7dd".to_owned());
        
    }

But on state update it gives follow error:

panicked at 'called `Result::unwrap()` on an `Err` value: InconsistentStateError(IntegerOverflow)'

How can I update the block_timestamp with every function call?

Code: https://gateway.ipfs.io/ipfs/QmTNHuRryBoDmTp7wqmNsCcJW8Gu7G6dz3cE3F4pynv6V9


Solution

  • The error was because storage_usage was set to zero. Setting it to large number solves it.

    https://github.com/near/near-sdk-rs/issues/216