Use custom assert in JS library.

The assert was previously provided by Buster.JS which is not available outside
of the test suite.
This commit is contained in:
Stefan Thomas
2012-12-03 19:45:31 -08:00
parent a1ae6c1866
commit 7bda03745e
2 changed files with 14 additions and 8 deletions

View File

@@ -551,7 +551,7 @@ Remote.prototype.request_server_info = function () {
// XXX This is a bad command. Some varients don't scale.
// XXX Require the server to be trusted.
Remote.prototype.request_ledger = function (ledger, full) {
//assert(this.trusted);
//utils.assert(this.trusted);
var request = new Request(this, 'ledger');
@@ -566,7 +566,7 @@ Remote.prototype.request_ledger = function (ledger, full) {
// Only for unit testing.
Remote.prototype.request_ledger_hash = function () {
//assert(this.trusted); // If not trusted, need to check proof.
//utils.assert(this.trusted); // If not trusted, need to check proof.
return new Request(this, 'ledger_closed');
};
@@ -588,7 +588,7 @@ Remote.prototype.request_ledger_current = function () {
// .ledger_index()
// .offer_id()
Remote.prototype.request_ledger_entry = function (type) {
//assert(this.trusted); // If not trusted, need to check proof, maybe talk packet protocol.
//utils.assert(this.trusted); // If not trusted, need to check proof, maybe talk packet protocol.
var self = this;
var request = new Request(this, 'ledger_entry');
@@ -692,7 +692,7 @@ Remote.prototype.request_unsubscribe = function (streams) {
};
Remote.prototype.request_transaction_entry = function (hash) {
//assert(this.trusted); // If not trusted, need to check proof, maybe talk packet protocol.
//utils.assert(this.trusted); // If not trusted, need to check proof, maybe talk packet protocol.
return (new Request(this, 'transaction_entry'))
.tx_hash(hash);
@@ -700,7 +700,7 @@ Remote.prototype.request_transaction_entry = function (hash) {
Remote.prototype.request_ripple_lines_get = function (accountID, index) {
// XXX Does this require the server to be trusted?
//assert(this.trusted);
//utils.assert(this.trusted);
var request = new Request(this, 'ripple_lines_get');
@@ -713,7 +713,7 @@ Remote.prototype.request_ripple_lines_get = function (accountID, index) {
};
Remote.prototype.request_wallet_accounts = function (seed) {
assert(this.trusted); // Don't send secrets.
utils.assert(this.trusted); // Don't send secrets.
var request = new Request(this, 'wallet_accounts');
@@ -724,7 +724,7 @@ Remote.prototype.request_wallet_accounts = function (seed) {
Remote.prototype.request_account_tx = function (accountID, ledger_min, ledger_max) {
// XXX Does this require the server to be trusted?
//assert(this.trusted);
//utils.assert(this.trusted);
var request = new Request(this, 'account_tx');

View File

@@ -87,13 +87,19 @@ var logObject = function (msg, obj) {
console.log(msg, JSON.stringify(obj, undefined, 2));
};
var assert = function (assertion, msg) {
if (!assertion) {
throw new Error("Assertion failed" + (msg ? ": "+msg : "."));
}
};
exports.trace = trace;
exports.arraySet = arraySet;
exports.hexToString = hexToString;
exports.stringToArray = stringToArray;
exports.stringToHex = stringToHex;
exports.logObject = logObject;
exports.chunkString = chunkString;
exports.logObject = logObject;
exports.assert = assert;
// vim:sw=2:sts=2:ts=8:et