Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wltsmrz committed Jun 5, 2014
1 parent 44a9724 commit e49bb4e
Show file tree
Hide file tree
Showing 6 changed files with 707 additions and 129 deletions.
4 changes: 2 additions & 2 deletions src/js/ripple/request.js
Expand Up @@ -199,7 +199,7 @@ Request.prototype.ledgerSelect = function(ledger) {
switch (ledger) {
case 'current':
case 'closed':
case 'verified':
case 'validated':
this.message.ledger_index = ledger;
break;

Expand Down Expand Up @@ -327,7 +327,7 @@ Request.prototype.books = function(books, snapshot) {
return this;
};

Request.prototype.addBook = function (book, snapshot) {
Request.prototype.addBook = function(book, snapshot) {
if (!Array.isArray(this.message.books)) {
this.message.books = [ ];
}
Expand Down
29 changes: 19 additions & 10 deletions src/js/ripple/transactionqueue.js
Expand Up @@ -4,6 +4,7 @@
*/

var LRU = require('lru-cache');
var Transaction = require('./transaction').Transaction;

function TransactionQueue() {
this._queue = [ ];
Expand All @@ -19,6 +20,15 @@ TransactionQueue.prototype.addReceivedSequence = function(sequence) {
this._sequenceCache.set(String(sequence), true);
};

/**
* Check that sequence number has been consumed by a validated
* transaction
*/

TransactionQueue.prototype.hasSequence = function(sequence) {
return this._sequenceCache.has(String(sequence));
};

/**
* Store received (validated) ID transaction
*/
Expand All @@ -35,22 +45,13 @@ TransactionQueue.prototype.getReceived = function(id) {
return this._idCache.get(id);
};

/**
* Check that sequence number has been consumed by a validated
* transaction
*/

TransactionQueue.prototype.hasSequence = function(sequence) {
return this._sequenceCache.has(String(sequence));
};

/**
* Get a submitted transaction by ID. Transactions
* may have multiple associated IDs.
*/

TransactionQueue.prototype.getSubmission = function(id) {
var result = false;
var result = void(0);

for (var i=0, tx; (tx=this._queue[i]); i++) {
if (~tx.submittedIDs.indexOf(id)) {
Expand All @@ -70,6 +71,14 @@ TransactionQueue.prototype.remove = function(tx) {
// ND: We are just removing the Transaction by identity
var i = this._queue.length;

if (typeof tx === 'string') {
tx = this.getSubmission(tx);
}

if (!(tx instanceof Transaction)) {
return;
}

while (i--) {
if (this._queue[i] === tx) {
this._queue.splice(i, 1);
Expand Down

0 comments on commit e49bb4e

Please sign in to comment.