Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (23 sloc) 1.65 KB

Testing contracts where time is a critical component can be difficult. We use a suite of functions that work with ganache to:

  • query block time
  • increase blockchain time
  • increase block numbers
  • revert blockchain state to a previous snapshot

The majority of the functions we use for this are from the npm package ganache-time-traveler, which was developed by one of AirSwap's developers. We combined this with a couple of web3 time-based functions to create a helper library.

You can find the time.js library on NPM within @airswap/test-utils or on the AirSwap GitHub


For documentation of the following 6 functions, view ganache-time-traveller on NPM or GitHub.







These 6 functions are all available within AirSwap's time.js library along with the following 2 functions:


Returns the latest block timestamp.


Param Type Description
days number The number of days to add to the current time.

Returns the timestamp that is days number of days in the future. Note this does not increase the blockchain to this time, it merely returns the timestamp of that time.

You can’t perform that action at this time.