JS & UT: add et to vim setting.

This commit is contained in:
Arthur Britto
2012-11-24 14:07:21 -08:00
committed by Stefan Thomas
parent 4467ef62d3
commit 184c059354
13 changed files with 116 additions and 115 deletions

View File

@@ -22,4 +22,4 @@ var Account = function (network, account) {
exports.Account = Account; exports.Account = Account;
// vim:sw=2:sts=2:ts=8 // vim:sw=2:sts=2:ts=8:et

View File

@@ -727,4 +727,4 @@ exports.UInt160 = UInt160;
exports.config = {}; exports.config = {};
// vim:sw=2:sts=2:ts=8 // vim:sw=2:sts=2:ts=8:et

View File

@@ -1216,4 +1216,4 @@ BigInteger.ONE = nbv(1);
exports.nbi = nbi; exports.nbi = nbi;
exports.BigInteger = BigInteger; exports.BigInteger = BigInteger;
// vim:sw=2:sts=2:ts=8 // vim:sw=2:sts=2:ts=8:et

View File

@@ -55,4 +55,4 @@ Network.protocol.stop = function () {
exports.Network = Network; exports.Network = Network;
// vim:sw=2:sts=2:ts=8 // vim:sw=2:sts=2:ts=8:et

View File

@@ -88,4 +88,4 @@ exports.mkPath = mkPath;
exports.resetPath = resetPath; exports.resetPath = resetPath;
exports.rmPath = rmPath; exports.rmPath = rmPath;
// vim:sw=2:sts=2:ts=8 // vim:sw=2:sts=2:ts=8:et

View File

@@ -1489,4 +1489,4 @@ Transaction.prototype.wallet_add = function (src, amount, authorized_key, public
exports.config = {}; exports.config = {};
exports.Remote = Remote; exports.Remote = Remote;
// vim:sw=2:sts=2:ts=8 // vim:sw=2:sts=2:ts=8:et

View File

@@ -41,4 +41,4 @@ serializer.addUInt160 = function(value) {
serializer.getSHA512Half = function() { serializer.getSHA512Half = function() {
}; };
// vim:ts=4 // vim:sw=2:sts=2:ts=8:et

View File

@@ -76,4 +76,4 @@ exports.hexToString = hexToString;
exports.stringToArray = stringToArray; exports.stringToArray = stringToArray;
exports.stringToHex = stringToHex; exports.stringToHex = stringToHex;
// vim:sw=2:sts=2:ts=8 // vim:sw=2:sts=2:ts=8:et

View File

@@ -1,12 +1,12 @@
var buster = require("buster"); var buster = require("buster");
var jsbn = require('../src/js/jsbn.js'); var jsbn = require('../src/js/jsbn.js');
var BigInteger = jsbn.BigInteger; var BigInteger = jsbn.BigInteger;
var nbi = jsbn.nbi; var nbi = jsbn.nbi;
var amount = require("../src/js/amount.js"); var amount = require("../src/js/amount.js");
var Amount = require("../src/js/amount.js").Amount; var Amount = require("../src/js/amount.js").Amount;
var UInt160 = require("../src/js/amount.js").UInt160; var UInt160 = require("../src/js/amount.js").UInt160;
require("../src/js/amount.js").config = require("./config.js"); require("../src/js/amount.js").config = require("./config.js");
@@ -107,4 +107,4 @@ buster.testCase("Amount", {
} }
}); });
// vim:sw=2:sts=2:ts=8 // vim:sw=2:sts=2:ts=8:et

View File

@@ -4,6 +4,8 @@ config["Newcoin tests"] = {
rootPath: "../", rootPath: "../",
environment: "node", environment: "node",
tests: [ tests: [
"test/*-test.js" "test/*-test.js"
] ]
} }
// vim:sw=2:sts=2:ts=8:et

View File

@@ -7,7 +7,7 @@ var path = require("path");
// Where to find the binary. // Where to find the binary.
exports.rippled = path.resolve("build/rippled"); exports.rippled = path.resolve("build/rippled");
exports.server_default = "alpha"; exports.server_default = "alpha";
// Configuration for servers. // Configuration for servers.
exports.servers = { exports.servers = {
@@ -66,4 +66,4 @@ exports.accounts = {
}, },
}; };
// vim:sw=2:sts=2:ts=8 // vim:sw=2:sts=2:ts=8:et

View File

@@ -1,5 +1,4 @@
var async = require("async"); var async = require("async");
// var buster = require("buster");
var Amount = require("../src/js/amount.js").Amount; var Amount = require("../src/js/amount.js").Amount;
var Remote = require("../src/js/remote.js").Remote; var Remote = require("../src/js/remote.js").Remote;
@@ -15,24 +14,24 @@ var account_dump = function (remote, account, callback) {
async.waterfall([ async.waterfall([
function (callback) { function (callback) {
self.what = "Get latest account_root"; self.what = "Get latest account_root";
remote remote
.request_ledger_entry('account_root') .request_ledger_entry('account_root')
.ledger_hash(remote.ledger_hash()) .ledger_hash(remote.ledger_hash())
.account_root("root") .account_root("root")
.on('success', function (r) { .on('success', function (r) {
//console.log("account_root: %s", JSON.stringify(r, undefined, 2)); //console.log("account_root: %s", JSON.stringify(r, undefined, 2));
callback(); callback();
}) })
.on('error', function(m) { .on('error', function(m) {
console.log("error: %s", m); console.log("error: %s", m);
buster.assert(false); buster.assert(false);
callback(); callback();
}) })
.request(); .request();
}, },
], function (error) { ], function (error) {
callback(error); callback(error);
@@ -106,10 +105,10 @@ var build_setup = function (opts, host) {
* @param host {String} Identifier for the host configuration to be used. * @param host {String} Identifier for the host configuration to be used.
*/ */
var build_teardown = function (host) { var build_teardown = function (host) {
return function (done) { return function (done) {
host = host || config.server_default; host = host || config.server_default;
var data = this.store[host]; var data = this.store[host];
@@ -117,22 +116,22 @@ var build_teardown = function (host) {
async.series([ async.series([
function disconnectWebsocketStep(callback) { function disconnectWebsocketStep(callback) {
data.remote data.remote
.on('disconnected', callback) .on('disconnected', callback)
.connect(false); .connect(false);
}, },
function stopServerStep(callback) { function stopServerStep(callback) {
if (opts.no_server) if (opts.no_server)
{ {
return callback(); return callback();
} }
data.server.on('stopped', callback).stop(); data.server.on('stopped', callback).stop();
} }
], done); ], done);
}; };
}; };
@@ -144,15 +143,15 @@ var create_accounts = function (remote, src, amount, accounts, callback) {
.payment(src, account, amount) .payment(src, account, amount)
.set_flags('CreateAccount') .set_flags('CreateAccount')
.on('proposed', function (m) { .on('proposed', function (m) {
// console.log("proposed: %s", JSON.stringify(m)); // console.log("proposed: %s", JSON.stringify(m));
callback(m.result != 'tesSUCCESS'); callback(m.result != 'tesSUCCESS');
}) })
.on('error', function (m) { .on('error', function (m) {
// console.log("error: %s", JSON.stringify(m)); // console.log("error: %s", JSON.stringify(m));
callback(m); callback(m);
}) })
.submit(); .submit();
}, callback); }, callback);
}; };
@@ -163,14 +162,14 @@ var credit_limit = function (remote, src, amount, callback) {
remote.transaction() remote.transaction()
.ripple_line_set(src, amount) .ripple_line_set(src, amount)
.on('proposed', function (m) { .on('proposed', function (m) {
// console.log("proposed: %s", JSON.stringify(m)); // console.log("proposed: %s", JSON.stringify(m));
callback(m.result != 'tesSUCCESS'); callback(m.result != 'tesSUCCESS');
}) })
.on('error', function (m) { .on('error', function (m) {
// console.log("error: %s", JSON.stringify(m)); // console.log("error: %s", JSON.stringify(m));
callback(m); callback(m);
}) })
.submit(); .submit();
}; };
@@ -181,8 +180,8 @@ var credit_limits = function (remote, balances, callback) {
var limits = []; var limits = [];
for (var src in balances) { for (var src in balances) {
var values_src = balances[src]; var values_src = balances[src];
var values = 'string' === typeof values_src ? [ values_src ] : values_src; var values = 'string' === typeof values_src ? [ values_src ] : values_src;
for (var index in values) { for (var index in values) {
limits.push( { "source" : src, "amount" : values[index] } ); limits.push( { "source" : src, "amount" : values[index] } );
@@ -192,7 +191,7 @@ var credit_limits = function (remote, balances, callback) {
async.every(limits, async.every(limits,
function (limit, callback) { function (limit, callback) {
credit_limit(remote, limit.source, limit.amount, credit_limit(remote, limit.source, limit.amount,
function (mismatch) { callback(!mismatch); }); function (mismatch) { callback(!mismatch); });
}, },
function (every) { function (every) {
callback(!every); callback(!every);
@@ -205,14 +204,14 @@ var payment = function (remote, src, dst, amount, callback) {
remote.transaction() remote.transaction()
.payment(src, dst, amount) .payment(src, dst, amount)
.on('proposed', function (m) { .on('proposed', function (m) {
// console.log("proposed: %s", JSON.stringify(m)); // console.log("proposed: %s", JSON.stringify(m));
callback(m.result != 'tesSUCCESS'); callback(m.result != 'tesSUCCESS');
}) })
.on('error', function (m) { .on('error', function (m) {
// console.log("error: %s", JSON.stringify(m)); // console.log("error: %s", JSON.stringify(m));
callback(m); callback(m);
}) })
.submit(); .submit();
}; };
@@ -223,8 +222,8 @@ var payments = function (remote, balances, callback) {
var sends = []; var sends = [];
for (var src in balances) { for (var src in balances) {
var values_src = balances[src]; var values_src = balances[src];
var values = 'string' === typeof values_src ? [ values_src ] : values_src; var values = 'string' === typeof values_src ? [ values_src ] : values_src;
for (var index in values) { for (var index in values) {
var amount_json = values[index]; var amount_json = values[index];
@@ -237,7 +236,7 @@ var payments = function (remote, balances, callback) {
async.every(sends, async.every(sends,
function (send, callback) { function (send, callback) {
payment(remote, send.source, send.destination, send.amount, payment(remote, send.source, send.destination, send.amount,
function (mismatch) { callback(!mismatch); }); function (mismatch) { callback(!mismatch); });
}, },
function (every) { function (every) {
callback(!every); callback(!every);
@@ -251,14 +250,14 @@ var transfer_rate = function (remote, src, billionths, callback) {
.account_set(src) .account_set(src)
.transfer_rate(billionths) .transfer_rate(billionths)
.on('proposed', function (m) { .on('proposed', function (m) {
// console.log("proposed: %s", JSON.stringify(m)); // console.log("proposed: %s", JSON.stringify(m));
callback(m.result != 'tesSUCCESS'); callback(m.result != 'tesSUCCESS');
}) })
.on('error', function (m) { .on('error', function (m) {
// console.log("error: %s", JSON.stringify(m)); // console.log("error: %s", JSON.stringify(m));
callback(m); callback(m);
}) })
.submit(); .submit();
}; };
@@ -270,32 +269,32 @@ var verify_balance = function (remote, src, amount_json, callback) {
if (amount_req.is_native()) { if (amount_req.is_native()) {
remote.request_account_balance(src, 'CURRENT') remote.request_account_balance(src, 'CURRENT')
.once('account_balance', function (amount_act) { .once('account_balance', function (amount_act) {
if (!amount_act.equals(amount_req)) if (!amount_act.equals(amount_req))
console.log("verify_balance: failed: %s / %s", console.log("verify_balance: failed: %s / %s",
amount_act.to_text_full(), amount_act.to_text_full(),
amount_req.to_text_full()); amount_req.to_text_full());
callback(!amount_act.equals(amount_req)); callback(!amount_act.equals(amount_req));
}) })
.request(); .request();
} }
else { else {
remote.request_ripple_balance(src, amount_req.issuer().to_json(), amount_req.currency().to_json(), 'CURRENT') remote.request_ripple_balance(src, amount_req.issuer().to_json(), amount_req.currency().to_json(), 'CURRENT')
.once('ripple_state', function (m) { .once('ripple_state', function (m) {
// console.log("BALANCE: %s", JSON.stringify(m)); // console.log("BALANCE: %s", JSON.stringify(m));
// console.log("account_balance: %s", m.account_balance.to_text_full()); // console.log("account_balance: %s", m.account_balance.to_text_full());
// console.log("account_limit: %s", m.account_limit.to_text_full()); // console.log("account_limit: %s", m.account_limit.to_text_full());
// console.log("issuer_balance: %s", m.issuer_balance.to_text_full()); // console.log("issuer_balance: %s", m.issuer_balance.to_text_full());
// console.log("issuer_limit: %s", m.issuer_limit.to_text_full()); // console.log("issuer_limit: %s", m.issuer_limit.to_text_full());
var account_balance = Amount.from_json(m.account_balance); var account_balance = Amount.from_json(m.account_balance);
if (!account_balance.equals(amount_req)) { if (!account_balance.equals(amount_req)) {
console.log("verify_balance: failed: %s vs %s is %s: %s", src, account_balance.to_text_full(), amount_req.to_text_full(), account_balance.not_equals_why(amount_req)); console.log("verify_balance: failed: %s vs %s is %s: %s", src, account_balance.to_text_full(), amount_req.to_text_full(), account_balance.not_equals_why(amount_req));
} }
callback(!account_balance.equals(amount_req)); callback(!account_balance.equals(amount_req));
}) })
.request(); .request();
} }
}; };
@@ -304,8 +303,8 @@ var verify_balances = function (remote, balances, callback) {
var tests = []; var tests = [];
for (var src in balances) { for (var src in balances) {
var values_src = balances[src]; var values_src = balances[src];
var values = 'string' === typeof values_src ? [ values_src ] : values_src; var values = 'string' === typeof values_src ? [ values_src ] : values_src;
for (var index in values) { for (var index in values) {
tests.push( { "source" : src, "amount" : values[index] } ); tests.push( { "source" : src, "amount" : values[index] } );
@@ -315,7 +314,7 @@ var verify_balances = function (remote, balances, callback) {
async.every(tests, async.every(tests,
function (check, callback) { function (check, callback) {
verify_balance(remote, check.source, check.amount, verify_balance(remote, check.source, check.amount,
function (mismatch) { callback(!mismatch); }); function (mismatch) { callback(!mismatch); });
}, },
function (every) { function (every) {
callback(!every); callback(!every);
@@ -332,13 +331,13 @@ var verify_offer = function (remote, owner, seq, taker_pays, taker_gets, callbac
remote.request_ledger_entry('offer') remote.request_ledger_entry('offer')
.offer_id(owner, seq) .offer_id(owner, seq)
.on('success', function (m) { .on('success', function (m) {
var wrong = (!Amount.from_json(m.node.TakerGets).equals(Amount.from_json(taker_gets)) var wrong = (!Amount.from_json(m.node.TakerGets).equals(Amount.from_json(taker_gets))
|| !Amount.from_json(m.node.TakerPays).equals(Amount.from_json(taker_pays))); || !Amount.from_json(m.node.TakerPays).equals(Amount.from_json(taker_pays)));
if (wrong) if (wrong)
console.log("verify_offer: failed: %s", JSON.stringify(m)); console.log("verify_offer: failed: %s", JSON.stringify(m));
callback(wrong); callback(wrong);
}) })
.request(); .request();
}; };
@@ -349,32 +348,32 @@ var verify_offer_not_found = function (remote, owner, seq, callback) {
remote.request_ledger_entry('offer') remote.request_ledger_entry('offer')
.offer_id(owner, seq) .offer_id(owner, seq)
.on('success', function (m) { .on('success', function (m) {
console.log("verify_offer_not_found: found offer: %s", JSON.stringify(m)); console.log("verify_offer_not_found: found offer: %s", JSON.stringify(m));
callback('entryFound'); callback('entryFound');
}) })
.on('error', function (m) { .on('error', function (m) {
// console.log("verify_offer_not_found: success: %s", JSON.stringify(m)); // console.log("verify_offer_not_found: success: %s", JSON.stringify(m));
callback('remoteError' !== m.error callback('remoteError' !== m.error
|| 'entryNotFound' !== m.remote.error); || 'entryNotFound' !== m.remote.error);
}) })
.request(); .request();
}; };
exports.account_dump = account_dump; exports.account_dump = account_dump;
exports.build_setup = build_setup; exports.build_setup = build_setup;
exports.create_accounts = create_accounts; exports.create_accounts = create_accounts;
exports.credit_limit = credit_limit; exports.credit_limit = credit_limit;
exports.credit_limits = credit_limits; exports.credit_limits = credit_limits;
exports.payment = payment; exports.payment = payment;
exports.payments = payments; exports.payments = payments;
exports.build_teardown = build_teardown; exports.build_teardown = build_teardown;
exports.transfer_rate = transfer_rate; exports.transfer_rate = transfer_rate;
exports.verify_balance = verify_balance; exports.verify_balance = verify_balance;
exports.verify_balances = verify_balances; exports.verify_balances = verify_balances;
exports.verify_offer = verify_offer; exports.verify_offer = verify_offer;
exports.verify_offer_not_found = verify_offer_not_found; exports.verify_offer_not_found = verify_offer_not_found;
// vim:sw=2:sts=2:ts=8 // vim:sw=2:sts=2:ts=8:et

View File

@@ -1,4 +1,4 @@
var fs = require("fs"); var fs = require("fs");
var buster = require("buster"); var buster = require("buster");
var utils = require("../src/js/utils.js"); var utils = require("../src/js/utils.js");
@@ -23,4 +23,4 @@ buster.testCase("Utils", {
} }
}); });
// vim:sw=2:sts=2:ts=8 // vim:sw=2:sts=2:ts=8:et