test tx history from client
This commit is contained in:
parent
9260ab202e
commit
4b1e27f750
|
@ -14,6 +14,7 @@ var Bitcore = require('bitcore');
|
||||||
var WalletUtils = require('../../lib/walletutils');
|
var WalletUtils = require('../../lib/walletutils');
|
||||||
var ExpressApp = require('../../lib/expressapp');
|
var ExpressApp = require('../../lib/expressapp');
|
||||||
var Storage = require('../../lib/storage');
|
var Storage = require('../../lib/storage');
|
||||||
|
var TestData = require('../testdata');
|
||||||
|
|
||||||
|
|
||||||
var helpers = {};
|
var helpers = {};
|
||||||
|
@ -84,10 +85,8 @@ fsmock._set = function(name, data) {
|
||||||
return content[name] = data;
|
return content[name] = data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var blockExplorerMock = {};
|
var blockExplorerMock = {};
|
||||||
blockExplorerMock.utxos = [];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
blockExplorerMock.getUnspentUtxos = function(dummy, cb) {
|
blockExplorerMock.getUnspentUtxos = function(dummy, cb) {
|
||||||
var ret = _.map(blockExplorerMock.utxos || [], function(x) {
|
var ret = _.map(blockExplorerMock.utxos || [], function(x) {
|
||||||
|
@ -115,8 +114,17 @@ blockExplorerMock.broadcast = function(raw, cb) {
|
||||||
return cb(null, (new Bitcore.Transaction(raw)).id);
|
return cb(null, (new Bitcore.Transaction(raw)).id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
blockExplorerMock.setHistory = function(txs) {
|
||||||
|
blockExplorerMock.txHistory = txs;
|
||||||
|
};
|
||||||
|
|
||||||
|
blockExplorerMock.getTransactions = function(addresses, cb) {
|
||||||
|
return cb(null, blockExplorerMock.txHistory || []);
|
||||||
|
};
|
||||||
|
|
||||||
blockExplorerMock.reset = function() {
|
blockExplorerMock.reset = function() {
|
||||||
blockExplorerMock.utxos = [];
|
blockExplorerMock.utxos = [];
|
||||||
|
blockExplorerMock.txHistory = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1340,4 +1348,35 @@ describe('client API ', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Transaction history', function() {
|
||||||
|
it('should get transaction history', function(done) {
|
||||||
|
blockExplorerMock.setHistory(TestData.history);
|
||||||
|
helpers.createAndJoinWallet(clients, 1, 1, function(err, w) {
|
||||||
|
clients[0].createAddress(function(err, x0) {
|
||||||
|
should.not.exist(err);
|
||||||
|
should.exist(x0.address);
|
||||||
|
clients[0].getTxHistory({}, function(err, txs) {
|
||||||
|
should.not.exist(err);
|
||||||
|
should.exist(txs);
|
||||||
|
txs.length.should.equal(2);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('should get empty transaction history when there are no addresses', function(done) {
|
||||||
|
blockExplorerMock.setHistory(TestData.history);
|
||||||
|
helpers.createAndJoinWallet(clients, 1, 1, function(err, w) {
|
||||||
|
clients[0].getTxHistory({}, function(err, txs) {
|
||||||
|
should.not.exist(err);
|
||||||
|
should.exist(txs);
|
||||||
|
txs.length.should.equal(0);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it.skip('should get transaction history decorated with proposal', function(done) {});
|
||||||
|
it.skip('should get paginated transaction history', function(done) {});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue