diff --git a/lib/plugins.js b/lib/plugins.js index 3062db89..f3b8654a 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -30,7 +30,6 @@ var tradeInterval = null; var reapTxInterval = null; var tradesQueue = []; -var dispenseStatuses = {}; // that's basically a constructor exports.init = function init(databaseHandle) { @@ -280,35 +279,6 @@ exports.sendBitcoins = function sendBitcoins(deviceFingerprint, rawTx, cb) { executeTx(deviceFingerprint, rawTx, cb); }; -// sets given status both "locally" (dispenseStatuses) and saves to db -function _setDispenseStatus(deviceFingerprint, tx, status, deposit) { - tx.status = status; - - // No need to set default state again - if (status !== 'noDeposit') - // save to db ASAP - db.changeTxStatus(tx.txId, status, { - hash: tx.txHash - }); - - var fiat = 0; - if (status === 'authorizedDeposit') - fiat = tx.fiat; - - var statusObject = null; - if (status !== 'dispensedDeposit') - statusObject = { - status: status, - txId: tx.txId, - deposit: deposit || 0, - dispenseFiat: fiat, - expectedDeposit: tx.satoshis - }; - - // keep local copy - dispenseStatuses[deviceFingerprint] = statusObject; -} - exports.cashOut = function cashOut(deviceFingerprint, tx, cb) { var tmpInfo = { label: 'TX ' + Date.now(), @@ -324,11 +294,6 @@ exports.cashOut = function cashOut(deviceFingerprint, tx, cb) { }; exports.dispenseAck = function dispenseAck(deviceFingerprint, tx) { - _setDispenseStatus(deviceFingerprint, tx, 'dispensedDeposit'); -}; - -exports.dispenseStatus = function dispenseStatus(deviceFingerprint) { - return dispenseStatuses[deviceFingerprint]; }; exports.fiatBalance = function fiatBalance() { diff --git a/test/plugins.js b/test/plugins.js index 00616ef5..c1761e89 100644 --- a/test/plugins.js +++ b/test/plugins.js @@ -6,14 +6,12 @@ var _ = require('lodash'); var should = require('chai').should(); var mockery = require('mockery'); - var config = require('./mocks/config.json'); var CONFIG = _.cloneDeep(config); function requireFreshConfig() { return _.cloneDeep(CONFIG); } - var walletMock = require('./mocks/wallet'); var tickerMock = require('./mocks/ticker'); var traderMock = require('./mocks/trader'); @@ -26,7 +24,6 @@ mockery.registerMock('lamassu-mockTrader', traderMock); mockery.registerMock('lamassu-mockVerifier', verifierMock); mockery.registerMock('lamassu-mockInfo', infoMock); - describe('Plugins', function() { var plugins = null; @@ -138,7 +135,6 @@ describe('Plugins', function() { }); - describe('Ticker', function() { it('should have called .ticker() at least once', function() { tickerMock.getTickerCalls().should.be.at.least(1); @@ -162,7 +158,6 @@ describe('Plugins', function() { }); }); - describe('Wallet', function() { var db = require('./mocks/db'); @@ -207,7 +202,8 @@ describe('Plugins', function() { satoshis: 1e7 }; - plugins.sendBitcoins(db.FINGERPRINT_NEW, txDetails, function(err, response) { + plugins.sendBitcoins(db.FINGERPRINT_NEW, txDetails, function(err, + response) { should.not.exist(err); should.exist(response); /* jshint expr: true */ @@ -227,7 +223,8 @@ describe('Plugins', function() { toAddress: walletMock.ADDR, satoshis: 1e9 }; - plugins.sendBitcoins(db.FINGERPRINT_FUNDS, txDetails, function(err, txHash) { + plugins.sendBitcoins(db.FINGERPRINT_FUNDS, txDetails, function(err, + txHash) { should.exist(err); err.should.be.instanceof(Error); err.name.should.equal('InsufficientFunds'); @@ -268,4 +265,3 @@ describe('Plugins', function() { describe('Trader', function() {}); }); -