Merge pull request #28 from chester1000/tests-cleanup
test(cleanup): unused tests removed
This commit is contained in:
commit
920f55e4bc
3 changed files with 0 additions and 314 deletions
|
|
@ -1,125 +0,0 @@
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
|
||||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
||||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var async = require('async');
|
|
||||||
var hock = require('hock');
|
|
||||||
var createServer = require('../helpers/create-https-server.js');
|
|
||||||
var assert = require('chai').assert;
|
|
||||||
|
|
||||||
var LamassuConfig = require('lamassu-config');
|
|
||||||
var con = 'psql://lamassu:lamassu@localhost/lamassu';
|
|
||||||
var config = new LamassuConfig(con);
|
|
||||||
|
|
||||||
var fnTable = {};
|
|
||||||
|
|
||||||
var app = {
|
|
||||||
get: function(route, fn) {
|
|
||||||
fnTable[route] = fn;
|
|
||||||
},
|
|
||||||
post: function(route, fn) {
|
|
||||||
fnTable[route] = fn;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var cfg;
|
|
||||||
var port;
|
|
||||||
|
|
||||||
var blockchainMock = hock.createHock();
|
|
||||||
|
|
||||||
// blockchain info
|
|
||||||
var guid = '3acf1633-db4d-44a9-9013-b13e85405404';
|
|
||||||
var pwd = 'baz';
|
|
||||||
var bitAddr = '1LhkU2R8nJaU8Zj6jB8VjWrMpvVKGqCZ64';
|
|
||||||
|
|
||||||
|
|
||||||
describe('send test', function() {
|
|
||||||
|
|
||||||
beforeEach(function(done) {
|
|
||||||
|
|
||||||
async.parallel({
|
|
||||||
blockchain: async.apply(createServer, blockchainMock.handler),
|
|
||||||
config: function(cb) {
|
|
||||||
config.load(cb);
|
|
||||||
}
|
|
||||||
}, function(err, results) {
|
|
||||||
assert.isNull(err);
|
|
||||||
|
|
||||||
cfg = results.config;
|
|
||||||
port = results.blockchain.address().port;
|
|
||||||
|
|
||||||
cfg.exchanges.plugins.current.transfer = 'blockchain';
|
|
||||||
cfg.exchanges.plugins.settings.blockchain = {
|
|
||||||
host: 'localhost',
|
|
||||||
port: results.blockchain.address().port,
|
|
||||||
rejectUnauthorized: false,
|
|
||||||
password: pwd,
|
|
||||||
fromAddress: bitAddr,
|
|
||||||
guid: guid
|
|
||||||
};
|
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should send to blockchain', function(done) {
|
|
||||||
this.timeout(1000000);
|
|
||||||
|
|
||||||
var amount= 100000000;
|
|
||||||
|
|
||||||
var address_reponse = {
|
|
||||||
'hash160':'660d4ef3a743e3e696ad990364e555c271ad504b',
|
|
||||||
'address': bitAddr,
|
|
||||||
'n_tx': 1,
|
|
||||||
'n_unredeemed': 1,
|
|
||||||
'total_received': 0,
|
|
||||||
'total_sent': 0,
|
|
||||||
'final_balance': 0,
|
|
||||||
'txs': []
|
|
||||||
};
|
|
||||||
|
|
||||||
var payment_response = {
|
|
||||||
'message': 'Sent 0.1 BTC to 1LhkU2R8nJaU8Zj6jB8VjWrMpvVKGqCZ64',
|
|
||||||
'tx_hash': 'f322d01ad784e5deeb25464a5781c3b20971c1863679ca506e702e3e33c18e9c',
|
|
||||||
'notice': 'Some funds are pending confirmation and cannot be spent yet (Value 0.001 BTC)'
|
|
||||||
};
|
|
||||||
|
|
||||||
blockchainMock
|
|
||||||
.get('/address/1LhkU2R8nJaU8Zj6jB8VjWrMpvVKGqCZ64?format=json&limit=10&password=baz')
|
|
||||||
.reply(200, address_reponse)
|
|
||||||
.post('/merchant/3acf1633-db4d-44a9-9013-b13e85405404/payment?to=1LhkU2R8nJaU8Zj6jB8VjWrMpvVKGqCZ64&amount=100000000&from=1LhkU2R8nJaU8Zj6jB8VjWrMpvVKGqCZ64&password=baz')
|
|
||||||
.reply(200, payment_response);
|
|
||||||
|
|
||||||
|
|
||||||
var api = require('../../lib/protocol/atm-api');
|
|
||||||
api.init(app, cfg);
|
|
||||||
|
|
||||||
var params = {
|
|
||||||
body: {
|
|
||||||
address: bitAddr,
|
|
||||||
satoshis: amount
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
setTimeout(function() {
|
|
||||||
fnTable['/send'](params, {json: function(result) {
|
|
||||||
assert.isNull(result.err);
|
|
||||||
assert.equal(payment_response.tx_hash, result.results);
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, 2000);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -1,119 +0,0 @@
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
|
||||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
||||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var hock = require('hock');
|
|
||||||
var async = require('async');
|
|
||||||
var createServer = require('../helpers/create-https-server.js');
|
|
||||||
var assert = require('chai').assert;
|
|
||||||
|
|
||||||
var LamassuConfig = require('lamassu-config');
|
|
||||||
var con = 'psql://lamassu:lamassu@localhost/lamassu';
|
|
||||||
var config = new LamassuConfig(con);
|
|
||||||
|
|
||||||
var cfg;
|
|
||||||
|
|
||||||
var blockchainMock = hock.createHock();
|
|
||||||
var bitpayMock = hock.createHock();
|
|
||||||
|
|
||||||
var jsonquest = require('jsonquest');
|
|
||||||
var express = require('express');
|
|
||||||
var app = express();
|
|
||||||
var testPort = 4000;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
describe('ticker test', function(){
|
|
||||||
|
|
||||||
beforeEach(function(done) {
|
|
||||||
|
|
||||||
app.listen(testPort);
|
|
||||||
|
|
||||||
async.parallel({
|
|
||||||
blockchain: async.apply(createServer, blockchainMock.handler),
|
|
||||||
bitpay: async.apply(createServer, bitpayMock.handler),
|
|
||||||
config: config.load.bind(config)
|
|
||||||
}, function(err, results) {
|
|
||||||
assert.isNull(err);
|
|
||||||
|
|
||||||
cfg = results.config;
|
|
||||||
|
|
||||||
cfg.exchanges.settings.commission = 1;
|
|
||||||
|
|
||||||
cfg.exchanges.plugins.current.ticker = 'bitpay';
|
|
||||||
cfg.exchanges.plugins.current.trade = null;
|
|
||||||
cfg.exchanges.plugins.settings.bitpay = {
|
|
||||||
host: 'localhost',
|
|
||||||
port: results.bitpay.address().port,
|
|
||||||
rejectUnauthorized: false
|
|
||||||
};
|
|
||||||
|
|
||||||
cfg.exchanges.plugins.current.transfer = 'blockchain';
|
|
||||||
cfg.exchanges.plugins.settings.blockchain = {
|
|
||||||
host: 'localhost',
|
|
||||||
port: results.blockchain.address().port,
|
|
||||||
rejectUnauthorized: false,
|
|
||||||
password: 'baz',
|
|
||||||
fromAddress: '1LhkU2R8nJaU8Zj6jB8VjWrMpvVKGqCZ64',
|
|
||||||
guid: '3acf1633-db4d-44a9-9013-b13e85405404'
|
|
||||||
};
|
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('should read ticker data from bitpay', function(done) {
|
|
||||||
this.timeout(1000000);
|
|
||||||
|
|
||||||
bitpayMock
|
|
||||||
.get('/api/rates')
|
|
||||||
.reply(200, [
|
|
||||||
{ code: 'EUR', rate: 1337 },
|
|
||||||
{ code: 'USD', rate: 100 }
|
|
||||||
]);
|
|
||||||
|
|
||||||
blockchainMock
|
|
||||||
.get('/merchant/3acf1633-db4d-44a9-9013-b13e85405404/address_balance?address=1LhkU2R8nJaU8Zj6jB8VjWrMpvVKGqCZ64&confirmations=0&password=baz')
|
|
||||||
.reply(200, { balance: 100000000, total_received: 100000000 })
|
|
||||||
.get('/merchant/3acf1633-db4d-44a9-9013-b13e85405404/address_balance?address=1LhkU2R8nJaU8Zj6jB8VjWrMpvVKGqCZ64&confirmations=1&password=baz')
|
|
||||||
.reply(200, { balance: 100000000, total_received: 100000000 });
|
|
||||||
// That's 1 BTC.
|
|
||||||
|
|
||||||
var api = require('../../lib/protocol/atm-api');
|
|
||||||
api.init(app, cfg);
|
|
||||||
|
|
||||||
// let ticker rate fetch finish...
|
|
||||||
setTimeout(function() {
|
|
||||||
jsonquest({
|
|
||||||
host: 'localhost',
|
|
||||||
port: testPort,
|
|
||||||
path: '/poll/USD',//:currency
|
|
||||||
method: 'GET',
|
|
||||||
protocol: 'http'
|
|
||||||
}, function (err, res, body) {
|
|
||||||
assert.isNull(err);
|
|
||||||
assert.equal(res.statusCode, 200);
|
|
||||||
|
|
||||||
assert.isNull(body.err);
|
|
||||||
assert.equal(Number(body.rate) > 0, true);
|
|
||||||
console.log(100 / cfg.exchanges.settings.lowBalanceMargin, body.fiat);
|
|
||||||
assert.equal(body.fiat, 100 / cfg.exchanges.settings.lowBalanceMargin);
|
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
}, 2000);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
|
||||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
||||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var assert = require('chai').assert;
|
|
||||||
var hock = require('hock');
|
|
||||||
|
|
||||||
var LamassuConfig = require('lamassu-config');
|
|
||||||
var con = 'psql://lamassu:lamassu@localhost/lamassu';
|
|
||||||
var config = new LamassuConfig(con);
|
|
||||||
|
|
||||||
var fnTable = {};
|
|
||||||
var app = { get: function(route, fn) {
|
|
||||||
fnTable[route] = fn;
|
|
||||||
},
|
|
||||||
post: function(route, fn) {
|
|
||||||
fnTable[route] = fn;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var cfg;
|
|
||||||
|
|
||||||
var bitstampMock = hock.createHock();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the tests
|
|
||||||
*/
|
|
||||||
describe('trade test', function(){
|
|
||||||
|
|
||||||
beforeEach(function(done) {
|
|
||||||
config.load(function(err, result) {
|
|
||||||
assert.isNull(err);
|
|
||||||
cfg = result;
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
it('should execute a trade against bitstamp', function(done) {
|
|
||||||
this.timeout(1000000);
|
|
||||||
|
|
||||||
cfg.exchanges.plugins.trade = 'bitstamp';
|
|
||||||
var api = require('../../lib/protocol/atm-api');
|
|
||||||
api.init(app, cfg);
|
|
||||||
|
|
||||||
// schedule two trades this should result in a single consolidated trade hitting the trading system
|
|
||||||
fnTable['/trade']({body: {fiat: 100, satoshis: 10, currency: 'USD'}}, {json: function(result) {
|
|
||||||
console.log(result);
|
|
||||||
}});
|
|
||||||
|
|
||||||
fnTable['/trade']({body: {fiat: 100, satoshis: 10, currency: 'USD'}}, {json: function(result) {
|
|
||||||
console.log(result);
|
|
||||||
}});
|
|
||||||
|
|
||||||
setTimeout(function() { done(); }, 1000000);
|
|
||||||
// check results and execute done()
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue