Restore jasmine test functionality
-Rename spec directory to test -Move old data.js file into the new test directory and rename to testData.js -Remove unused support/jasmine.json file -Populate testData.js with sample data from Exor blockchain -Re-configure explorerSpec.js tests to match new testData.js data
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@
|
||||
"scripts": {
|
||||
"start": "npm run sass:compile && node --stack-size=10000 ./bin/cluster",
|
||||
"stop": "kill -2 $(cat tmp/cluster.pid)",
|
||||
"test": "node ./node_modules/jasmine/bin/jasmine.js",
|
||||
"test": "node ./node_modules/jasmine/bin/jasmine.js test/*Spec.js",
|
||||
"sass:compile": "sh ./scripts/sass_theme_reader.sh && ./node_modules/.bin/sass --no-source-map --style=compressed ./public/css/style.scss ./public/css/style.min.css"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
describe('market', function() {
|
||||
var poloniex = require('../lib/poloniex');
|
||||
|
||||
describe('poloniex', function() {
|
||||
beforeEach(function() {
|
||||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
||||
});
|
||||
|
||||
it('should return trade history', function(done){
|
||||
poloniex.get_trades('DRK', 'BTC', function(err, trades) {
|
||||
expect(err).toEqual(null);
|
||||
expect(trades.length).toEqual(200);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return orderbook', function(done){
|
||||
poloniex.get_orders('DRK', 'BTC', function(err, orders) {
|
||||
expect(err).toEqual(null);
|
||||
expect(orders.asks.length).toEqual(50);
|
||||
expect(orders.bids.length).toEqual(50);
|
||||
expect(orders.isFrozen).toEqual('0');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return summary', function(done){
|
||||
poloniex.get_summary('DRK', 'BTC', function(err, summary) {
|
||||
expect(err).toEqual(null);
|
||||
expect(summary.isFrozen).toEqual('0');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return chartdata', function(done){
|
||||
poloniex.get_chartdata('DRK', 'BTC', 0, function(err, chartdata) {
|
||||
expect(err).toEqual(null);
|
||||
expect(chartdata.length).toBeGreaterThan(10);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"spec_dir": "spec",
|
||||
"spec_files": [
|
||||
"*[sS]pec.js"
|
||||
],
|
||||
"helpers": [
|
||||
"helpers/*.js"
|
||||
]
|
||||
}
|
||||
-2421
File diff suppressed because one or more lines are too long
@@ -1,33 +1,28 @@
|
||||
describe('explorer', function() {
|
||||
var lib = require('../lib/explorer');
|
||||
var data = require('../test/data.js');
|
||||
var data = require('./testData.js');
|
||||
|
||||
describe('convert_to_satoshi', function() {
|
||||
|
||||
it('should be able to convert round numbers', function() {
|
||||
lib.convert_to_satoshi(500, function(amount_sat) {
|
||||
expect(amount_sat).toEqual(50000000000);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to convert decimals above 1', function() {
|
||||
lib.convert_to_satoshi(500.12564, function(amount_sat) {
|
||||
expect(amount_sat).toEqual(50012564000);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to convert decimals below 1', function() {
|
||||
lib.convert_to_satoshi(0.0005, function(amount_sat) {
|
||||
expect(amount_sat).toEqual(50000);
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('is_unique', function() {
|
||||
|
||||
var arrayStrMap = [
|
||||
{'addresses' : 'XsF8k8s5CoS3XATqW2FkuTsznbJJzFAC2U'},
|
||||
{'addresses' : 'XsF8k8s5C14FbhqW2FkuATsznFACAfVhUn'},
|
||||
@@ -46,7 +41,6 @@ describe('explorer', function() {
|
||||
lib.is_unique(arrayStrMap, arrayStrMap[2].addresses, function(unique, index) {
|
||||
expect(index).toEqual(2);
|
||||
expect(unique).toEqual(false);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -54,7 +48,6 @@ describe('explorer', function() {
|
||||
lib.is_unique(arrayArrMap, arrayArrMap[2].addresses, function(unique, index) {
|
||||
expect(index).toEqual(2);
|
||||
expect(unique).toEqual(false);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -62,7 +55,6 @@ describe('explorer', function() {
|
||||
lib.is_unique(arrayStrMap, 'unique', function(unique, index) {
|
||||
expect(index).toEqual(null);
|
||||
expect(unique).toEqual(true);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -70,14 +62,11 @@ describe('explorer', function() {
|
||||
lib.is_unique(arrayArrMap, ['unique'], function(unique, index) {
|
||||
expect(index).toEqual(null);
|
||||
expect(unique).toEqual(true);
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('prepare_vout', function() {
|
||||
|
||||
|
||||
var originalTimeout;
|
||||
beforeEach(function() {
|
||||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
@@ -85,16 +74,16 @@ describe('explorer', function() {
|
||||
});
|
||||
|
||||
it('should ignore nonstandard outputs', function(done) {
|
||||
lib.prepare_vout(data.txA().vout, data.txA().txid, function(prepared) {
|
||||
expect(prepared.length).toEqual(152);
|
||||
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, function(prepared) {
|
||||
expect(prepared[150].amount).toEqual(2.1006);
|
||||
expect(prepared[150].addresses).toEqual(['XyPreJfnUxSSY1QbYqQxDXpymc26VFQPDV']);
|
||||
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).toEqual(17499989908960);
|
||||
expect(prepared[1].addresses).toEqual('ENpRvyLpLFEyrMZthAGABhxZi3N4Byk3Ab');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -102,7 +91,6 @@ describe('explorer', function() {
|
||||
afterEach(function() {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('calculate_total', function() {
|
||||
@@ -114,9 +102,9 @@ describe('explorer', function() {
|
||||
});
|
||||
|
||||
it('should calculate correct total', function(done) {
|
||||
lib.prepare_vout(data.txA().vout, data.txA().txid, function(prepared) {
|
||||
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) {
|
||||
lib.calculate_total(prepared, function(total) {
|
||||
expect(total).toEqual(700200000);
|
||||
expect(total).toEqual(19499989908960);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -137,15 +125,15 @@ describe('explorer', function() {
|
||||
|
||||
it('should return array of correct length', function(done) {
|
||||
lib.prepare_vin(data.txB(), function(prepared) {
|
||||
expect(prepared.length).toEqual(18);
|
||||
expect(prepared.length).toEqual(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should get correct input addresses', function(done) {
|
||||
lib.prepare_vin(data.txB(), function(prepared) {
|
||||
expect(prepared[3].amount).toEqual(10.00000001);
|
||||
expect(prepared[3].addresses).toEqual('XjYC7q5QwG7dGnytYDoCURhL4CATj6WQhZ');
|
||||
expect(prepared[0].amount).toEqual(27499989920000);
|
||||
expect(prepared[0].addresses).toEqual('coinbase');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
describe('market', function() {
|
||||
var poloniex = require('../lib/markets/poloniex');
|
||||
|
||||
describe('poloniex', function() {
|
||||
beforeEach(function() {
|
||||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
||||
});
|
||||
|
||||
it('should return market data', function(done) {
|
||||
poloniex.get_data({ coin: 'LTC', exchange: 'BTC' }, function(err, obj) {
|
||||
expect(err).toEqual(null);
|
||||
expect(obj.buys.length).toEqual(50);
|
||||
expect(obj.sells.length).toEqual(50);
|
||||
expect(obj.trades.length).toEqual(200);
|
||||
expect(Object.keys(obj.stats).length).toEqual(7);
|
||||
expect(obj.chartdata.length).toBeGreaterThan(10);
|
||||
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