mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-19 18:45:52 +00:00
Made some changes to account_tx-test.js
This commit is contained in:
@@ -845,15 +845,14 @@ Remote.prototype.request_account_tx = function (obj) {
|
||||
//request.message.ledger = ledger_min;
|
||||
}
|
||||
else {
|
||||
if (obj.ledger_index_min) {request.message.ledger_index_min = obj.ledger_index_min;}
|
||||
if (obj.ledger_index_max) {request.message.ledger_index_max = obj.ledger_index_max;}
|
||||
if (obj.binary) {request.message.binary = obj.binary;}
|
||||
if (obj.count) {request.message.count = obj.count;}
|
||||
if (obj.descending) {request.message.descending = obj.descending;}
|
||||
if (obj.offset) {request.message.offset = obj.offset;}
|
||||
if (obj.limit) {request.message.limit = obj.limit;}
|
||||
if ("undefined" != typeof obj.ledger_index_min) {request.message.ledger_index_min = obj.ledger_index_min;}
|
||||
if ("undefined" != typeof obj.ledger_index_max) {request.message.ledger_index_max = obj.ledger_index_max;}
|
||||
if ("undefined" != typeof obj.binary) {request.message.binary = obj.binary;}
|
||||
if ("undefined" != typeof obj.count) {request.message.count = obj.count;}
|
||||
if ("undefined" != typeof obj.descending) {request.message.descending = obj.descending;}
|
||||
if ("undefined" != typeof obj.offset) {request.message.offset = obj.offset;}
|
||||
if ("undefined" != typeof obj.limit) {request.message.limit = obj.limit;}
|
||||
}
|
||||
|
||||
return request;
|
||||
};
|
||||
|
||||
|
||||
@@ -18,13 +18,13 @@ var BINARY_LIMIT = 500;
|
||||
var NONBINARY_LIMIT = 200;
|
||||
|
||||
var ACCOUNT = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
|
||||
var FIRST_BATCH = 199; // Within both limits
|
||||
var OFFSET = 180;
|
||||
var LIMIT = 170;
|
||||
var FIRST_BATCH = 19;//199; // Within both limits
|
||||
var OFFSET = 1;//18;//0;
|
||||
var LIMIT = 100;//17;//0;
|
||||
var SECOND_BATCH = 10; // Between NONBINARY_LIMIT and BINARY_LIMIT
|
||||
var THIRD_BATCH = 295; // Exceeds both limits
|
||||
var THIRD_BATCH = 29;//295; // Exceeds both limits
|
||||
|
||||
buster.testCase("// Account_tx tests", {
|
||||
buster.testCase("Account_tx tests", {
|
||||
'setUp' : testutils.build_setup(),
|
||||
'tearDown' : testutils.build_teardown(),
|
||||
|
||||
@@ -32,20 +32,28 @@ buster.testCase("// Account_tx tests", {
|
||||
function (done) {
|
||||
var self = this;
|
||||
var final_create;
|
||||
|
||||
var transactionCounter = 0;
|
||||
|
||||
var f = 0;
|
||||
var functionHolder;
|
||||
var createOfferFunction = function (callback) {
|
||||
self.remote.transaction()
|
||||
.offer_create("root", "500", "100/USD/root")
|
||||
.on('proposed', function (m) {
|
||||
transactionCounter++;
|
||||
console.log('Submitted transaction', transactionCounter);
|
||||
|
||||
callback(m.result !== 'tesSUCCESS');
|
||||
})
|
||||
.on('final', function (m) {
|
||||
f++;
|
||||
console.log("FINALIZED TRANSACTION:", f);
|
||||
buster.assert.equals('tesSUCCESS', m.metadata.TransactionResult);
|
||||
buster.assert(final_create);
|
||||
if ( f == transactionCounter ) {
|
||||
console.log(m);
|
||||
console.log("ALL TRANSACTIONS HAVE BEEN FINALIZED");
|
||||
functionHolder();
|
||||
}
|
||||
})
|
||||
.submit();
|
||||
};
|
||||
@@ -55,36 +63,37 @@ buster.testCase("// Account_tx tests", {
|
||||
for (var i=0; i<number; i++) {
|
||||
bunchOfOffers.push(createOfferFunction);
|
||||
}
|
||||
functionHolder = whenDone; //lolwut
|
||||
async.parallel(bunchOfOffers, function (error) {
|
||||
console.log("ABOUT TO ACCEPT LEDGER.");
|
||||
buster.refute(error);
|
||||
self.remote
|
||||
.once('ledger_closed', function (message) {
|
||||
final_create = message;
|
||||
})
|
||||
.ledger_accept();
|
||||
whenDone();
|
||||
});
|
||||
}
|
||||
|
||||
function firstBatch() {
|
||||
lotsOfTransactions(FIRST_BATCH,
|
||||
function(){runTests(self, FIRST_BATCH, 0, 0,
|
||||
function(){runTests(self, FIRST_BATCH, OFFSET, 0,
|
||||
function(){runTests(self, FIRST_BATCH, 0, LIMIT, secondBatch)})}
|
||||
function(){runTests(self, FIRST_BATCH, undefined, undefined,
|
||||
function(){runTests(self, FIRST_BATCH, OFFSET, 0,
|
||||
function(){runTests(self, FIRST_BATCH, undefined, LIMIT, secondBatch)})}
|
||||
)});
|
||||
}
|
||||
|
||||
function secondBatch() {
|
||||
lotsOfTransactions(SECOND_BATCH,
|
||||
function(){runTests(self, FIRST_BATCH+SECOND_BATCH, 0, 0,
|
||||
function(){runTests(self, FIRST_BATCH+SECOND_BATCH, OFFSET, 0, thirdBatch)}
|
||||
function(){runTests(self, FIRST_BATCH+SECOND_BATCH, undefined, undefined,
|
||||
function(){runTests(self, FIRST_BATCH+SECOND_BATCH, OFFSET, undefined, thirdBatch)}
|
||||
)});
|
||||
}
|
||||
|
||||
function thirdBatch() {
|
||||
lotsOfTransactions(THIRD_BATCH,
|
||||
function(){runTests(self, FIRST_BATCH+SECOND_BATCH+THIRD_BATCH, 0, 0,
|
||||
function(){runTests(self, FIRST_BATCH+SECOND_BATCH+THIRD_BATCH, OFFSET, 0, done)}
|
||||
function(){runTests(self, FIRST_BATCH+SECOND_BATCH+THIRD_BATCH, undefined, undefined,
|
||||
function(){runTests(self, FIRST_BATCH+SECOND_BATCH+THIRD_BATCH, OFFSET, undefined, done)}
|
||||
)});
|
||||
}
|
||||
|
||||
@@ -108,21 +117,25 @@ buster.testCase("// Account_tx tests", {
|
||||
self.remote.request_account_tx({
|
||||
account:ACCOUNT,
|
||||
ledger_index_min:0,
|
||||
ledger_index_max:5,
|
||||
ledger_index_max:100,
|
||||
offset:offset,
|
||||
limit:limit
|
||||
}).on('success', function (r) {
|
||||
buster.assert(r.transactions, "No transactions returned.");
|
||||
var targetLength = Math.min(NONBINARY_LIMIT, limit ? Math.min(limit,actualNumberOfTransactions-offset) : actualNumberOfTransactions-offset);
|
||||
buster.assert(r.transactions.length == targetLength, "Got "+r.transactions.length+" transactions; expected "+targetLength );
|
||||
|
||||
//Check for proper ordering.
|
||||
for (var i=0; i<r.transactions.length-1; i++) {
|
||||
var t1 = r.transactions[i].tx;
|
||||
var t2 = r.transactions[i+1].tx;
|
||||
buster.assert(t1.inLedger<t2.inLedger || (t1.inLedger==t2.inLedger && t1.hash < t2.hash ),
|
||||
"Transactions were not ordered correctly: "+t1.inLedger+"#"+t1.hash+" should not have come before "+t2.inLedger+"#"+t2.hash);
|
||||
console.log("GOT STUFF!",r);
|
||||
if (r.transactions) {
|
||||
var targetLength = Math.min(NONBINARY_LIMIT, limit ? Math.min(limit,actualNumberOfTransactions-offset) : actualNumberOfTransactions-offset);
|
||||
buster.assert(r.transactions.length == targetLength, "Got "+r.transactions.length+" transactions; expected "+targetLength );
|
||||
//Check for proper ordering.
|
||||
for (var i=0; i<r.transactions.length-1; i++) {
|
||||
var t1 = r.transactions[i].tx;
|
||||
var t2 = r.transactions[i+1].tx;
|
||||
buster.assert(t1.inLedger<t2.inLedger || (t1.inLedger==t2.inLedger && t1.hash < t2.hash ),
|
||||
"Transactions were not ordered correctly: "+t1.inLedger+"#"+t1.hash+" should not have come before "+t2.inLedger+"#"+t2.hash);
|
||||
}
|
||||
} else {
|
||||
buster.assert(r.transactions, "No transactions returned: "+offset+" "+limit);
|
||||
}
|
||||
|
||||
callback(false);
|
||||
})
|
||||
.on('error', standardErrorHandler(callback))
|
||||
@@ -134,14 +147,18 @@ buster.testCase("// Account_tx tests", {
|
||||
self.remote.request_account_tx({
|
||||
account:ACCOUNT,
|
||||
ledger_index_min:0,
|
||||
ledger_index_max:5,
|
||||
ledger_index_max:100,
|
||||
binary:true,
|
||||
offset:offset,
|
||||
limit:limit
|
||||
}).on('success', function (r) {
|
||||
buster.assert(r.transactions, "No transactions returned.");
|
||||
var targetLength = Math.min(BINARY_LIMIT, limit ? Math.min(limit,actualNumberOfTransactions-offset) : actualNumberOfTransactions-offset);
|
||||
buster.assert(r.transactions.length == targetLength, "Got "+r.transactions.length+" transactions; expected "+targetLength );
|
||||
console.log("GOT STUFF!",r);
|
||||
if (r.transactions) {
|
||||
var targetLength = Math.min(BINARY_LIMIT, limit ? Math.min(limit,actualNumberOfTransactions-offset) : actualNumberOfTransactions-offset);
|
||||
buster.assert(r.transactions.length == targetLength, "Got "+r.transactions.length+" transactions; expected "+targetLength );
|
||||
} else {
|
||||
buster.assert(r.transactions, "No transactions returned: "+offset+" "+limit);
|
||||
}
|
||||
callback(false);
|
||||
})
|
||||
.on('error', standardErrorHandler(callback))
|
||||
@@ -153,21 +170,27 @@ buster.testCase("// Account_tx tests", {
|
||||
self.remote.request_account_tx({
|
||||
account:ACCOUNT,
|
||||
ledger_index_min:0,
|
||||
ledger_index_max:5,
|
||||
ledger_index_max:100,
|
||||
descending:true,
|
||||
offset:offset,
|
||||
limit:limit
|
||||
}).on('success', function (r) {
|
||||
buster.assert(r.transactions, "No transactions returned.");
|
||||
var targetLength = Math.min(NONBINARY_LIMIT, limit ? Math.min(limit,actualNumberOfTransactions-offset) : actualNumberOfTransactions-offset );
|
||||
buster.assert(r.transactions.length == targetLength, "Got "+r.transactions.length+" transactions; expected "+targetLength );
|
||||
//Check for proper ordering.
|
||||
for (var i=0; i<r.transactions.length-1; i++) {
|
||||
var t1 = r.transactions[i].tx;
|
||||
var t2 = r.transactions[i+1].tx;
|
||||
buster.assert(t1.inLedger>t2.inLedger || (t1.inLedger==t2.inLedger && t1.hash > t2.hash ),
|
||||
"Transactions were not ordered correctly: "+t1.inLedger+"#"+t1.hash+" should not have come before "+t2.inLedger+"#"+t2.hash);
|
||||
console.log("GOT STUFF!",r);
|
||||
if (r.transactions) {
|
||||
var targetLength = Math.min(NONBINARY_LIMIT, limit ? Math.min(limit,actualNumberOfTransactions-offset) : actualNumberOfTransactions-offset );
|
||||
buster.assert(r.transactions.length == targetLength, "Got "+r.transactions.length+" transactions; expected "+targetLength );
|
||||
//Check for proper ordering.
|
||||
for (var i=0; i<r.transactions.length-1; i++) {
|
||||
var t1 = r.transactions[i].tx;
|
||||
var t2 = r.transactions[i+1].tx;
|
||||
buster.assert(t1.inLedger>t2.inLedger || (t1.inLedger==t2.inLedger && t1.hash > t2.hash ),
|
||||
"Transactions were not ordered correctly: "+t1.inLedger+"#"+t1.hash+" should not have come before "+t2.inLedger+"#"+t2.hash);
|
||||
}
|
||||
} else {
|
||||
buster.assert(r.transactions, "No transactions returned: "+offset+" "+limit);
|
||||
}
|
||||
|
||||
|
||||
callback(false);
|
||||
})
|
||||
.on('error', standardErrorHandler(callback))
|
||||
|
||||
Reference in New Issue
Block a user