Publish Nerbus source snapshot and build documentation
This commit is contained in:
commit
76cccceca7
198 files changed
+338574
No files matched your search
@@ -0,0 +1,135 @@
|
||||
describe('explorer', function() {
|
||||
const lib = require('../lib/explorer');
|
||||
const data = require('./testData.js');
|
||||
const Decimal = require('decimal.js');
|
||||
|
||||
describe('convert_to_satoshi', function() {
|
||||
it('should be able to convert round numbers', function() {
|
||||
const amount_sat = lib.convert_to_satoshi(new Decimal('500'));
|
||||
expect(amount_sat.toString()).toEqual('50000000000');
|
||||
});
|
||||
|
||||
it('should be able to convert decimals above 1', function() {
|
||||
const amount_sat = lib.convert_to_satoshi(new Decimal('500.12564'));
|
||||
expect(amount_sat.toString()).toEqual('50012564000');
|
||||
});
|
||||
|
||||
it('should be able to convert decimals below 1', function() {
|
||||
const amount_sat = lib.convert_to_satoshi(new Decimal('0.0005'));
|
||||
expect(amount_sat.toString()).toEqual('50000');
|
||||
});
|
||||
});
|
||||
|
||||
describe('is_unique', function() {
|
||||
const arrayStrMap = [
|
||||
{'addresses' : 'XsF8k8s5CoS3XATqW2FkuTsznbJJzFAC2U'},
|
||||
{'addresses' : 'XsF8k8s5C14FbhqW2FkuATsznFACAfVhUn'},
|
||||
{'addresses' : 'XsF8k8s5CoAF5gTqW2FkuTsznbJJzhkj5A'},
|
||||
{'addresses' : 'XfuW2K9QiGMSsq5eXgtimEQvTvz9dzBCzb'}
|
||||
];
|
||||
|
||||
const arrayArrMap = [
|
||||
{'addresses' : ['XsF8k8s5CoS3XATqW2FkuTsznbJJzFAC2U']},
|
||||
{'addresses' : ['XsF8k8s5C14FbhqW2FkuATsznFACAfVhUn']},
|
||||
{'addresses' : ['XsF8k8s5CoAF5gTqW2FkuTsznbJJzhkj5A']},
|
||||
{'addresses' : ['XfuW2K9QiGMSsq5eXgtimEQvTvz9dzBCzb']}
|
||||
];
|
||||
|
||||
it('should return index of matching string object', function() {
|
||||
const index = lib.is_unique(arrayStrMap, arrayStrMap[2].addresses, 'addresses');
|
||||
expect(index).toEqual(2);
|
||||
});
|
||||
|
||||
it('should return index of matching array object', function() {
|
||||
const index = lib.is_unique(arrayArrMap, arrayArrMap[2].addresses, 'addresses');
|
||||
expect(index).toEqual(2);
|
||||
});
|
||||
|
||||
it('should return index of -1 if no matching string object', function() {
|
||||
const index = lib.is_unique(arrayStrMap, 'unique', 'addresses');
|
||||
expect(index).toEqual(-1);
|
||||
});
|
||||
|
||||
it('should return index of -1 if no matching array object', function() {
|
||||
const index = lib.is_unique(arrayArrMap, ['unique'], 'addresses');
|
||||
expect(index).toEqual(-1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('prepare_vout', function() {
|
||||
let originalTimeout;
|
||||
|
||||
beforeEach(function() {
|
||||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
||||
});
|
||||
|
||||
it('should ignore nonstandard outputs', function(done) {
|
||||
lib.prepare_vout(data.txA().vout, data.txA().txid, data.txA().vin, ((typeof data.txA().vjoinsplit === 'undefined' || data.txA().vjoinsplit == null) ? [] : data.txA().vjoinsplit), function(prepared) {
|
||||
expect(prepared.length).toEqual(2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should maintain order', function(done) {
|
||||
lib.prepare_vout(data.txA().vout, data.txA().txid, data.txA().vin, ((typeof data.txA().vjoinsplit === 'undefined' || data.txA().vjoinsplit == null) ? [] : data.txA().vjoinsplit), function(prepared) {
|
||||
expect(prepared[1].amount.toString()).toEqual('17499989908960');
|
||||
expect(prepared[1].addresses).toEqual('ENpRvyLpLFEyrMZthAGABhxZi3N4Byk3Ab');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
});
|
||||
});
|
||||
|
||||
describe('calculate_total', function() {
|
||||
let originalTimeout;
|
||||
|
||||
beforeEach(function() {
|
||||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
||||
});
|
||||
|
||||
it('should calculate correct total', function(done) {
|
||||
lib.prepare_vout(data.txA().vout, data.txA().txid, data.txA().vin, ((typeof data.txA().vjoinsplit === 'undefined' || data.txA().vjoinsplit == null) ? [] : data.txA().vjoinsplit), function(prepared) {
|
||||
const total = lib.calculate_total(prepared)
|
||||
expect(total.toString()).toEqual('19499989908960');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
});
|
||||
});
|
||||
|
||||
describe('prepare_vin', function() {
|
||||
let originalTimeout;
|
||||
|
||||
beforeEach(function() {
|
||||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
||||
});
|
||||
|
||||
it('should return array of correct length', function(done) {
|
||||
lib.prepare_vin(data.txB(), function(prepared) {
|
||||
expect(prepared.length).toEqual(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should get correct input addresses', function(done) {
|
||||
lib.prepare_vin(data.txB(), function(prepared) {
|
||||
expect(prepared[0].amount.toString()).toEqual('27499989920000');
|
||||
expect(prepared[0].addresses).toEqual('coinbase');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,233 @@
|
||||
describe('market', function() {
|
||||
describe('dexomy', function() {
|
||||
beforeEach(function() {
|
||||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
|
||||
});
|
||||
|
||||
it('should return market data', function(done) {
|
||||
const dexomy = require('../lib/markets/dexomy');
|
||||
|
||||
dexomy.get_data({ coin: 'BTC', exchange: 'USDT' }, function(err, obj) {
|
||||
expect(err).toEqual(null);
|
||||
expect(obj.buys.length).toBeGreaterThan(0);
|
||||
expect(obj.buys.length).toBeLessThanOrEqual(100);
|
||||
expect(obj.sells.length).toBeGreaterThan(0);
|
||||
expect(obj.sells.length).toBeLessThanOrEqual(100);
|
||||
expect(obj.trades.length).toBeGreaterThan(0);
|
||||
expect(obj.trades.length).toBeLessThanOrEqual(100);
|
||||
expect(Object.keys(obj.stats).length).toEqual(5);
|
||||
expect(obj.chartdata.length).toBeGreaterThan(0);
|
||||
expect(obj.chartdata.length).toBeLessThanOrEqual(96);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
});
|
||||
});
|
||||
|
||||
describe('dextrade', function() {
|
||||
beforeEach(function() {
|
||||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
|
||||
});
|
||||
|
||||
it('should return market data', function(done) {
|
||||
const dextrade = require('../lib/markets/dextrade');
|
||||
|
||||
dextrade.get_data({ coin: 'BTC', exchange: 'USDT' }, function(err, obj) {
|
||||
expect(err).toEqual(null);
|
||||
expect(obj.buys.length).toBeGreaterThan(0);
|
||||
expect(obj.buys.length).toBeLessThanOrEqual(1000);
|
||||
expect(obj.sells.length).toBeGreaterThan(0);
|
||||
expect(obj.sells.length).toBeLessThanOrEqual(1000);
|
||||
expect(obj.trades.length).toBeGreaterThan(0);
|
||||
expect(obj.trades.length).toBeLessThanOrEqual(25);
|
||||
expect(Object.keys(obj.stats).length).toEqual(6);
|
||||
expect(obj.chartdata.length).toBeGreaterThan(0);
|
||||
expect(obj.chartdata.length).toBeLessThanOrEqual(96);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
});
|
||||
});
|
||||
|
||||
describe('freiexchange', function() {
|
||||
beforeEach(function() {
|
||||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
|
||||
});
|
||||
|
||||
it('should return market data', function(done) {
|
||||
const freiexchange = require('../lib/markets/freiexchange');
|
||||
|
||||
freiexchange.get_data({ coin: 'LTC', exchange: 'BTC' }, function(err, obj) {
|
||||
expect(err).toEqual(null);
|
||||
expect(obj.buys.length).toBeGreaterThan(0);
|
||||
expect(obj.buys.length).toBeLessThanOrEqual(500);
|
||||
expect(obj.sells.length).toBeGreaterThan(0);
|
||||
expect(obj.sells.length).toBeLessThanOrEqual(500);
|
||||
|
||||
// NOTE: Commenting out the trade data since the trades api seems to have been discontinued.
|
||||
// It will be reimplemented again later if the trades api ever returns.
|
||||
//expect(obj.trades.length).toBeGreaterThan(0);
|
||||
//expect(obj.trades.length).toBeLessThanOrEqual(100);
|
||||
expect(obj.trades.length).toEqual(0);
|
||||
expect(Object.keys(obj.stats).length).toEqual(8);
|
||||
expect(obj.chartdata).toEqual(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
});
|
||||
});
|
||||
|
||||
describe('nestex', function() {
|
||||
beforeEach(function() {
|
||||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
|
||||
});
|
||||
|
||||
it('should return market data', function(done) {
|
||||
const nestex = require('../lib/markets/nestex');
|
||||
|
||||
nestex.get_data({ coin: 'BTC', exchange: 'USDT' }, function(err, obj) {
|
||||
expect(err).toEqual(null);
|
||||
expect(obj.buys.length).toBeGreaterThan(0);
|
||||
expect(obj.buys.length).toBeLessThanOrEqual(100);
|
||||
expect(obj.sells.length).toBeGreaterThan(0);
|
||||
expect(obj.sells.length).toBeLessThanOrEqual(100);
|
||||
expect(obj.trades.length).toBeGreaterThan(0);
|
||||
expect(obj.trades.length).toBeLessThanOrEqual(300);
|
||||
expect(Object.keys(obj.stats).length).toEqual(7);
|
||||
expect(obj.chartdata).toEqual(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
});
|
||||
});
|
||||
|
||||
describe('nonkyc', function() {
|
||||
beforeEach(function() {
|
||||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
|
||||
});
|
||||
|
||||
it('should return market data', function(done) {
|
||||
const nonkyc = require('../lib/markets/nonkyc');
|
||||
|
||||
nonkyc.get_data({ coin: 'BTC', exchange: 'USDT' }, function(err, obj) {
|
||||
expect(err).toEqual(null);
|
||||
expect(obj.buys.length).toBeGreaterThan(0);
|
||||
expect(obj.buys.length).toBeLessThanOrEqual(100);
|
||||
expect(obj.sells.length).toBeGreaterThan(0);
|
||||
expect(obj.sells.length).toBeLessThanOrEqual(100);
|
||||
expect(obj.trades.length).toBeGreaterThan(0);
|
||||
expect(obj.trades.length).toBeLessThanOrEqual(300);
|
||||
expect(Object.keys(obj.stats).length).toEqual(9);
|
||||
expect(obj.chartdata.length).toBeGreaterThan(0);
|
||||
expect(obj.chartdata.length).toBeLessThanOrEqual(96);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
});
|
||||
});
|
||||
|
||||
describe('poloniex', function() {
|
||||
beforeEach(function() {
|
||||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
|
||||
});
|
||||
|
||||
it('should return market data', function(done) {
|
||||
const poloniex = require('../lib/markets/poloniex');
|
||||
|
||||
poloniex.get_data({ coin: 'BTC', exchange: 'USDT' }, function(err, obj) {
|
||||
expect(err).toEqual(null);
|
||||
expect(obj.buys.length).toBeGreaterThan(0);
|
||||
expect(obj.buys.length).toBeLessThanOrEqual(50);
|
||||
expect(obj.sells.length).toBeGreaterThan(0);
|
||||
expect(obj.sells.length).toBeLessThanOrEqual(50);
|
||||
expect(obj.trades.length).toBeGreaterThan(0);
|
||||
expect(obj.trades.length).toBeLessThanOrEqual(500);
|
||||
expect(Object.keys(obj.stats).length).toEqual(7);
|
||||
expect(obj.chartdata.length).toBeGreaterThan(0);
|
||||
expect(obj.chartdata.length).toBeLessThanOrEqual(96);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
});
|
||||
});
|
||||
|
||||
describe('qutrade', function() {
|
||||
beforeEach(function() {
|
||||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
|
||||
});
|
||||
|
||||
it('should return market data', function(done) {
|
||||
const qutrade = require('../lib/markets/qutrade');
|
||||
|
||||
qutrade.get_data({ coin: 'BTC', exchange: 'USDT' }, function(err, obj) {
|
||||
expect(err).toEqual(null);
|
||||
expect(obj.buys.length).toBeGreaterThan(0);
|
||||
expect(obj.buys.length).toBeLessThanOrEqual(100);
|
||||
expect(obj.sells.length).toBeGreaterThan(0);
|
||||
expect(obj.sells.length).toBeLessThanOrEqual(100);
|
||||
expect(obj.trades.length).toBeGreaterThan(0);
|
||||
expect(obj.trades.length).toBeLessThanOrEqual(100);
|
||||
expect(Object.keys(obj.stats).length).toEqual(8);
|
||||
expect(obj.chartdata).toEqual(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
});
|
||||
});
|
||||
|
||||
describe('yobit', function() {
|
||||
beforeEach(function() {
|
||||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
|
||||
});
|
||||
|
||||
it('should return market data', function(done) {
|
||||
const yobit = require('../lib/markets/yobit');
|
||||
|
||||
yobit.get_data({ coin: 'BTC', exchange: 'USDT' }, function(err, obj) {
|
||||
expect(err).toEqual(null);
|
||||
expect(obj.buys.length).toBeGreaterThan(0);
|
||||
expect(obj.buys.length).toBeLessThanOrEqual(150);
|
||||
expect(obj.sells.length).toBeGreaterThan(0);
|
||||
expect(obj.sells.length).toBeLessThanOrEqual(150);
|
||||
expect(obj.trades.length).toBeGreaterThan(0);
|
||||
expect(obj.trades.length).toBeLessThanOrEqual(150);
|
||||
expect(Object.keys(obj.stats).length).toEqual(6);
|
||||
expect(obj.chartdata).toEqual(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,86 @@
|
||||
module.exports = {
|
||||
txA: function() {
|
||||
return {
|
||||
"hex": "01000000017eb15ab57385cba5f3cf98c61aa539b0935310167f242e38b56ffc8df8d205af000000006a473044022067081a04ac02c066e3584f4fe4b0cf16ed25341234b0507fb3c2adf6e0b412d2022024e57e1882db5b25ad772d661f805dea48173f0b7769108805c52e671a8f4e0d012103c45f64a58623d6586c3316f4e810815d42ed1284ad5da2748f67e9440a242848ffffffff0200204aa9d10100001976a914c28b8eb72accf4a5674d09f9819822ceacbbcb5088ace09dae88ea0f00001976a9143e21d7f627a05504811ade3de943a09bd5bcb0be88ac00000000",
|
||||
"txid": "57a09665c67703f6be22e5e4725261e6e8a63c975237cf114c6c44d0e303f564",
|
||||
"version": 1,
|
||||
"locktime": 0,
|
||||
"vin": [
|
||||
{
|
||||
"txid": "af05d2f88dfc6fb5382e247f16105393b039a51ac698cff3a5cb8573b55ab17e",
|
||||
"vout": 0,
|
||||
"scriptSig": {
|
||||
"asm": "3044022067081a04ac02c066e3584f4fe4b0cf16ed25341234b0507fb3c2adf6e0b412d2022024e57e1882db5b25ad772d661f805dea48173f0b7769108805c52e671a8f4e0d01 03c45f64a58623d6586c3316f4e810815d42ed1284ad5da2748f67e9440a242848",
|
||||
"hex": "473044022067081a04ac02c066e3584f4fe4b0cf16ed25341234b0507fb3c2adf6e0b412d2022024e57e1882db5b25ad772d661f805dea48173f0b7769108805c52e671a8f4e0d012103c45f64a58623d6586c3316f4e810815d42ed1284ad5da2748f67e9440a242848"
|
||||
},
|
||||
"sequence": 4294967295
|
||||
}
|
||||
],
|
||||
"vout": [
|
||||
{
|
||||
"value": 20000,
|
||||
"n": 0,
|
||||
"scriptPubKey": {
|
||||
"asm": "OP_DUP OP_HASH160 c28b8eb72accf4a5674d09f9819822ceacbbcb50 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"hex": "76a914c28b8eb72accf4a5674d09f9819822ceacbbcb5088ac",
|
||||
"reqSigs": 1,
|
||||
"type": "pubkeyhash",
|
||||
"addresses": [
|
||||
"EatZmRVp2RC1eWjDDs3T97qjHiRQd4fcY3"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"value": 174999.8990896,
|
||||
"n": 1,
|
||||
"scriptPubKey": {
|
||||
"asm": "OP_DUP OP_HASH160 3e21d7f627a05504811ade3de943a09bd5bcb0be OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"hex": "76a9143e21d7f627a05504811ade3de943a09bd5bcb0be88ac",
|
||||
"reqSigs": 1,
|
||||
"type": "pubkeyhash",
|
||||
"addresses": [
|
||||
"ENpRvyLpLFEyrMZthAGABhxZi3N4Byk3Ab"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"blockhash": "0000044ac8528db3bc14ec7f81a94b2f731d01f37e7a67352b315f1116f0a90b",
|
||||
"confirmations": 795824,
|
||||
"time": 1558978791,
|
||||
"blocktime": 1558978791
|
||||
};
|
||||
},
|
||||
txB: function() {
|
||||
return {
|
||||
"hex": "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff05029a000102ffffffff01006921d702190000232103ccc28ef6edc7bd2d361cee574eeebe40ec84a0b0513bd98580af0d68926ce848ac00000000",
|
||||
"txid": "2e3dab17d71f8e53e8fa840469715622bb791a656419c47b56ceea695c6a082b",
|
||||
"version": 1,
|
||||
"locktime": 0,
|
||||
"vin": [
|
||||
{
|
||||
"coinbase": "029a000102",
|
||||
"sequence": 4294967295
|
||||
}
|
||||
],
|
||||
"vout": [
|
||||
{
|
||||
"value": 274999.8992,
|
||||
"n": 0,
|
||||
"scriptPubKey": {
|
||||
"asm": "03ccc28ef6edc7bd2d361cee574eeebe40ec84a0b0513bd98580af0d68926ce848 OP_CHECKSIG",
|
||||
"hex": "2103ccc28ef6edc7bd2d361cee574eeebe40ec84a0b0513bd98580af0d68926ce848ac",
|
||||
"reqSigs": 1,
|
||||
"type": "pubkey",
|
||||
"addresses": [
|
||||
"ELZzVxeCjZi5Zry15hbe8NLMmTJQuegi26"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"blockhash": "00000305e5aede3aa79ca07e5d3976f9cfac7098fcbcaea109c15ee4688ee409",
|
||||
"confirmations": 795794,
|
||||
"time": 1558980932,
|
||||
"blocktime": 1558980932
|
||||
};
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user