Skip to content

Commit

Permalink
Time Helpers, add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ßingen committed Jul 30, 2018
1 parent ef93d35 commit 0910f19
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/mocks/TimeHelpersMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
pragma solidity 0.4.18;

import "../../contracts/lib/misc/TimeHelpers.sol";


contract TimeHelpersMock is TimeHelpers {
function getBlockNumberExt() public view returns (uint256) {
return getBlockNumber();
}

function getBlockNumber64Ext() public view returns (uint64) {
return getBlockNumber64();
}

function getTimestampExt() public view returns (uint256) {
return getTimestamp();
}

function getTimestamp64Ext() public view returns (uint64) {
return getTimestamp64();
}
}
15 changes: 15 additions & 0 deletions test/time_helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
contract('TimeHelpers test', accounts => {
let timeHelpersMock

before(async () => {
timeHelpersMock = await artifacts.require('TimeHelpersMock').new()
})

it('checks block number', async () => {
assert.equal((await timeHelpersMock.getBlockNumberExt.call()).toString(), (await timeHelpersMock.getBlockNumber64Ext.call()).toString(), "block number should match")
})

it('checks time stamp', async () => {
assert.equal((await timeHelpersMock.getTimestampExt.call()).toString(), (await timeHelpersMock.getTimestamp64Ext.call()).toString(), "time stamp should match")
})
})

0 comments on commit 0910f19

Please sign in to comment.