Browse Source

Merge pull request #544 from maraoz/timer-improvement

remove timer test helper
Francisco Giordano 8 years ago
parent
commit
14ae881e26
2 changed files with 4 additions and 18 deletions
  1. 4 3
      test/DayLimit.js
  2. 0 15
      test/helpers/timer.js

+ 4 - 3
test/DayLimit.js

@@ -1,16 +1,17 @@
 'use strict';
 const assertJump = require('./helpers/assertJump');
-const timer = require('./helpers/timer');
+import latestTime from './helpers/latestTime'
+import {increaseTimeTo, duration} from './helpers/increaseTime'
 
 var DayLimitMock = artifacts.require('./helpers/DayLimitMock.sol');
 
 contract('DayLimit', function(accounts) {
-  const day = 60 * 60 * 24;
 
   let dayLimit;
   let initLimit = 10;
 
   beforeEach( async function() {
+    this.startTime = latestTime();
     dayLimit = await DayLimitMock.new(initLimit);
   });
 
@@ -99,7 +100,7 @@ contract('DayLimit', function(accounts) {
     spentToday = await dayLimit.spentToday();
     assert.equal(spentToday, 8);
 
-    await timer(day);
+    await increaseTimeTo(this.startTime + duration.days(1));
 
     await dayLimit.attemptSpend(3);
     spentToday = await dayLimit.spentToday();

+ 0 - 15
test/helpers/timer.js

@@ -1,15 +0,0 @@
-// timer for tests specific to testrpc
-module.exports = s => {
-  return new Promise((resolve, reject) => {
-    web3.currentProvider.sendAsync({
-      jsonrpc: '2.0',
-      method: 'evm_increaseTime',
-      params: [s], // 60 seaconds, may need to be hex, I forget
-      id: new Date().getTime() // Id of the request; anything works, really
-    }, function(err) {
-      if (err) return reject(err);
-      resolve();
-    });
-    //setTimeout(() => resolve(), s * 1000 + 600) // 600ms breathing room for testrpc to sync
-  });
-};