Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
refactor(Coinify): remove unnecessary expire function and getTime of …
Browse files Browse the repository at this point in the history
…trade times
  • Loading branch information
Phil London committed Apr 27, 2017
1 parent d603721 commit fb3512e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 22 deletions.
8 changes: 0 additions & 8 deletions src/quote.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ class Quote extends Exchange.Quote {

var expiresAt = new Date(obj.expiryTime);

// Debug, make quote expire in 15 seconds:
// expiresAt = new Date(new Date().getTime() + 15 * 1000);

this._id = obj.id;
this._baseCurrency = obj.baseCurrency;
this._quoteCurrency = obj.quoteCurrency;
Expand Down Expand Up @@ -57,11 +54,6 @@ class Quote extends Exchange.Quote {
return super.getQuote(amount, baseCurrency, quoteCurrency, ['BTC', 'EUR', 'GBP', 'USD', 'DKK'], debug)
.then(getQuote);
}

// QA tool
expire () {
this._expiresAt = new Date(new Date().getTime() + 3 * 1000);
}
}

module.exports = Quote;
6 changes: 3 additions & 3 deletions src/trade.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ class Trade extends Exchange.Trade {
// This log only happens if .set() is called after .debug is set.
console.info('Trade ' + this.id + ' from Coinify API');
}
this._createdAt = new Date(obj.createTime);
this._updatedAt = new Date(obj.updateTime);
this._quoteExpireTime = new Date(obj.quoteExpireTime);
this._createdAt = new Date(obj.createTime).getTime();
this._updatedAt = new Date(obj.updateTime).getTime();
this._quoteExpireTime = new Date(obj.quoteExpireTime).getTime();
this._receiptUrl = obj.receiptUrl;

if (this._inCurrency !== 'BTC') {
Expand Down
8 changes: 0 additions & 8 deletions tests/quote_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,5 @@ describe('Coinify Quote', function () {
expect(q.id).toBe(q._id);
})
);

describe('QA expire()', () =>
it('should set expiration time to 3 seconds in the future', function () {
let originalExpiration = q.expiresAt;
q.expire();
expect(q.expiresAt).not.toEqual(originalExpiration);
})
);
});
});
6 changes: 3 additions & 3 deletions tests/trade_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ describe('Coinify Trade', function () {
trade = new Trade(tradeJSON, api, delegate);
expect(trade.id).toEqual(1142);
expect(trade.iSignThisID).toEqual('05e18928-7b29-4b70-b29e-84cfe9fbc5ac');
expect(trade.quoteExpireTime).toEqual(new Date('2016-08-26T15:10:00.000Z'));
expect(trade.createdAt).toEqual(new Date('2016-08-26T14:53:26.650Z'));
expect(trade.updatedAt).toEqual(new Date('2016-08-26T14:54:00.000Z'));
expect(trade.quoteExpireTime).toEqual(new Date('2016-08-26T15:10:00.000Z').getTime());
expect(trade.createdAt).toEqual(new Date('2016-08-26T14:53:26.650Z').getTime());
expect(trade.updatedAt).toEqual(new Date('2016-08-26T14:54:00.000Z').getTime());
expect(trade.inCurrency).toEqual('USD');
expect(trade.outCurrency).toEqual('BTC');
expect(trade.inAmount).toEqual(4000);
Expand Down

0 comments on commit fb3512e

Please sign in to comment.