Przeglądaj źródła

Refactor and remove moment.js usages

Jakub Wojciechowski 8 lat temu
rodzic
commit
e86ac90853

+ 1 - 1
test/CappedCrowdsale.js

@@ -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)

+ 1 - 1
test/Crowdsale.js

@@ -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)
 

+ 1 - 1
test/FinalizableCrowdsale.js

@@ -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)
 

+ 1 - 1
test/RefundableCrowdsale.js

@@ -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)
 

+ 1 - 1
test/SampleCrowdsale.js

@@ -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);
 

+ 1 - 1
test/TokenTimelock.js

@@ -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})
   })

+ 1 - 1
test/helpers/increaseTime.js

@@ -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);

+ 2 - 4
test/helpers/latestTime.js

@@ -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;
 }