fix broadcasting new proposals
This commit is contained in:
parent
8cf56c2a3d
commit
23cddbe47f
|
@ -209,6 +209,10 @@ TxProposal.prototype.getBitcoreTx = function() {
|
||||||
return t;
|
return t;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TxProposal.prototype.getNetworkName = function() {
|
||||||
|
return this.network;
|
||||||
|
};
|
||||||
|
|
||||||
TxProposal.prototype.getRawTx = function() {
|
TxProposal.prototype.getRawTx = function() {
|
||||||
var t = this.getBitcoreTx();
|
var t = this.getBitcoreTx();
|
||||||
|
|
||||||
|
|
|
@ -468,4 +468,15 @@ helpers.createAddresses = function(server, wallet, main, change, cb) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
helpers.createAndPublishTx = function(server, txOpts, signingKey, cb) {
|
||||||
|
server.createTx(txOpts, function(err, txp) {
|
||||||
|
should.not.exist(err);
|
||||||
|
var publishOpts = helpers.getProposalSignatureOpts(txp, signingKey);
|
||||||
|
server.publishTx(publishOpts, function(err) {
|
||||||
|
should.not.exist(err);
|
||||||
|
return cb(txp);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = helpers;
|
module.exports = helpers;
|
||||||
|
|
|
@ -3429,6 +3429,8 @@ describe('Wallet service', function() {
|
||||||
|
|
||||||
describe('#broadcastTx & #broadcastRawTx', function() {
|
describe('#broadcastTx & #broadcastRawTx', function() {
|
||||||
var server, wallet, txpid, txid;
|
var server, wallet, txpid, txid;
|
||||||
|
describe('Legacy', function() {
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
helpers.createAndJoinWallet(1, 1, function(s, w) {
|
helpers.createAndJoinWallet(1, 1, function(s, w) {
|
||||||
server = s;
|
server = s;
|
||||||
|
@ -3547,10 +3549,6 @@ describe('Wallet service', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
it('should fail to brodcast a not yet accepted tx', function(done) {
|
it('should fail to brodcast a not yet accepted tx', function(done) {
|
||||||
helpers.stubBroadcast();
|
helpers.stubBroadcast();
|
||||||
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 9, TestData.copayers[0].privKey_1H_0, {
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 9, TestData.copayers[0].privKey_1H_0, {
|
||||||
|
@ -3633,6 +3631,63 @@ describe('Wallet service', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('New', function() {
|
||||||
|
beforeEach(function(done) {
|
||||||
|
helpers.createAndJoinWallet(1, 1, function(s, w) {
|
||||||
|
server = s;
|
||||||
|
wallet = w;
|
||||||
|
helpers.stubUtxos(server, wallet, [10, 10], function() {
|
||||||
|
var txOpts = {
|
||||||
|
outputs: [{
|
||||||
|
toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7',
|
||||||
|
amount: 9e8,
|
||||||
|
}],
|
||||||
|
message: 'some message',
|
||||||
|
};
|
||||||
|
helpers.createAndPublishTx(server, txOpts, TestData.copayers[0].privKey_1H_0, function(txp) {
|
||||||
|
should.exist(txp);
|
||||||
|
var signatures = helpers.clientSign(txp, TestData.copayers[0].xPrivKey_44H_0H_0H);
|
||||||
|
server.signTx({
|
||||||
|
txProposalId: txp.id,
|
||||||
|
signatures: signatures,
|
||||||
|
}, function(err, txp) {
|
||||||
|
should.not.exist(err);
|
||||||
|
should.exist(txp);
|
||||||
|
txp.isAccepted().should.be.true;
|
||||||
|
txp.isBroadcasted().should.be.false;
|
||||||
|
txid = txp.txid;
|
||||||
|
txpid = txp.id;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should broadcast a tx', function(done) {
|
||||||
|
var clock = sinon.useFakeTimers(1234000, 'Date');
|
||||||
|
helpers.stubBroadcast();
|
||||||
|
server.broadcastTx({
|
||||||
|
txProposalId: txpid
|
||||||
|
}, function(err) {
|
||||||
|
should.not.exist(err);
|
||||||
|
server.getTx({
|
||||||
|
txProposalId: txpid
|
||||||
|
}, function(err, txp) {
|
||||||
|
should.not.exist(err);
|
||||||
|
should.not.exist(txp.raw);
|
||||||
|
txp.txid.should.equal(txid);
|
||||||
|
txp.isBroadcasted().should.be.true;
|
||||||
|
txp.broadcastedOn.should.equal(1234);
|
||||||
|
clock.restore();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('Tx proposal workflow', function() {
|
describe('Tx proposal workflow', function() {
|
||||||
var server, wallet;
|
var server, wallet;
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
|
|
Loading…
Reference in New Issue