lock and release tests

This commit is contained in:
Matias Alejo Garcia 2015-02-19 20:19:01 -03:00
parent 71d01e279f
commit c0615d7ac7
2 changed files with 17 additions and 6 deletions

View File

@ -358,7 +358,8 @@ CopayServer.prototype._getUtxos = function(cb) {
bc.getUnspentUtxos(addressStrs, function(err, inutxos) {
if (err) return cb(err);
var utxos = _.map(inutxos, function(i) {
return i.toObject();
var r = i.toObject();
return _.pick(r,['txid', 'vout', 'address', 'scriptPubKey', 'amount', 'satoshis']);
});
self.getPendingTxs({}, function(err, txps) {
if (err) return cb(err);

View File

@ -91,10 +91,11 @@ blockExplorerMock.utxos = [];
blockExplorerMock.getUnspentUtxos = function(dummy, cb) {
var ret = _.map(blockExplorerMock.utxos || [], function(x) {
x.toObject = function() {
var y = _.clone(x);
y.toObject = function() {
return this;
};
return x;
return y;
});
return cb(null, ret);
};
@ -526,7 +527,7 @@ describe('client API ', function() {
});
describe('Transaction Troposals and Locked funds', function() {
it('Should not allow to propose txs if not funds are available', function(done) {
it('Should lock and release funds', function(done) {
helpers.createAndJoinWallet(clients, 2, 2, function(err, w) {
clients[0].createAddress(function(err, x0) {
should.not.exist(err);
@ -540,9 +541,18 @@ describe('client API ', function() {
};
clients[0].sendTxProposal(opts, function(err, x) {
should.not.exist(err);
clients[0].sendTxProposal(opts, function(err, x) {
clients[0].sendTxProposal(opts, function(err, y) {
err.code.should.contain('INSUFFICIENTFUNDS');
done();
clients[0].rejectTxProposal(x, 'no', function(err, z) {
should.not.exist(err);
z.status.should.equal('rejected');
clients[0].sendTxProposal(opts, function(err, x) {
should.not.exist(err);
done();
});
});
});
});
});