Preserve sent timestamp for incoming proposals
This commit is contained in:
parent
71e6fce6e6
commit
9d5b26f526
3 changed files with 42 additions and 4 deletions
|
|
@ -255,7 +255,9 @@ TxProposal.prototype.setSent = function(sentTxid) {
|
||||||
this.sentTs = Date.now();
|
this.sentTs = Date.now();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TxProposal.prototype.getSent = function(sentTxid) {
|
||||||
|
return !!this.sentTxid;
|
||||||
|
}
|
||||||
|
|
||||||
TxProposal.prototype._allSignatures = function() {
|
TxProposal.prototype._allSignatures = function() {
|
||||||
var ret = {};
|
var ret = {};
|
||||||
|
|
|
||||||
|
|
@ -405,9 +405,11 @@ Wallet.prototype._onTxProposal = function(senderId, data) {
|
||||||
if (tx.isComplete()) {
|
if (tx.isComplete()) {
|
||||||
this._checkSentTx(m.ntxid, function(ret) {
|
this._checkSentTx(m.ntxid, function(ret) {
|
||||||
if (ret) {
|
if (ret) {
|
||||||
m.txp.setSent(m.ntxid);
|
if (!m.txp.getSent()) {
|
||||||
self.emit('txProposalsUpdated');
|
m.txp.setSent(m.ntxid);
|
||||||
self.store();
|
self.emit('txProposalsUpdated');
|
||||||
|
self.store();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1564,6 +1564,7 @@ describe('Wallet model', function() {
|
||||||
var txp = {
|
var txp = {
|
||||||
getSeen: sinon.stub().returns(true),
|
getSeen: sinon.stub().returns(true),
|
||||||
setCopayers: sinon.stub().returns(['new copayer']),
|
setCopayers: sinon.stub().returns(['new copayer']),
|
||||||
|
getSent: sinon.stub().returns(false),
|
||||||
setSent: sinon.spy(),
|
setSent: sinon.spy(),
|
||||||
builder: {
|
builder: {
|
||||||
build: sinon.stub().returns({
|
build: sinon.stub().returns({
|
||||||
|
|
@ -1595,6 +1596,7 @@ describe('Wallet model', function() {
|
||||||
var txp = {
|
var txp = {
|
||||||
getSeen: sinon.stub().returns(true),
|
getSeen: sinon.stub().returns(true),
|
||||||
setCopayers: sinon.stub().returns(['new copayer']),
|
setCopayers: sinon.stub().returns(['new copayer']),
|
||||||
|
getSent: sinon.stub().returns(false),
|
||||||
setSent: sinon.spy(),
|
setSent: sinon.spy(),
|
||||||
builder: {
|
builder: {
|
||||||
build: sinon.stub().returns({
|
build: sinon.stub().returns({
|
||||||
|
|
@ -1618,6 +1620,38 @@ describe('Wallet model', function() {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not overwrite sent info', function(done) {
|
||||||
|
var data = {
|
||||||
|
txProposal: {
|
||||||
|
dummy: 1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
var txp = {
|
||||||
|
getSeen: sinon.stub().returns(true),
|
||||||
|
setCopayers: sinon.stub().returns(['new copayer']),
|
||||||
|
getSent: sinon.stub().returns(true),
|
||||||
|
setSent: sinon.spy(),
|
||||||
|
builder: {
|
||||||
|
build: sinon.stub().returns({
|
||||||
|
isComplete: sinon.stub().returns(true),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
w.txProposals.merge = sinon.stub().returns({
|
||||||
|
ntxid: 1,
|
||||||
|
txp: txp,
|
||||||
|
new: false,
|
||||||
|
hasChanged: false,
|
||||||
|
});
|
||||||
|
w._checkSentTx = sinon.stub().yields(true);
|
||||||
|
|
||||||
|
w._onTxProposal('senderID', data);
|
||||||
|
txp.setSent.called.should.be.false;
|
||||||
|
w.sendTxProposal.called.should.be.false;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
it('should resend when not complete only if changed', function(done) {
|
it('should resend when not complete only if changed', function(done) {
|
||||||
var data = {
|
var data = {
|
||||||
txProposal: {
|
txProposal: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue