JS & UT: add et to vim setting.

This commit is contained in:
Arthur Britto
2012-11-24 14:07:21 -08:00
parent 189c1276a3
commit 49e6ca70ba
21 changed files with 1569 additions and 1565 deletions

View File

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

View File

@@ -704,4 +704,4 @@ exports.UInt160 = UInt160;
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.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;
// 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.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.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() {
};
// vim:ts=4
// vim:sw=2:sts=2:ts=8:et

View File

@@ -76,4 +76,4 @@ exports.hexToString = hexToString;
exports.stringToArray = stringToArray;
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 BigInteger = jsbn.BigInteger;
var nbi = jsbn.nbi;
var jsbn = require('../src/js/jsbn.js');
var BigInteger = jsbn.BigInteger;
var nbi = jsbn.nbi;
var amount = require("../src/js/amount.js");
var Amount = require("../src/js/amount.js").Amount;
var UInt160 = require("../src/js/amount.js").UInt160;
var amount = require("../src/js/amount.js");
var Amount = require("../src/js/amount.js").Amount;
var UInt160 = require("../src/js/amount.js").UInt160;
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: "../",
environment: "node",
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.
exports.rippled = path.resolve("build/rippled");
exports.server_default = "alpha";
exports.server_default = "alpha";
// Configuration for 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,17 +1,17 @@
var async = require("async");
var buster = require("buster");
var async = require("async");
var buster = require("buster");
var Amount = require("../src/js/amount.js").Amount;
var Remote = require("../src/js/remote.js").Remote;
var Server = require("./server.js").Server;
var Amount = require("../src/js/amount.js").Amount;
var Remote = require("../src/js/remote.js").Remote;
var Server = require("./server.js").Server;
var testutils = require("./testutils.js");
var testutils = require("./testutils.js");
require("../src/js/amount.js").config = require("./config.js");
require("../src/js/remote.js").config = require("./config.js");
buster.testRunner.timeout = 5000;
buster.testCase("//Monitor account", {
'setUp' : testutils.build_setup({ verbose: true }),
'tearDown' : testutils.build_teardown(),
@@ -21,34 +21,34 @@ buster.testCase("//Monitor account", {
var self = this;
async.waterfall([
function (callback) {
self.what = "Create accounts.";
function (callback) {
self.what = "Create accounts.";
testutils.create_accounts(self.remote, "root", "10000", ["alice"], callback);
},
function (callback) {
self.what = "Close ledger.";
testutils.create_accounts(self.remote, "root", "10000", ["alice"], callback);
},
function (callback) {
self.what = "Close ledger.";
self.remote.once('ledger_closed', function (ledger_closed, ledger_index) {
callback();
});
self.remote.once('ledger_closed', function (ledger_closed, ledger_index) {
callback();
});
self.remote.ledger_accept();
},
function (callback) {
self.what = "Dumping root.";
self.remote.ledger_accept();
},
function (callback) {
self.what = "Dumping root.";
testutils.account_dump(self.remote, "root", function (error) {
buster.refute(error);
callback();
});
},
testutils.account_dump(self.remote, "root", function (error) {
buster.refute(error);
callback();
});
},
], function (error) {
buster.refute(error, self.what);
done();
buster.refute(error, self.what);
done();
});
},
});
// vim:sw=2:sts=2:ts=8
// vim:sw=2:sts=2:ts=8:et

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,11 @@
var async = require("async");
var buster = require("buster");
var async = require("async");
var buster = require("buster");
var Amount = require("../src/js/amount.js").Amount;
var Remote = require("../src/js/remote.js").Remote;
var Server = require("./server.js").Server;
var Amount = require("../src/js/amount.js").Amount;
var Remote = require("../src/js/remote.js").Remote;
var Server = require("./server.js").Server;
var testutils = require("./testutils.js");
var testutils = require("./testutils.js");
require("../src/js/amount.js").config = require("./config.js");
require("../src/js/remote.js").config = require("./config.js");
@@ -21,46 +21,47 @@ buster.testCase("Path finding", {
var self = this;
async.waterfall([
function (callback) {
self.what = "Create accounts.";
function (callback) {
self.what = "Create accounts.";
testutils.create_accounts(self.remote, "root", "10000", ["alice", "bob", "mtgox"], callback);
},
function (callback) {
self.what = "Set credit limits.";
testutils.create_accounts(self.remote, "root", "10000", ["alice", "bob", "mtgox"], callback);
},
function (callback) {
self.what = "Set credit limits.";
testutils.credit_limits(self.remote,
{
"alice" : "600/USD/mtgox",
"bob" : "700/USD/mtgox",
},
callback);
},
function (callback) {
self.what = "Distribute funds.";
testutils.credit_limits(self.remote,
{
"alice" : "600/USD/mtgox",
"bob" : "700/USD/mtgox",
},
callback);
},
function (callback) {
self.what = "Distribute funds.";
testutils.payments(self.remote,
{
"mtgox" : [ "70/USD/alice", "50/USD/bob" ],
},
callback);
},
function (callback) {
self.what = "Find path from alice to mtgox";
testutils.payments(self.remote,
{
"mtgox" : [ "70/USD/alice", "50/USD/bob" ],
},
callback);
},
function (callback) {
self.what = "Find path from alice to mtgox";
self.remote.request_ripple_path_find("alice", "bob", "5/USD/mtgox",
[ { 'currency' : "USD" } ])
.on('success', function (m) {
console.log("proposed: m", JSON.stringify(m));
self.remote.request_ripple_path_find("alice", "bob", "5/USD/mtgox",
[ { 'currency' : "USD" } ])
.on('success', function (m) {
console.log("proposed: m", JSON.stringify(m));
callback();
})
.request();
},
], function (error) {
buster.refute(error, self.what);
done();
});
callback();
})
.request();
},
], function (error) {
buster.refute(error, self.what);
done();
});
},
});
// vim:sw=2:sts=2:ts=8
// vim:sw=2:sts=2:ts=8:et

View File

@@ -1,19 +1,19 @@
var buster = require("buster");
var buster = require("buster");
var Amount = require("../src/js/amount.js").Amount;
var Remote = require("../src/js/remote.js").Remote;
var Server = require("./server.js").Server;
var Amount = require("../src/js/amount.js").Amount;
var Remote = require("../src/js/remote.js").Remote;
var Server = require("./server.js").Server;
var testutils = require("./testutils.js");
var testutils = require("./testutils.js");
require("../src/js/amount.js").config = require("./config.js");
require("../src/js/remote.js").config = require("./config.js");
// How long to wait for server to start.
var serverDelay = 1500; // XXX Not implemented.
var serverDelay = 1500; // XXX Not implemented.
buster.testRunner.timeout = 5000;
buster.testCase("Remote functions", {
'setUp' : testutils.build_setup(),
'tearDown' : testutils.build_teardown(),
@@ -21,16 +21,16 @@ buster.testCase("Remote functions", {
"request_ledger_current" :
function (done) {
this.remote.request_ledger_current().on('success', function (m) {
// console.log(m);
// console.log(m);
buster.assert.equals(m.ledger_current_index, 3);
done();
})
buster.assert.equals(m.ledger_current_index, 3);
done();
})
.on('error', function(m) {
// console.log(m);
// console.log(m);
buster.assert(false);
})
buster.assert(false);
})
.request();
},
@@ -38,16 +38,16 @@ buster.testCase("Remote functions", {
"request_ledger_hash" :
function (done) {
this.remote.request_ledger_hash().on('success', function (m) {
// console.log("result: %s", JSON.stringify(m));
// console.log("result: %s", JSON.stringify(m));
buster.assert.equals(m.ledger_index, 2);
done();
})
buster.assert.equals(m.ledger_index, 2);
done();
})
.on('error', function(m) {
// console.log("error: %s", m);
// console.log("error: %s", m);
buster.assert(false);
})
buster.assert(false);
})
.request();
},
@@ -56,30 +56,30 @@ buster.testCase("Remote functions", {
var self = this;
this.remote.request_ledger_hash().on('success', function (r) {
// console.log("result: %s", JSON.stringify(r));
// console.log("result: %s", JSON.stringify(r));
self.remote
.request_ledger_entry('account_root')
.ledger_hash(r.ledger_hash)
.account_root("rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh")
.on('success', function (r) {
// console.log("account_root: %s", JSON.stringify(r));
self.remote
.request_ledger_entry('account_root')
.ledger_hash(r.ledger_hash)
.account_root("rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh")
.on('success', function (r) {
// console.log("account_root: %s", JSON.stringify(r));
buster.assert('node' in r);
done();
})
.on('error', function(m) {
// console.log("error: %s", m);
buster.assert('node' in r);
done();
})
.on('error', function(m) {
// console.log("error: %s", m);
buster.assert(false);
})
.request();
})
buster.assert(false);
})
.request();
})
.on('error', function(m) {
// console.log("error: %s", m);
// console.log("error: %s", m);
buster.assert(false);
})
buster.assert(false);
})
.request();
},
@@ -89,31 +89,31 @@ buster.testCase("Remote functions", {
var self = this;
this.remote.request_ledger_hash().on('success', function (r) {
// console.log("result: %s", JSON.stringify(r));
// console.log("result: %s", JSON.stringify(r));
self.remote
.request_ledger_entry('account_root')
.ledger_hash(r.ledger_hash)
.account_root("zHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh")
.on('success', function (r) {
// console.log("account_root: %s", JSON.stringify(r));
self.remote
.request_ledger_entry('account_root')
.ledger_hash(r.ledger_hash)
.account_root("zHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh")
.on('success', function (r) {
// console.log("account_root: %s", JSON.stringify(r));
buster.assert(false);
})
.on('error', function(m) {
// console.log("error: %s", m);
buster.assert(false);
})
.on('error', function(m) {
// console.log("error: %s", m);
buster.assert.equals(m.error, 'remoteError');
buster.assert.equals(m.remote.error, 'malformedAddress');
done();
})
.request();
})
buster.assert.equals(m.error, 'remoteError');
buster.assert.equals(m.remote.error, 'malformedAddress');
done();
})
.request();
})
.on('error', function(m) {
// console.log("error: %s", m);
// console.log("error: %s", m);
buster.assert(false);
})
buster.assert(false);
})
.request();
},
@@ -122,31 +122,31 @@ buster.testCase("Remote functions", {
var self = this;
this.remote.request_ledger_hash().on('success', function (r) {
// console.log("result: %s", JSON.stringify(r));
// console.log("result: %s", JSON.stringify(r));
self.remote
.request_ledger_entry('account_root')
.ledger_hash(r.ledger_hash)
.account_root("alice")
.on('success', function (r) {
// console.log("account_root: %s", JSON.stringify(r));
self.remote
.request_ledger_entry('account_root')
.ledger_hash(r.ledger_hash)
.account_root("alice")
.on('success', function (r) {
// console.log("account_root: %s", JSON.stringify(r));
buster.assert(false);
})
.on('error', function(m) {
// console.log("error: %s", m);
buster.assert(false);
})
.on('error', function(m) {
// console.log("error: %s", m);
buster.assert.equals(m.error, 'remoteError');
buster.assert.equals(m.remote.error, 'entryNotFound');
done();
})
.request();
})
buster.assert.equals(m.error, 'remoteError');
buster.assert.equals(m.remote.error, 'entryNotFound');
done();
})
.request();
})
.on('error', function(m) {
// console.log("error: %s", m);
// console.log("error: %s", m);
buster.assert(false);
}).request();
buster.assert(false);
}).request();
},
"ledger_entry index" :
@@ -154,52 +154,52 @@ buster.testCase("Remote functions", {
var self = this;
this.remote.request_ledger_hash().on('success', function (r) {
// console.log("result: %s", JSON.stringify(r));
// console.log("result: %s", JSON.stringify(r));
self.remote
.request_ledger_entry('index')
.ledger_hash(r.ledger_hash)
.account_root("alice")
.index("2B6AC232AA4C4BE41BF49D2459FA4A0347E1B543A4C92FCEE0821C0201E2E9A8")
.on('success', function (r) {
// console.log("account_root: %s", JSON.stringify(r));
self.remote
.request_ledger_entry('index')
.ledger_hash(r.ledger_hash)
.account_root("alice")
.index("2B6AC232AA4C4BE41BF49D2459FA4A0347E1B543A4C92FCEE0821C0201E2E9A8")
.on('success', function (r) {
// console.log("account_root: %s", JSON.stringify(r));
buster.assert('node_binary' in r);
done();
})
.on('error', function(m) {
// console.log("error: %s", m);
buster.assert('node_binary' in r);
done();
})
.on('error', function(m) {
// console.log("error: %s", m);
buster.assert(false);
}).
request();
})
buster.assert(false);
}).
request();
})
.on('error', function(m) {
// console.log(m);
// console.log(m);
buster.assert(false);
})
buster.assert(false);
})
.request();
},
"create account" :
function (done) {
this.remote.transaction()
.payment('root', 'alice', Amount.from_json("10000"))
.set_flags('CreateAccount')
.on('success', function (r) {
// console.log("account_root: %s", JSON.stringify(r));
.payment('root', 'alice', Amount.from_json("10000"))
.set_flags('CreateAccount')
.on('success', function (r) {
// console.log("account_root: %s", JSON.stringify(r));
// Need to verify account and balance.
buster.assert(true);
done();
})
.on('error', function(m) {
// console.log("error: %s", m);
// Need to verify account and balance.
buster.assert(true);
done();
})
.on('error', function(m) {
// console.log("error: %s", m);
buster.assert(false);
})
.submit();
buster.assert(false);
})
.submit();
},
"create account final" :
@@ -210,39 +210,39 @@ buster.testCase("Remote functions", {
var got_success;
this.remote.transaction()
.payment('root', 'alice', Amount.from_json("10000"))
.set_flags('CreateAccount')
.on('success', function (r) {
// console.log("create_account: %s", JSON.stringify(r));
.payment('root', 'alice', Amount.from_json("10000"))
.set_flags('CreateAccount')
.on('success', function (r) {
// console.log("create_account: %s", JSON.stringify(r));
got_success = true;
})
.on('error', function (m) {
// console.log("error: %s", m);
got_success = true;
})
.on('error', function (m) {
// console.log("error: %s", m);
buster.assert(false);
})
.on('final', function (m) {
// console.log("final: %s", JSON.stringify(m));
buster.assert(false);
})
.on('final', function (m) {
// console.log("final: %s", JSON.stringify(m));
buster.assert(got_success && got_proposed);
done();
})
.on('proposed', function (m) {
// console.log("proposed: %s", JSON.stringify(m));
buster.assert(got_success && got_proposed);
done();
})
.on('proposed', function (m) {
// console.log("proposed: %s", JSON.stringify(m));
// buster.assert.equals(m.result, 'terNO_DST');
buster.assert.equals(m.result, 'tesSUCCESS');
// buster.assert.equals(m.result, 'terNO_DST');
buster.assert.equals(m.result, 'tesSUCCESS');
got_proposed = true;
got_proposed = true;
self.remote.ledger_accept();
})
.on('status', function (s) {
// console.log("status: %s", JSON.stringify(s));
})
.submit();
self.remote.ledger_accept();
})
.on('status', function (s) {
// console.log("status: %s", JSON.stringify(s));
})
.submit();
},
});
// vim:sw=2:sts=2:ts=8
// vim:sw=2:sts=2:ts=8:et

File diff suppressed because it is too large Load Diff

View File

@@ -12,17 +12,17 @@ buster.testCase("Standalone server startup", {
alpha = Server.from_config("alpha");
alpha
.on('started', function () {
alpha
.on('stopped', function () {
buster.assert(true);
.on('started', function () {
alpha
.on('stopped', function () {
buster.assert(true);
done();
})
.stop();
})
.start();
done();
})
.stop();
})
.start();
}
});
// vim:sw=2:sts=2:ts=8
// vim:sw=2:sts=2:ts=8:et

View File

@@ -2,11 +2,11 @@
//
// Usage:
// s = new Server(name, config)
// s.verbose() : optional
// s.verbose() : optional
// .start()
// 'started'
// 'started'
//
// s.stop() : stops server is started.
// s.stop() : stops server is started.
// 'stopped'
//
@@ -15,22 +15,22 @@
// Servers are created in tmp/server/$server
//
var buster = require("buster");
var child = require("child_process");
var fs = require("fs");
var path = require("path");
var util = require("util");
var buster = require("buster");
var child = require("child_process");
var fs = require("fs");
var path = require("path");
var util = require("util");
var EventEmitter = require('events').EventEmitter;
var config = require("./config.js");
var nodeutils = require("../src/js/nodeutils.js");
var config = require("./config.js");
var nodeutils = require("../src/js/nodeutils.js");
// Create a server object
var Server = function (name, config, verbose) {
this.name = name;
this.config = config;
this.started = false;
this.quiet = !verbose;
this.name = name;
this.config = config;
this.started = false;
this.quiet = !verbose;
};
Server.prototype = new EventEmitter;
@@ -66,7 +66,7 @@ Server.prototype._writeConfig = function(done) {
fs.writeFile(
this.configPath(),
Object.keys(this.config).map(function(o) {
return util.format("[%s]\n%s\n", o, self.config[o]);
return util.format("[%s]\n%s\n", o, self.config[o]);
}).join(""),
'utf8', done);
};
@@ -111,10 +111,10 @@ Server.prototype._makeBase = function (done) {
// Reset the server directory, build it if needed.
nodeutils.resetPath(path, '0777', function (e) {
if (e) {
throw e;
throw e;
}
else {
self._writeConfig(done);
self._writeConfig(done);
}
});
};
@@ -128,17 +128,17 @@ Server.prototype.verbose = function () {
// Create a standalone server.
// Prepare the working directory and spawn the server.
Server.prototype.start = function () {
var self = this;
var self = this;
if (!this.quiet) console.log("server: start: %s: %s", this.name, JSON.stringify(this.config));
this._makeBase(function (e) {
if (e) {
throw e;
throw e;
}
else {
self._serverSpawnSync();
self.emit('started');
self._serverSpawnSync();
self.emit('started');
}
});
@@ -153,10 +153,10 @@ Server.prototype.stop = function () {
// Update the on exit to invoke done.
this.child.on('exit', function (code, signal) {
if (!self.quiet) console.log("server: stop: server exited");
if (!self.quiet) console.log("server: stop: server exited");
self.emit('stopped');
delete this.child;
self.emit('stopped');
delete this.child;
});
this.child.kill();
@@ -171,4 +171,4 @@ Server.prototype.stop = function () {
exports.Server = Server;
// 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 buster = require("buster");
var Amount = require("../src/js/amount.js").Amount;
var Remote = require("../src/js/remote.js").Remote;
@@ -15,24 +14,24 @@ var account_dump = function (remote, account, callback) {
async.waterfall([
function (callback) {
self.what = "Get latest account_root";
self.what = "Get latest account_root";
remote
.request_ledger_entry('account_root')
.ledger_hash(remote.ledger_hash())
.account_root("root")
.on('success', function (r) {
//console.log("account_root: %s", JSON.stringify(r, undefined, 2));
remote
.request_ledger_entry('account_root')
.ledger_hash(remote.ledger_hash())
.account_root("root")
.on('success', function (r) {
//console.log("account_root: %s", JSON.stringify(r, undefined, 2));
callback();
})
.on('error', function(m) {
console.log("error: %s", m);
callback();
})
.on('error', function(m) {
console.log("error: %s", m);
buster.assert(false);
callback();
})
.request();
buster.assert(false);
callback();
})
.request();
},
], function (error) {
callback(error);
@@ -106,10 +105,10 @@ var build_setup = function (opts, host) {
* @param host {String} Identifier for the host configuration to be used.
*/
var build_teardown = function (host) {
return function (done) {
host = host || config.server_default;
var data = this.store[host];
@@ -117,22 +116,22 @@ var build_teardown = function (host) {
async.series([
function disconnectWebsocketStep(callback) {
data.remote
.on('disconnected', callback)
.connect(false);
},
function stopServerStep(callback) {
if (opts.no_server)
if (opts.no_server)
{
return callback();
}
return callback();
}
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)
.set_flags('CreateAccount')
.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) {
// console.log("error: %s", JSON.stringify(m));
// console.log("error: %s", JSON.stringify(m));
callback(m);
})
callback(m);
})
.submit();
}, callback);
};
@@ -163,14 +162,14 @@ var credit_limit = function (remote, src, amount, callback) {
remote.transaction()
.ripple_line_set(src, amount)
.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) {
// console.log("error: %s", JSON.stringify(m));
// console.log("error: %s", JSON.stringify(m));
callback(m);
callback(m);
})
.submit();
};
@@ -181,8 +180,8 @@ var credit_limits = function (remote, balances, callback) {
var limits = [];
for (var src in balances) {
var values_src = balances[src];
var values = 'string' === typeof values_src ? [ values_src ] : values_src;
var values_src = balances[src];
var values = 'string' === typeof values_src ? [ values_src ] : values_src;
for (var index in values) {
limits.push( { "source" : src, "amount" : values[index] } );
@@ -192,7 +191,7 @@ var credit_limits = function (remote, balances, callback) {
async.every(limits,
function (limit, callback) {
credit_limit(remote, limit.source, limit.amount,
function (mismatch) { callback(!mismatch); });
function (mismatch) { callback(!mismatch); });
},
function (every) {
callback(!every);
@@ -205,14 +204,14 @@ var payment = function (remote, src, dst, amount, callback) {
remote.transaction()
.payment(src, dst, amount)
.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) {
// console.log("error: %s", JSON.stringify(m));
// console.log("error: %s", JSON.stringify(m));
callback(m);
callback(m);
})
.submit();
};
@@ -223,8 +222,8 @@ var payments = function (remote, balances, callback) {
var sends = [];
for (var src in balances) {
var values_src = balances[src];
var values = 'string' === typeof values_src ? [ values_src ] : values_src;
var values_src = balances[src];
var values = 'string' === typeof values_src ? [ values_src ] : values_src;
for (var index in values) {
var amount_json = values[index];
@@ -237,7 +236,7 @@ var payments = function (remote, balances, callback) {
async.every(sends,
function (send, callback) {
payment(remote, send.source, send.destination, send.amount,
function (mismatch) { callback(!mismatch); });
function (mismatch) { callback(!mismatch); });
},
function (every) {
callback(!every);
@@ -251,14 +250,14 @@ var transfer_rate = function (remote, src, billionths, callback) {
.account_set(src)
.transfer_rate(billionths)
.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) {
// console.log("error: %s", JSON.stringify(m));
// console.log("error: %s", JSON.stringify(m));
callback(m);
callback(m);
})
.submit();
};
@@ -270,32 +269,32 @@ var verify_balance = function (remote, src, amount_json, callback) {
if (amount_req.is_native()) {
remote.request_account_balance(src, 'CURRENT')
.once('account_balance', function (amount_act) {
if (!amount_act.equals(amount_req))
console.log("verify_balance: failed: %s / %s",
amount_act.to_text_full(),
amount_req.to_text_full());
if (!amount_act.equals(amount_req))
console.log("verify_balance: failed: %s / %s",
amount_act.to_text_full(),
amount_req.to_text_full());
callback(!amount_act.equals(amount_req));
})
callback(!amount_act.equals(amount_req));
})
.request();
}
else {
remote.request_ripple_balance(src, amount_req.issuer().to_json(), amount_req.currency().to_json(), 'CURRENT')
.once('ripple_state', function (m) {
// console.log("BALANCE: %s", JSON.stringify(m));
// console.log("account_balance: %s", m.account_balance.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_limit: %s", m.issuer_limit.to_text_full());
// console.log("BALANCE: %s", JSON.stringify(m));
// console.log("account_balance: %s", m.account_balance.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_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)) {
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));
}
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));
}
callback(!account_balance.equals(amount_req));
})
callback(!account_balance.equals(amount_req));
})
.request();
}
};
@@ -304,8 +303,8 @@ var verify_balances = function (remote, balances, callback) {
var tests = [];
for (var src in balances) {
var values_src = balances[src];
var values = 'string' === typeof values_src ? [ values_src ] : values_src;
var values_src = balances[src];
var values = 'string' === typeof values_src ? [ values_src ] : values_src;
for (var index in values) {
tests.push( { "source" : src, "amount" : values[index] } );
@@ -315,7 +314,7 @@ var verify_balances = function (remote, balances, callback) {
async.every(tests,
function (check, callback) {
verify_balance(remote, check.source, check.amount,
function (mismatch) { callback(!mismatch); });
function (mismatch) { callback(!mismatch); });
},
function (every) {
callback(!every);
@@ -332,13 +331,13 @@ var verify_offer = function (remote, owner, seq, taker_pays, taker_gets, callbac
remote.request_ledger_entry('offer')
.offer_id(owner, seq)
.on('success', function (m) {
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)));
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)));
if (wrong)
console.log("verify_offer: failed: %s", JSON.stringify(m));
if (wrong)
console.log("verify_offer: failed: %s", JSON.stringify(m));
callback(wrong);
callback(wrong);
})
.request();
};
@@ -349,32 +348,32 @@ var verify_offer_not_found = function (remote, owner, seq, callback) {
remote.request_ledger_entry('offer')
.offer_id(owner, seq)
.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) {
// 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
|| 'entryNotFound' !== m.remote.error);
callback('remoteError' !== m.error
|| 'entryNotFound' !== m.remote.error);
})
.request();
};
exports.account_dump = account_dump;
exports.account_dump = account_dump;
exports.build_setup = build_setup;
exports.create_accounts = create_accounts;
exports.credit_limit = credit_limit;
exports.credit_limits = credit_limits;
exports.payment = payment;
exports.payments = payments;
exports.build_teardown = build_teardown;
exports.transfer_rate = transfer_rate;
exports.verify_balance = verify_balance;
exports.verify_balances = verify_balances;
exports.verify_offer = verify_offer;
exports.verify_offer_not_found = verify_offer_not_found;
exports.build_setup = build_setup;
exports.create_accounts = create_accounts;
exports.credit_limit = credit_limit;
exports.credit_limits = credit_limits;
exports.payment = payment;
exports.payments = payments;
exports.build_teardown = build_teardown;
exports.transfer_rate = transfer_rate;
exports.verify_balance = verify_balance;
exports.verify_balances = verify_balances;
exports.verify_offer = verify_offer;
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 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

View File

@@ -17,23 +17,23 @@ buster.testCase("WebSocket connection", {
"websocket connect and disconnect" :
function (done) {
var alpha = Remote.from_config("alpha");
var alpha = Remote.from_config("alpha");
alpha
.on('connected', function () {
// OPEN
buster.assert(true);
.on('connected', function () {
// OPEN
buster.assert(true);
alpha
.on('disconnected', function () {
// CLOSED
buster.assert(true);
done();
})
.connect(false);
})
.connect();
alpha
.on('disconnected', function () {
// CLOSED
buster.assert(true);
done();
})
.connect(false);
})
.connect();
},
});
// vim:sw=2:sts=2:ts=8
// vim:sw=2:sts=2:ts=8:et