wallet test passing
This commit is contained in:
parent
efb5b28c50
commit
e9005c2ca0
3 changed files with 85 additions and 68 deletions
|
|
@ -38,6 +38,17 @@ function TxProposal(opts) {
|
||||||
this.readonly = opts.readonly || null;
|
this.readonly = opts.readonly || null;
|
||||||
this.merchant = opts.merchant || null;
|
this.merchant = opts.merchant || null;
|
||||||
this.paymentProtocolURL = opts.paymentProtocolURL || null;
|
this.paymentProtocolURL = opts.paymentProtocolURL || null;
|
||||||
|
|
||||||
|
if (opts.creator) {
|
||||||
|
var now = Date.now();
|
||||||
|
var me = {};
|
||||||
|
me[opts.creator] = now;
|
||||||
|
|
||||||
|
this.signedBy = this.seenBy = me;
|
||||||
|
this.creator = opts.creator;
|
||||||
|
this.createdTs = now;
|
||||||
|
}
|
||||||
|
|
||||||
this._sync();
|
this._sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -50,7 +61,7 @@ TxProposal.prototype._checkPayPro = function() {
|
||||||
if (!this.merchant.outs || this.merchant.outs.length !== 1)
|
if (!this.merchant.outs || this.merchant.outs.length !== 1)
|
||||||
throw new Error('PayPro: Unsopported number of outputs');
|
throw new Error('PayPro: Unsopported number of outputs');
|
||||||
|
|
||||||
if (this.merchant.expires < (this.getSent() || Date.now()/1000.) )
|
if (this.merchant.expires < (this.getSent() || Date.now() / 1000.))
|
||||||
throw new Error('PayPro: Request expired');
|
throw new Error('PayPro: Request expired');
|
||||||
|
|
||||||
if (!this.merchant.total || !this.merchant.outs[0].amountSatStr || !this.merchant.outs[0].address)
|
if (!this.merchant.total || !this.merchant.outs[0].amountSatStr || !this.merchant.outs[0].address)
|
||||||
|
|
|
||||||
|
|
@ -1541,7 +1541,9 @@ Wallet.prototype.fetchPaymentRequest = function(options, cb) {
|
||||||
var merchantData, err;
|
var merchantData, err;
|
||||||
try {
|
try {
|
||||||
merchantData = self.parsePaymentRequest(options, pr);
|
merchantData = self.parsePaymentRequest(options, pr);
|
||||||
} catch (e) { err = e};
|
} catch (e) {
|
||||||
|
err = e
|
||||||
|
};
|
||||||
|
|
||||||
log.debug('PayPro request data', merchantData);
|
log.debug('PayPro request data', merchantData);
|
||||||
return cb(err, merchantData);
|
return cb(err, merchantData);
|
||||||
|
|
@ -1831,7 +1833,7 @@ Wallet.prototype.sendPaymentTx = function(ntxid, options, cb) {
|
||||||
ack = paypro.makePaymentACK(data);
|
ack = paypro.makePaymentACK(data);
|
||||||
return self.receivePaymentRequestACK(ntxid, tx, txp, ack, cb);
|
return self.receivePaymentRequestACK(ntxid, tx, txp, ack, cb);
|
||||||
})
|
})
|
||||||
.error(function(data, status ) {
|
.error(function(data, status) {
|
||||||
log.debug('Sending to server was not met with a returned tx.');
|
log.debug('Sending to server was not met with a returned tx.');
|
||||||
log.debug('XHR status: ' + status);
|
log.debug('XHR status: ' + status);
|
||||||
self._processTxProposalSent(ntxid, function(err, txid) {
|
self._processTxProposalSent(ntxid, function(err, txid) {
|
||||||
|
|
@ -2136,7 +2138,7 @@ Wallet.prototype.createTx = function(opts, cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var toAddress = opts.toAddress;
|
var toAddress = opts.toAddress;
|
||||||
var amountSat = opts.amountSat;
|
var amountSat = opts.amountSat;
|
||||||
preconditions.checkArgument(!opts.comment || opts.comment.length <= 100);
|
var comment = opts.comment;
|
||||||
var url = opts.url;
|
var url = opts.url;
|
||||||
|
|
||||||
if (url && !opts.merchantData) {
|
if (url && !opts.merchantData) {
|
||||||
|
|
@ -2148,7 +2150,7 @@ Wallet.prototype.createTx = function(opts, cb) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
opts.merchantData = merchantData;
|
opts.merchantData = merchantData;
|
||||||
opts.amountSat = merchantData.outs[0].address;
|
opts.amountSat = merchantData.outs[0].address;
|
||||||
opts.toAddress = merchantData.outs[0].amount;
|
opts.toAddress = merchantData.outs[0].amount;
|
||||||
self.createTx(opts, cb);
|
self.createTx(opts, cb);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -2158,19 +2160,21 @@ Wallet.prototype.createTx = function(opts, cb) {
|
||||||
this.getUnspent(function(err, safeUnspent) {
|
this.getUnspent(function(err, safeUnspent) {
|
||||||
if (err) return cb(new Error('Could not get list of UTXOs'));
|
if (err) return cb(new Error('Could not get list of UTXOs'));
|
||||||
|
|
||||||
var ntxid;
|
var ntxid, txp;
|
||||||
try {
|
try {
|
||||||
var txp = self.createTxProposal(toAddress, amountSat, safeUnspent, opts.builderOpts);
|
txp = self.createTxProposal(toAddress, amountSat, comment, safeUnspent, opts.builderOpts);
|
||||||
|
|
||||||
if (opts.merchantData)
|
|
||||||
txp.addMerchantData(opts.merchantData);
|
|
||||||
|
|
||||||
var ntxid = self.addNewTxProposal(txp);
|
|
||||||
log.debug('TXP Added: ', ntxid);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
log.error(e);
|
||||||
return cb(e);
|
return cb(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.merchantData)
|
||||||
|
txp.addMerchantData(opts.merchantData);
|
||||||
|
|
||||||
|
var ntxid = self.txProposals.add(txp);
|
||||||
|
log.debug('TXP Added: ', ntxid);
|
||||||
|
|
||||||
|
|
||||||
if (!ntxid) {
|
if (!ntxid) {
|
||||||
return cb(new Error('Error creating the transaction'));
|
return cb(new Error('Error creating the transaction'));
|
||||||
}
|
}
|
||||||
|
|
@ -2194,10 +2198,11 @@ var sanitize = function(address) {
|
||||||
* @desc Create a transaction proposal
|
* @desc Create a transaction proposal
|
||||||
* @TODO: Document more
|
* @TODO: Document more
|
||||||
*/
|
*/
|
||||||
Wallet.prototype.createTxProposal = function(toAddress, amountSat, utxos, builderOpts) {
|
Wallet.prototype.createTxProposal = function(toAddress, amountSat, comment, utxos, builderOpts) {
|
||||||
preconditions.checkArgument(toAddress);
|
preconditions.checkArgument(toAddress);
|
||||||
preconditions.checkArgument(amountSat);
|
preconditions.checkArgument(amountSat);
|
||||||
preconditions.checkArgument(_.isArray(utxos));
|
preconditions.checkArgument(_.isArray(utxos));
|
||||||
|
preconditions.checkArgument(!comment || comment.length <= 100, 'Comment too long');
|
||||||
builderOpts = builderOpts || {};
|
builderOpts = builderOpts || {};
|
||||||
|
|
||||||
var pkr = this.publicKeyRing;
|
var pkr = this.publicKeyRing;
|
||||||
|
|
@ -2257,32 +2262,11 @@ Wallet.prototype.createTxProposal = function(toAddress, amountSat, utxos, builde
|
||||||
inputChainPaths: inputChainPaths,
|
inputChainPaths: inputChainPaths,
|
||||||
comment: comment,
|
comment: comment,
|
||||||
builder: b,
|
builder: b,
|
||||||
|
creator: this.getMyCopayerId(),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* addNewTxProposal
|
|
||||||
* adds a transaction proposal to the list. Sets current copayer and creation metadata.
|
|
||||||
*
|
|
||||||
* @param {txp} Transaction Proposal Object
|
|
||||||
* @desc returns normalized transaction ID
|
|
||||||
* @param {ntxid}
|
|
||||||
*/
|
|
||||||
Wallet.prototype.addNewTxProposal = function(txp) {
|
|
||||||
var myId = this.getMyCopayerId();
|
|
||||||
var now = Date.now();
|
|
||||||
var me = {};
|
|
||||||
me[myId] = now;
|
|
||||||
|
|
||||||
// Add metadata to TxP
|
|
||||||
txp.signedBy = txp.seenBy = me;
|
|
||||||
txp.creator = myId;
|
|
||||||
txp.createdTs = now;
|
|
||||||
|
|
||||||
var ntxid = this.txProposals.add(txp);
|
|
||||||
return ntxid;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc Updates all the indexes for the current publicKeyRing. This scans
|
* @desc Updates all the indexes for the current publicKeyRing. This scans
|
||||||
* the blockchain looking for transactions on derived addresses.
|
* the blockchain looking for transactions on derived addresses.
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,7 @@ describe('Wallet model', function() {
|
||||||
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(1, true);
|
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(1, true);
|
||||||
|
|
||||||
var f = function() {
|
var f = function() {
|
||||||
var ntxid = w.createTxSync(
|
var ntxid = w.createTxProposal(
|
||||||
'15q6HKjWHAksHcH91JW23BJEuzZgFwydBt',
|
'15q6HKjWHAksHcH91JW23BJEuzZgFwydBt',
|
||||||
'123456789',
|
'123456789',
|
||||||
null,
|
null,
|
||||||
|
|
@ -233,18 +233,18 @@ describe('Wallet model', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
it('#create, check builder opts', function() {
|
it('#create, check builder opts', function() {
|
||||||
var w = cachedCreateW2();
|
var w = cachedCreateW2();
|
||||||
unspentTest[0].address = w.publicKeyRing.getAddress(1, true, w.publicKey).toString();
|
unspentTest[0].address = w.publicKeyRing.getAddress(1, true, w.publicKey).toString();
|
||||||
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(1, true, w.publicKey);
|
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(1, true, w.publicKey);
|
||||||
var ntxid = w.createTxSync(
|
var txp = w.createTxProposal(
|
||||||
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
|
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
|
||||||
'123456789',
|
'123456789',
|
||||||
null,
|
null,
|
||||||
unspentTest
|
unspentTest
|
||||||
);
|
);
|
||||||
var t = w.txProposals;
|
var opts = JSON.parse(txp.builder.vanilla.opts);
|
||||||
var opts = JSON.parse(t.txps[ntxid].builder.vanilla.opts);
|
|
||||||
opts.signhash.should.equal(1);
|
opts.signhash.should.equal(1);
|
||||||
(opts.lockTime === null).should.be.true;
|
(opts.lockTime === null).should.be.true;
|
||||||
should.not.exist(opts.fee);
|
should.not.exist(opts.fee);
|
||||||
|
|
@ -257,15 +257,13 @@ describe('Wallet model', function() {
|
||||||
unspentTest[0].address = w.publicKeyRing.getAddress(1, true, w.publicKey).toString();
|
unspentTest[0].address = w.publicKeyRing.getAddress(1, true, w.publicKey).toString();
|
||||||
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(1, true, w.publicKey);
|
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(1, true, w.publicKey);
|
||||||
|
|
||||||
var ntxid = w.createTxSync(
|
var txp = w.createTxProposal(
|
||||||
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
|
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
|
||||||
'123456789',
|
'123456789',
|
||||||
null,
|
null,
|
||||||
unspentTest
|
unspentTest
|
||||||
);
|
);
|
||||||
|
|
||||||
var t = w.txProposals;
|
|
||||||
var txp = t.txps[ntxid];
|
|
||||||
Object.keys(txp._inputSigners).length.should.equal(1);
|
Object.keys(txp._inputSigners).length.should.equal(1);
|
||||||
var tx = txp.builder.build();
|
var tx = txp.builder.build();
|
||||||
should.exist(tx);
|
should.exist(tx);
|
||||||
|
|
@ -282,15 +280,13 @@ describe('Wallet model', function() {
|
||||||
unspentTest[0].address = w.publicKeyRing.getAddress(1, true, w.publicKey).toString();
|
unspentTest[0].address = w.publicKeyRing.getAddress(1, true, w.publicKey).toString();
|
||||||
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(1, true, w.publicKey);
|
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(1, true, w.publicKey);
|
||||||
|
|
||||||
var ntxid = w.createTxSync(
|
var txp = w.createTxProposal(
|
||||||
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
|
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
|
||||||
'123456789',
|
'123456789',
|
||||||
comment,
|
comment,
|
||||||
unspentTest
|
unspentTest
|
||||||
);
|
);
|
||||||
|
|
||||||
var t = w.txProposals;
|
|
||||||
var txp = t.txps[ntxid];
|
|
||||||
var tx = txp.builder.build();
|
var tx = txp.builder.build();
|
||||||
should.exist(tx);
|
should.exist(tx);
|
||||||
txp.comment.should.equal(comment);
|
txp.comment.should.equal(comment);
|
||||||
|
|
@ -304,16 +300,14 @@ describe('Wallet model', function() {
|
||||||
unspentTest[0].address = w.publicKeyRing.getAddress(1, true, w.publicKey).toString();
|
unspentTest[0].address = w.publicKeyRing.getAddress(1, true, w.publicKey).toString();
|
||||||
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(1, true, w.publicKey);
|
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(1, true, w.publicKey);
|
||||||
|
|
||||||
var badCreate = function() {
|
(function() {
|
||||||
w.createTxSync(
|
w.createTxProposal(
|
||||||
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
|
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
|
||||||
'123456789',
|
'123456789',
|
||||||
comment,
|
comment,
|
||||||
unspentTest
|
unspentTest
|
||||||
);
|
);
|
||||||
}
|
}).should.throw('Comment');
|
||||||
|
|
||||||
chai.expect(badCreate).to.throw(Error);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('#addressIsOwn', function() {
|
it('#addressIsOwn', function() {
|
||||||
|
|
@ -336,21 +330,19 @@ describe('Wallet model', function() {
|
||||||
for (var index = 0; index < 3; index++) {
|
for (var index = 0; index < 3; index++) {
|
||||||
unspentTest[0].address = w.publicKeyRing.getAddress(index, isChange, w.publicKey).toString();
|
unspentTest[0].address = w.publicKeyRing.getAddress(index, isChange, w.publicKey).toString();
|
||||||
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(index, isChange, w.publicKey);
|
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(index, isChange, w.publicKey);
|
||||||
w.createTxSync(
|
var txp = w.createTxProposal(
|
||||||
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
|
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
|
||||||
'123456789',
|
'123456789',
|
||||||
null,
|
null,
|
||||||
unspentTest
|
unspentTest
|
||||||
);
|
);
|
||||||
var t = w.txProposals;
|
var tx = txp.builder.build();
|
||||||
var k = Object.keys(t.txps)[0];
|
|
||||||
var tx = t.txps[k].builder.build();
|
|
||||||
should.exist(tx);
|
should.exist(tx);
|
||||||
tx.isComplete().should.equal(false);
|
tx.isComplete().should.equal(false);
|
||||||
tx.countInputMissingSignatures(0).should.equal(2);
|
tx.countInputMissingSignatures(0).should.equal(2);
|
||||||
|
|
||||||
(t.txps[k].signedBy[w.privateKey.getId()] - ts > 0).should.equal(true);
|
(txp.signedBy[w.privateKey.getId()] - ts > 0).should.equal(true);
|
||||||
(t.txps[k].seenBy[w.privateKey.getId()] - ts > 0).should.equal(true);
|
(txp.seenBy[w.privateKey.getId()] - ts > 0).should.equal(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -774,7 +766,10 @@ describe('Wallet model', function() {
|
||||||
var w = cachedCreateW2();
|
var w = cachedCreateW2();
|
||||||
var utxo = createUTXO(w);
|
var utxo = createUTXO(w);
|
||||||
w.blockchain.fixUnspent(utxo);
|
w.blockchain.fixUnspent(utxo);
|
||||||
w.createTx(toAddress, amountSatStr, null, function(err, ntxid) {
|
w.createTx({
|
||||||
|
toAddress: toAddress,
|
||||||
|
amountSat: amountSatStr,
|
||||||
|
}, function(err, ntxid) {
|
||||||
ntxid.length.should.equal(64);
|
ntxid.length.should.equal(64);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
@ -788,7 +783,10 @@ describe('Wallet model', function() {
|
||||||
var w = createW2([k2]);
|
var w = createW2([k2]);
|
||||||
var utxo = createUTXO(w);
|
var utxo = createUTXO(w);
|
||||||
w.blockchain.fixUnspent(utxo);
|
w.blockchain.fixUnspent(utxo);
|
||||||
w.createTx(toAddress, amountSatStr, null, function(err, ntxid) {
|
w.createTx({
|
||||||
|
toAddress: toAddress,
|
||||||
|
amountSat: amountSatStr,
|
||||||
|
}, function(err, ntxid) {
|
||||||
w.on('txProposalsUpdated', function() {
|
w.on('txProposalsUpdated', function() {
|
||||||
w.getTxProposals()[0].signedByUs.should.equal(true);
|
w.getTxProposals()[0].signedByUs.should.equal(true);
|
||||||
w.getTxProposals()[0].rejectedByUs.should.equal(false);
|
w.getTxProposals()[0].rejectedByUs.should.equal(false);
|
||||||
|
|
@ -802,7 +800,10 @@ describe('Wallet model', function() {
|
||||||
var w = cachedCreateW2();
|
var w = cachedCreateW2();
|
||||||
var utxo = createUTXO(w);
|
var utxo = createUTXO(w);
|
||||||
w.blockchain.fixUnspent(utxo);
|
w.blockchain.fixUnspent(utxo);
|
||||||
w.createTx(toAddress, amountSatStr, null, function(err, ntxid) {
|
w.createTx({
|
||||||
|
toAddress: toAddress,
|
||||||
|
amountSat: amountSatStr,
|
||||||
|
}, function(err, ntxid) {
|
||||||
(function() {
|
(function() {
|
||||||
w.reject(ntxid);
|
w.reject(ntxid);
|
||||||
}).should.throw('reject a signed');
|
}).should.throw('reject a signed');
|
||||||
|
|
@ -814,7 +815,10 @@ describe('Wallet model', function() {
|
||||||
var oldK = w.privateKey;
|
var oldK = w.privateKey;
|
||||||
var utxo = createUTXO(w);
|
var utxo = createUTXO(w);
|
||||||
w.blockchain.fixUnspent(utxo);
|
w.blockchain.fixUnspent(utxo);
|
||||||
w.createTx(toAddress, amountSatStr, null, function(err, ntxid) {
|
w.createTx({
|
||||||
|
toAddress: toAddress,
|
||||||
|
amountSat: amountSatStr,
|
||||||
|
}, function(err, ntxid) {
|
||||||
var s = sinon.stub(w, 'getMyCopayerId').returns('213');
|
var s = sinon.stub(w, 'getMyCopayerId').returns('213');
|
||||||
Object.keys(w.txProposals.get(ntxid).rejectedBy).length.should.equal(0);
|
Object.keys(w.txProposals.get(ntxid).rejectedBy).length.should.equal(0);
|
||||||
w.reject(ntxid);
|
w.reject(ntxid);
|
||||||
|
|
@ -828,7 +832,10 @@ describe('Wallet model', function() {
|
||||||
var w = createW2(null, 1);
|
var w = createW2(null, 1);
|
||||||
var utxo = createUTXO(w);
|
var utxo = createUTXO(w);
|
||||||
w.blockchain.fixUnspent(utxo);
|
w.blockchain.fixUnspent(utxo);
|
||||||
w.createTx(toAddress, amountSatStr, null, function(err, ntxid) {
|
w.createTx({
|
||||||
|
toAddress: toAddress,
|
||||||
|
amountSat: amountSatStr,
|
||||||
|
}, function(err, ntxid) {
|
||||||
w.sendTx(ntxid, function(txid) {
|
w.sendTx(ntxid, function(txid) {
|
||||||
txid.length.should.equal(64);
|
txid.length.should.equal(64);
|
||||||
done();
|
done();
|
||||||
|
|
@ -839,7 +846,10 @@ describe('Wallet model', function() {
|
||||||
var w = createW2(null, 1);
|
var w = createW2(null, 1);
|
||||||
var utxo = createUTXO(w);
|
var utxo = createUTXO(w);
|
||||||
w.blockchain.fixUnspent(utxo);
|
w.blockchain.fixUnspent(utxo);
|
||||||
w.createTx(toAddress, amountSatStr, null, function(err, ntxid) {
|
w.createTx({
|
||||||
|
toAddress: toAddress,
|
||||||
|
amountSat: amountSatStr,
|
||||||
|
}, function(err, ntxid) {
|
||||||
var txp = w.txProposals.get(ntxid);
|
var txp = w.txProposals.get(ntxid);
|
||||||
// Assign fake builder
|
// Assign fake builder
|
||||||
txp.builder = new Builder();
|
txp.builder = new Builder();
|
||||||
|
|
@ -858,7 +868,10 @@ describe('Wallet model', function() {
|
||||||
var w = createW2(null, 1);
|
var w = createW2(null, 1);
|
||||||
var utxo = createUTXO(w);
|
var utxo = createUTXO(w);
|
||||||
w.blockchain.fixUnspent(utxo);
|
w.blockchain.fixUnspent(utxo);
|
||||||
w.createTx(toAddress, amountSatStr, null, function(err, ntxid) {
|
w.createTx({
|
||||||
|
toAddress: toAddress,
|
||||||
|
amountSat: amountSatStr,
|
||||||
|
}, function(err, ntxid) {
|
||||||
sinon.stub(w.blockchain, 'broadcast').yields({
|
sinon.stub(w.blockchain, 'broadcast').yields({
|
||||||
statusCode: 303
|
statusCode: 303
|
||||||
});
|
});
|
||||||
|
|
@ -872,7 +885,10 @@ describe('Wallet model', function() {
|
||||||
var w = cachedCreateW2();
|
var w = cachedCreateW2();
|
||||||
var utxo = createUTXO(w);
|
var utxo = createUTXO(w);
|
||||||
w.blockchain.fixUnspent(utxo);
|
w.blockchain.fixUnspent(utxo);
|
||||||
w.createTx(toAddress, amountSatStr, null, function(err, ntxid) {
|
w.createTx({
|
||||||
|
toAddress: toAddress,
|
||||||
|
amountSat: amountSatStr,
|
||||||
|
}, function(err, ntxid) {
|
||||||
w.sendTxProposal.bind(w).should.throw('Illegal Argument.');
|
w.sendTxProposal.bind(w).should.throw('Illegal Argument.');
|
||||||
(function() {
|
(function() {
|
||||||
w.sendTxProposal(ntxid);
|
w.sendTxProposal(ntxid);
|
||||||
|
|
@ -885,7 +901,10 @@ describe('Wallet model', function() {
|
||||||
var w = cachedCreateW2();
|
var w = cachedCreateW2();
|
||||||
var utxo = createUTXO(w);
|
var utxo = createUTXO(w);
|
||||||
w.blockchain.fixUnspent(utxo);
|
w.blockchain.fixUnspent(utxo);
|
||||||
w.createTx(toAddress, amountSatStr, null, function(err, ntxid) {
|
w.createTx({
|
||||||
|
toAddress: toAddress,
|
||||||
|
amountSat: amountSatStr,
|
||||||
|
}, function(err, ntxid) {
|
||||||
w.sendAllTxProposals.bind(w).should.not.throw();
|
w.sendAllTxProposals.bind(w).should.not.throw();
|
||||||
(function() {
|
(function() {
|
||||||
w.sendAllTxProposals();
|
w.sendAllTxProposals();
|
||||||
|
|
@ -900,7 +919,10 @@ describe('Wallet model', function() {
|
||||||
var utxo = createUTXO(w);
|
var utxo = createUTXO(w);
|
||||||
w.blockchain.fixUnspent(utxo);
|
w.blockchain.fixUnspent(utxo);
|
||||||
sinon.stub(w, 'getUnspent').yields('error', null);
|
sinon.stub(w, 'getUnspent').yields('error', null);
|
||||||
w.createTx(toAddress, amountSatStr, null, function(err, ntxid) {
|
w.createTx({
|
||||||
|
toAddress: toAddress,
|
||||||
|
amountSat: amountSatStr,
|
||||||
|
}, function(err, ntxid) {
|
||||||
chai.expect(err.message).to.equal('Could not get list of UTXOs');
|
chai.expect(err.message).to.equal('Could not get list of UTXOs');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
@ -2049,7 +2071,7 @@ describe('Wallet model', function() {
|
||||||
}];
|
}];
|
||||||
|
|
||||||
w.blockchain.getTransactions = sinon.stub().yields(null, {
|
w.blockchain.getTransactions = sinon.stub().yields(null, {
|
||||||
items: txs.slice(2,3),
|
items: txs.slice(2, 3),
|
||||||
totalItems: txs.length,
|
totalItems: txs.length,
|
||||||
});
|
});
|
||||||
w.getAddressesInfo = sinon.stub().returns([{
|
w.getAddressesInfo = sinon.stub().returns([{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue