Refactor and remove moment.js usages
This commit is contained in:
@ -27,7 +27,7 @@ contract('CappedCrowdsale', function ([_, wallet]) {
|
||||
})
|
||||
|
||||
beforeEach(async function () {
|
||||
this.startTime = latestTime().unix() + duration.weeks(1);
|
||||
this.startTime = latestTime() + duration.weeks(1);
|
||||
this.endTime = this.startTime + duration.weeks(1);
|
||||
|
||||
this.crowdsale = await CappedCrowdsale.new(this.startTime, this.endTime, rate, wallet, cap)
|
||||
|
||||
@ -27,7 +27,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
|
||||
})
|
||||
|
||||
beforeEach(async function () {
|
||||
this.startTime = latestTime().unix() + duration.weeks(1);
|
||||
this.startTime = latestTime() + duration.weeks(1);
|
||||
this.endTime = this.startTime + duration.weeks(1);
|
||||
this.afterEndTime = this.endTime + duration.seconds(1)
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ contract('FinalizableCrowdsale', function ([_, owner, wallet, thirdparty]) {
|
||||
})
|
||||
|
||||
beforeEach(async function () {
|
||||
this.startTime = latestTime().unix() + duration.weeks(1)
|
||||
this.startTime = latestTime() + duration.weeks(1)
|
||||
this.endTime = this.startTime + duration.weeks(1)
|
||||
this.afterEndTime = this.endTime + duration.seconds(1)
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ contract('RefundableCrowdsale', function ([_, owner, wallet, investor]) {
|
||||
})
|
||||
|
||||
beforeEach(async function () {
|
||||
this.startTime = latestTime().unix() + duration.weeks(1)
|
||||
this.startTime = latestTime() + duration.weeks(1)
|
||||
this.endTime = this.startTime + duration.weeks(1)
|
||||
this.afterEndTime = this.endTime + duration.seconds(1)
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ contract('Crowdsale', function ([owner, wallet, investor]) {
|
||||
})
|
||||
|
||||
beforeEach(async function () {
|
||||
this.startTime = latestTime().unix() + duration.weeks(1);
|
||||
this.startTime = latestTime() + duration.weeks(1);
|
||||
this.endTime = this.startTime + duration.weeks(1);
|
||||
this.afterEndTime = this.endTime + duration.seconds(1);
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ contract('TokenTimelock', function ([_, owner, beneficiary]) {
|
||||
|
||||
beforeEach(async function () {
|
||||
this.token = await MintableToken.new({from: owner})
|
||||
this.releaseTime = latestTime().unix() + duration.years(1)
|
||||
this.releaseTime = latestTime() + duration.years(1)
|
||||
this.timelock = await TokenTimelock.new(this.token.address, beneficiary, this.releaseTime)
|
||||
await this.token.mint(this.timelock.address, amount, {from: owner})
|
||||
})
|
||||
|
||||
@ -32,7 +32,7 @@ export default function increaseTime(duration) {
|
||||
* @param target time in seconds
|
||||
*/
|
||||
export function increaseTimeTo(target) {
|
||||
let now = latestTime().unix();
|
||||
let now = latestTime();
|
||||
if (target < now) throw Error(`Cannot increase current time(${now}) to a moment in the past(${target})`);
|
||||
let diff = target - now;
|
||||
return increaseTime(diff);
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
import moment from 'moment'
|
||||
|
||||
// Returns a moment.js instance representing the time of the last mined block
|
||||
// Returns the time of the last mined block in seconds
|
||||
export default function latestTime() {
|
||||
return moment.unix(web3.eth.getBlock('latest').timestamp)
|
||||
return web3.eth.getBlock('latest').timestamp;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user