using paginated version of insight-api addrs/txs
This commit is contained in:
parent
9b27c30679
commit
18deef115a
5 changed files with 60 additions and 34 deletions
|
|
@ -1979,7 +1979,10 @@ describe('Wallet model', function() {
|
|||
fees: 0.00000100
|
||||
}];
|
||||
|
||||
w.blockchain.getTransactions = sinon.stub().yields(null, txs);
|
||||
w.blockchain.getTransactions = sinon.stub().yields(null, {
|
||||
items: txs,
|
||||
totalItems: txs.length,
|
||||
});
|
||||
w.getAddressesInfo = sinon.stub().returns([{
|
||||
addressStr: 'addr_in_1'
|
||||
}, {
|
||||
|
|
@ -2045,7 +2048,10 @@ describe('Wallet model', function() {
|
|||
fees: 0.00000100
|
||||
}];
|
||||
|
||||
w.blockchain.getTransactions = sinon.stub().yields(null, txs);
|
||||
w.blockchain.getTransactions = sinon.stub().yields(null, {
|
||||
items: txs.slice(2,3),
|
||||
totalItems: txs.length,
|
||||
});
|
||||
w.getAddressesInfo = sinon.stub().returns([{
|
||||
addressStr: 'addr_in_1'
|
||||
}, {
|
||||
|
|
@ -2068,7 +2074,11 @@ describe('Wallet model', function() {
|
|||
});
|
||||
it('should paginate empty list', function(done) {
|
||||
var w = cachedCreateW2();
|
||||
w.blockchain.getTransactions = sinon.stub().yields(null, []);
|
||||
var txs = [];
|
||||
w.blockchain.getTransactions = sinon.stub().yields(null, {
|
||||
items: txs,
|
||||
totalItems: txs.length,
|
||||
});
|
||||
w.getAddressesInfo = sinon.stub().returns([{
|
||||
addressStr: 'addr_in_1'
|
||||
}, {
|
||||
|
|
@ -2111,7 +2121,10 @@ describe('Wallet model', function() {
|
|||
fees: 0.00000100
|
||||
}];
|
||||
|
||||
w.blockchain.getTransactions = sinon.stub().yields(null, txs);
|
||||
w.blockchain.getTransactions = sinon.stub().yields(null, {
|
||||
items: txs,
|
||||
totalItems: txs.length,
|
||||
});
|
||||
w.getAddressesInfo = sinon.stub().returns([{
|
||||
addressStr: 'addr_in_1'
|
||||
}, {
|
||||
|
|
@ -2154,7 +2167,10 @@ describe('Wallet model', function() {
|
|||
fees: 0.00000100
|
||||
}];
|
||||
|
||||
w.blockchain.getTransactions = sinon.stub().yields(null, txs);
|
||||
w.blockchain.getTransactions = sinon.stub().yields(null, {
|
||||
items: txs,
|
||||
totalItems: txs.length,
|
||||
});
|
||||
w.getAddressesInfo = sinon.stub().returns([{
|
||||
addressStr: 'addr_1'
|
||||
}, {
|
||||
|
|
@ -2197,7 +2213,10 @@ describe('Wallet model', function() {
|
|||
fees: 0.00000100
|
||||
}];
|
||||
|
||||
w.blockchain.getTransactions = sinon.stub().yields(null, txs);
|
||||
w.blockchain.getTransactions = sinon.stub().yields(null, {
|
||||
items: txs,
|
||||
totalItems: txs.length,
|
||||
});
|
||||
w.getAddressesInfo = sinon.stub().returns([{
|
||||
addressStr: 'addr_in_1'
|
||||
}, {
|
||||
|
|
@ -2245,7 +2264,10 @@ describe('Wallet model', function() {
|
|||
fees: 0.00000100
|
||||
}];
|
||||
|
||||
w.blockchain.getTransactions = sinon.stub().yields(null, txs);
|
||||
w.blockchain.getTransactions = sinon.stub().yields(null, {
|
||||
items: txs,
|
||||
totalItems: txs.length,
|
||||
});
|
||||
w.getAddressesInfo = sinon.stub().returns([{
|
||||
addressStr: 'addr_in_1'
|
||||
}, {
|
||||
|
|
|
|||
|
|
@ -230,19 +230,19 @@ describe('Insight model', function() {
|
|||
var blockchain = new Insight(FAKE_OPTS);
|
||||
|
||||
sinon.stub(blockchain, "requestPost", function(url, data, cb) {
|
||||
url.should.be.equal('/api/addrs/txs');
|
||||
url.should.be.equal('/api/addrs/txs?from=0');
|
||||
data.addrs.should.be.equal('2NATQJnaQe2CUKLyhL1zdNkttJM1dUH9HaM,2NE9hTCffeugo5gQtfB4owq98gyTeWC56yb');
|
||||
setTimeout(function() {
|
||||
var res = {statusCode: 200};
|
||||
var body = [1, 2, 3];
|
||||
var body = { totalItems: 3, items: [1, 2, 3] };
|
||||
cb(null, res, body);
|
||||
}, 0);
|
||||
});
|
||||
|
||||
var addresses = ['2NATQJnaQe2CUKLyhL1zdNkttJM1dUH9HaM', '2NE9hTCffeugo5gQtfB4owq98gyTeWC56yb'];
|
||||
blockchain.getTransactions(addresses, function(err, txs) {
|
||||
blockchain.getTransactions(addresses, null, null, function(err, res) {
|
||||
chai.expect(err).to.be.null;
|
||||
txs.length.should.be.equal(3);
|
||||
res.items.length.should.be.equal(3);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ FakeBlockchain.prototype.getTransaction = function(txid, cb) {
|
|||
return cb(null, {txid: txid});
|
||||
};
|
||||
|
||||
FakeBlockchain.prototype.getTransactions = function(addresses, cb) {
|
||||
cb(null, []);
|
||||
FakeBlockchain.prototype.getTransactions = function(addresses, from, to, cb) {
|
||||
cb(null, { totalItems: 0, items: [] });
|
||||
};
|
||||
|
||||
FakeBlockchain.prototype.subscribe = function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue