add tests for balance

This commit is contained in:
Ivan Socolsky 2015-03-06 13:07:44 -03:00
parent 20d4d279b7
commit 2c39d6a687
1 changed files with 50 additions and 8 deletions

View File

@ -550,7 +550,6 @@ describe('Copay server', function() {
}); });
}); });
describe('#verifyMessageSignature', function() { describe('#verifyMessageSignature', function() {
var server, wallet; var server, wallet;
beforeEach(function(done) { beforeEach(function(done) {
@ -646,6 +645,56 @@ describe('Copay server', function() {
}); });
}); });
describe.only('#getBalance', function() {
var server, wallet;
beforeEach(function(done) {
helpers.createAndJoinWallet(1, 1, function(s, w) {
server = s;
wallet = w;
done();
});
});
it('should get balance', function(done) {
helpers.stubUtxos(server, wallet, 10, function() {
server.getBalance({}, function(err, balance) {
should.not.exist(err);
should.exist(balance);
balance.totalAmount.should.equal(helpers.toSatoshi(10));
balance.lockedAmount.should.equal(0);
should.exist(balance.byAddress);
balance.byAddress.length.should.equal(1);
balance.byAddress[0].amount.should.equal(helpers.toSatoshi(10));
done();
});
});
});
it('should get balance when there are no addresses', function(done) {
server.getBalance({}, function(err, balance) {
should.not.exist(err);
should.exist(balance);
balance.totalAmount.should.equal(0);
balance.lockedAmount.should.equal(0);
should.exist(balance.byAddress);
balance.byAddress.length.should.equal(0);
done();
});
});
it('should get balance when there are no funds', function(done) {
server.createAddress({}, function(err, address) {
should.not.exist(err);
server.getBalance({}, function(err, balance) {
should.not.exist(err);
should.exist(balance);
balance.totalAmount.should.equal(0);
balance.lockedAmount.should.equal(0);
should.exist(balance.byAddress);
balance.byAddress.length.should.equal(1);
done();
});
});
});
});
describe('Wallet not complete tests', function() { describe('Wallet not complete tests', function() {
it('should fail to create address when wallet is not complete', function(done) { it('should fail to create address when wallet is not complete', function(done) {
@ -710,7 +759,6 @@ describe('Copay server', function() {
}); });
}); });
describe('#createTx', function() { describe('#createTx', function() {
var server, wallet; var server, wallet;
beforeEach(function(done) { beforeEach(function(done) {
@ -959,7 +1007,6 @@ describe('Copay server', function() {
}); });
}); });
describe('#rejectTx', function() { describe('#rejectTx', function() {
var server, wallet, txid; var server, wallet, txid;
@ -1356,7 +1403,6 @@ describe('Copay server', function() {
}); });
}); });
describe('Tx proposal workflow', function() { describe('Tx proposal workflow', function() {
var server, wallet; var server, wallet;
beforeEach(function(done) { beforeEach(function(done) {
@ -1682,8 +1728,6 @@ describe('Copay server', function() {
}); });
}); });
describe('Notifications', function() { describe('Notifications', function() {
var server, wallet; var server, wallet;
@ -1901,7 +1945,6 @@ describe('Copay server', function() {
}); });
}); });
describe('#removePendingTx', function() { describe('#removePendingTx', function() {
var server, wallet, txp; var server, wallet, txp;
beforeEach(function(done) { beforeEach(function(done) {
@ -2037,7 +2080,6 @@ describe('Copay server', function() {
}); });
}); });
describe('#getTxHistory', function() { describe('#getTxHistory', function() {
var server, wallet, mainAddresses, changeAddresses; var server, wallet, mainAddresses, changeAddresses;
beforeEach(function(done) { beforeEach(function(done) {