test broadcast fail with tx in blockchain

This commit is contained in:
Ivan Socolsky 2015-05-28 12:51:30 -03:00
parent 33827c5b18
commit 38d6ee83d3
1 changed files with 24 additions and 1 deletions

View File

@ -1662,7 +1662,7 @@ describe('Wallet service', function() {
});
});
it('should fail to brodcast an already broadcasted tx', function(done) {
it('should fail to brodcast a tx already marked as broadcasted', function(done) {
helpers.stubBroadcast('999');
server.broadcastTx({
txProposalId: txpid
@ -1696,6 +1696,7 @@ describe('Wallet service', function() {
it('should keep tx as accepted if unable to broadcast it', function(done) {
helpers.stubBroadcastFail();
blockchainExplorer.getTransaction = sinon.stub().callsArgWith(1, null, null);
server.broadcastTx({
txProposalId: txpid
}, function(err) {
@ -1713,6 +1714,28 @@ describe('Wallet service', function() {
});
});
});
it('should mark tx as broadcasted if accepted but already in blockchain', function(done) {
helpers.stubBroadcastFail();
blockchainExplorer.getTransaction = sinon.stub().callsArgWith(1, null, {
txid: '999'
});
server.broadcastTx({
txProposalId: txpid
}, function(err) {
should.not.exist(err);
server.getTx({
txProposalId: txpid
}, function(err, txp) {
should.not.exist(err);
should.exist(txp.txid);
txp.txid.should.equal('999');
txp.isBroadcasted().should.be.true;
should.exist(txp.broadcastedOn);
done();
});
});
});
});
describe('Tx proposal workflow', function() {