mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 20:25:48 +00:00
Relocate presubmit emission to immediately before transaction submit
This commit is contained in:
@@ -365,8 +365,6 @@ TransactionManager.prototype._request = function(tx) {
|
|||||||
return tx.emit('error', new RippleError('tejLocalSigningRequired', message));
|
return tx.emit('error', new RippleError('tejLocalSigningRequired', message));
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.emit('presubmit');
|
|
||||||
|
|
||||||
if (tx.finalized) {
|
if (tx.finalized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -557,9 +555,11 @@ TransactionManager.prototype._request = function(tx) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
submitRequest.timeout(self._submissionTimeout, requestTimeout);
|
tx.emit('presubmit');
|
||||||
tx.submissions = submitRequest.broadcast();
|
|
||||||
|
|
||||||
|
submitRequest.timeout(self._submissionTimeout, requestTimeout);
|
||||||
|
|
||||||
|
tx.submissions = submitRequest.broadcast();
|
||||||
tx.attempts++;
|
tx.attempts++;
|
||||||
tx.emit('postsubmit');
|
tx.emit('postsubmit');
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1560,33 +1560,34 @@ describe('Transaction', function() {
|
|||||||
transaction.submit();
|
transaction.submit();
|
||||||
});
|
});
|
||||||
|
|
||||||
it.skip('Abort submission', function(done) {
|
it('Abort submission on presubmit', function(done) {
|
||||||
var remote = new Remote();
|
var remote = new Remote();
|
||||||
var transaction = new Transaction(remote).accountSet('r36xtKNKR43SeXnGn7kN4r4JdQzcrkqpWe');
|
remote.setSecret('rJaT8TafQfYJqDm8aC5n3Yx5yWEL2Ery79', 'snPwFATthTkKnGjEW73q3TL4yci1Q');
|
||||||
var account = remote.addAccount('r36xtKNKR43SeXnGn7kN4r4JdQzcrkqpWe');
|
|
||||||
|
var server = new Server(remote, 'wss://s1.ripple.com:443');
|
||||||
|
server._computeFee = function() { return '12'; };
|
||||||
|
server._connected = true;
|
||||||
|
|
||||||
|
remote._servers.push(server);
|
||||||
|
remote._connected = true;
|
||||||
|
remote._ledger_current_index = 1;
|
||||||
|
|
||||||
|
var transaction = new Transaction(remote).accountSet('rJaT8TafQfYJqDm8aC5n3Yx5yWEL2Ery79');
|
||||||
|
var account = remote.account('rJaT8TafQfYJqDm8aC5n3Yx5yWEL2Ery79');
|
||||||
|
|
||||||
account._transactionManager._nextSequence = 1;
|
account._transactionManager._nextSequence = 1;
|
||||||
|
|
||||||
account._transactionManager._request = function(tx) {
|
transaction.once('presubmit', function() {
|
||||||
setTimeout(function() {
|
transaction.abort();
|
||||||
tx.emit('success', { });
|
});
|
||||||
}, 20);
|
|
||||||
};
|
|
||||||
|
|
||||||
transaction.complete = function() {
|
transaction.submit(function(err, res) {
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
function submitCallback(err, res) {
|
|
||||||
setImmediate(function() {
|
setImmediate(function() {
|
||||||
assert(err);
|
assert(err);
|
||||||
assert.strictEqual(err.result, 'tejAbort');
|
assert.strictEqual(err.result, 'tejAbort');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
};
|
});
|
||||||
|
|
||||||
transaction.submit(submitCallback);
|
|
||||||
transaction.abort();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user