This commit is contained in:
parent
8c8c7e51fb
commit
4fcbadddf7
|
@ -1,5 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
var _ = require('lodash');
|
||||
|
||||
var TxProposalAction = require('./txproposalaction');
|
||||
|
||||
function TxProposal(opts) {
|
||||
|
|
|
@ -267,7 +267,7 @@ CopayServer.prototype.createTx = function (opts, cb) {
|
|||
});
|
||||
txp.rawTx = self._createRawTx(txp);
|
||||
|
||||
self.storage.storeTx(txp, function (err) {
|
||||
self.storage.storeTx(wallet.id, txp, function (err) {
|
||||
if (err) return cb(err);
|
||||
|
||||
return cb(null, txp);
|
||||
|
|
|
@ -28,7 +28,7 @@ Storage.prototype.fetchWallet = function (id, cb) {
|
|||
};
|
||||
|
||||
Storage.prototype.fetchTx = function (walletId, txProposalId, cb) {
|
||||
this.db.get('wallet-' + walletId + '-tx-' + txProposalId, function (err, data) {
|
||||
this.db.get('wallet-' + walletId + '-txp-' + txProposalId, function (err, data) {
|
||||
if (err) {
|
||||
if (err.notFound) return cb();
|
||||
return cb(err);
|
||||
|
@ -45,8 +45,8 @@ Storage.prototype.storeAddress = function (walletId, address, cb) {
|
|||
this.db.put('wallet-' + walletId + '-address-' + address.address, address, cb);
|
||||
};
|
||||
|
||||
Storage.prototype.storeTx = function (walletId, tx, cb) {
|
||||
this.db.put('wallet-' + walletId + '-tx-' + tx.txProposalId, tx, cb);
|
||||
Storage.prototype.storeTx = function (walletId, txp, cb) {
|
||||
this.db.put('wallet-' + walletId + '-txp-' + txp.txProposalId, txp, cb);
|
||||
};
|
||||
|
||||
Storage.prototype.fetchAddresses = function (walletId, cb) {
|
||||
|
|
|
@ -398,11 +398,13 @@ describe('Copay server', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it.skip('should create tx', function (done) {
|
||||
it('should create tx', function (done) {
|
||||
var bc = sinon.stub();
|
||||
bc.getUnspentUtxos = sinon.stub().yields(null, ['utxo1', 'utxo2']);
|
||||
bc.getUnspentUtxos = sinon.stub().callsArgWith(1, null, ['utxo1', 'utxo2']);
|
||||
server._getBlockExplorer = sinon.stub().returns(bc);
|
||||
|
||||
server._createRawTx = sinon.stub().returns('raw');
|
||||
|
||||
var txOpts = {
|
||||
copayerId: '1',
|
||||
walletId: '123',
|
||||
|
@ -415,7 +417,9 @@ describe('Copay server', function() {
|
|||
server.createTx(txOpts, function (err, tx) {
|
||||
should.not.exist(err);
|
||||
tx.should.exist;
|
||||
tx.raw.should.exist;
|
||||
tx.rawTx.should.equal('raw');
|
||||
tx.isAccepted().should.equal.false;
|
||||
tx.isRejected().should.equal.false;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue