Browse Source

remove timer

Manuel Araoz 8 years ago
parent
commit
7dd0ee6212
2 changed files with 4 additions and 31 deletions
  1. 4 2
      test/DayLimit.js
  2. 0 29
      test/helpers/timer.js

+ 4 - 2
test/DayLimit.js

@@ -1,6 +1,7 @@
 'use strict';
 'use strict';
 const assertJump = require('./helpers/assertJump');
 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');
 var DayLimitMock = artifacts.require('./helpers/DayLimitMock.sol');
 
 
@@ -11,6 +12,7 @@ contract('DayLimit', function(accounts) {
   let initLimit = 10;
   let initLimit = 10;
 
 
   beforeEach( async function() {
   beforeEach( async function() {
+    this.startTime = latestTime();
     dayLimit = await DayLimitMock.new(initLimit);
     dayLimit = await DayLimitMock.new(initLimit);
   });
   });
 
 
@@ -99,7 +101,7 @@ contract('DayLimit', function(accounts) {
     spentToday = await dayLimit.spentToday();
     spentToday = await dayLimit.spentToday();
     assert.equal(spentToday, 8);
     assert.equal(spentToday, 8);
 
 
-    await timer(day);
+    await increaseTimeTo(this.startTime + duration.days(1));
 
 
     await dayLimit.attemptSpend(3);
     await dayLimit.attemptSpend(3);
     spentToday = await dayLimit.spentToday();
     spentToday = await dayLimit.spentToday();

+ 0 - 29
test/helpers/timer.js

@@ -1,29 +0,0 @@
-'use strict';
-
-// timer for tests specific to testrpc
-// s is the amount of seconds to advance
-// if account is provided, will send a transaction from that account to force testrpc to mine the block
-module.exports = (s) => {
-  return new Promise((resolve, reject) => {
-    web3.currentProvider.sendAsync({
-      jsonrpc: '2.0', 
-      method: 'evm_increaseTime',
-      params: [s], 
-      id: new Date().getTime()
-    }, function(err) {
-      if (err) {
-        return reject(err);
-      }
-      web3.currentProvider.sendAsync({
-        jsonrpc: '2.0', 
-        method: 'evm_mine',
-        id: new Date().getTime()
-      }, (err, result) => {
-        if (err) {
-          return reject(err);
-        }
-        resolve(result);
-      });
-    });
-  });
-};