Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function verify_limit(remote, src, amount, callback) {
assert.strictEqual(arguments.length, 4);
var _m = amount.match(/^(\d+\/...\/[^\:]+)(?::(\d+)(?:,(\d+))?)?$/);
if (!_m) {
// console.log('credit_limit: parse error: %s', amount);
return callback(new Error('parse_error'));
}
// console.log('_m', _m.length, _m);
// console.log('verify_limit: parsed: %s', JSON.stringify(_m, undefined, 2));
var account_limit = _m[1];
var quality_in = Number(_m[2]);
var quality_out = Number(_m[3]);
var limit = Amount.from_json(account_limit);
var options = {
account: src,
issuer: limit.issuer().to_json(),
currency: limit.currency().to_json(),
ledger: 'current'
};
remote.request_ripple_balance(options, function(err, m) {
if (err) {
callback(err);
} else {
assert(m.account_limit.equals(limit));
assert(isNaN(quality_in) || m.account_quality_in === quality_in);
assert(isNaN(quality_out) || m.account_quality_out === quality_out);
callback(null);
require('babel/register');
var extend = require('extend');
var mocha = require('mocha');
var ripplelib = require('ripple-lib');
// Optionally use a more useful (but noisy) logger
if (process.env.USE_RCONSOLE) {
require('rconsole');
};
// Stash a reference away to this
extend(ripplelib, ripplelib._DEPRECATED);
var config = ripplelib.config = {
load: function (newOpts) {
extend(ripplelib.config, newOpts);
return config;
}
}
// camelCase to under_scored API conversion
function attachUnderscored(c) {
var o = ripplelib[c];
Object.keys(o.prototype).forEach(function(key) {
var UPPERCASE = /([A-Z]{1})[a-z]+/g;
if (!UPPERCASE.test(key)) {
return;
}
require('babel/register');
var extend = require('extend');
var mocha = require('mocha');
var ripplelib = require('ripple-lib');
// Optionally use a more useful (but noisy) logger
if (process.env.USE_RCONSOLE) {
require('rconsole');
};
// Stash a reference away to this
extend(ripplelib, ripplelib._DEPRECATED);
var config = ripplelib.config = {
load: function (newOpts) {
extend(ripplelib.config, newOpts);
return config;
}
}
// camelCase to under_scored API conversion
function attachUnderscored(c) {
var o = ripplelib[c];
Object.keys(o.prototype).forEach(function(key) {
var UPPERCASE = /([A-Z]{1})[a-z]+/g;
if (!UPPERCASE.test(key)) {
var async = require('async');
var assert = require('assert');
var extend = require('extend');
var Amount = require('ripple-lib').Amount;
var Remote = require('ripple-lib').Remote;
var Transaction = require('ripple-lib').Transaction;
var UInt160 = require('ripple-lib').UInt160;
var Server = require('./server').Server;
var path = require("path");
var server = { };
function get_config() {
var cfg = require(__dirname + '/config-example');
// See if the person testing wants to override the configuration by creating a
// file called test/config.js.
try {
cfg = extend({}, cfg, require(__dirname + '/config'));
} catch (e) { }
return cfg;
};
var async = require("async");
var fs = require("fs");
var path = require("path");
var utils = require("ripple-lib").utils;
// Empty a directory.
// done(err) : err = true if an error occured.
var emptyPath = function(dirPath, done) {
fs.readdir(dirPath, function(err, files) {
if (err) {
done(err);
}
else {
async.some(files.map(function(f) { return path.join(dirPath, f); }), rmPath, done);
}
});
};
// Make a directory and sub-directories.
var mkPath = function(dirPath, mode, done) {
/* eslint-disable max-len */
/* eslint new-cap: [2, {newIsCapExceptions: ["bn"]}] */
'use strict';
const assert = require('assert');
const sjcl = require('ripple-lib').sjcl;
// fix normalize bug in scjl:
// https://github.com/bitwiseshiftleft/sjcl/pull/221
function normalizeFix(bn) {
while (bn.limbs.length > 0 && bn.limbs[bn.limbs.length - 1] === 0) {
bn.limbs.pop();
}
return bn;
}
function testExp(vec) {
const actual = normalizeFix(new sjcl.bn(vec.g).powermod(
new sjcl.bn(vec.e), new sjcl.bn(vec.m)));
const expected = new sjcl.bn(vec.r);
assert.strictEqual(actual.toString(), expected.toString());
}
function connect_websocket(callback) {
self.remote = data.remote = Remote.from_config(host, !!opts.verbose_ws);
self.remote.once('connected', function() {
// self.remote.once('ledger_closed', function() {
callback();
});
self.remote.connect();
}
];
function connect_websocket(callback) {
self.remote = data.remote = Remote.from_config(host, !!opts.verbose_ws);
self.remote.once('connected', function() {
// self.remote.once('ledger_closed', function() {
callback();
});
self.remote.connect();
}
];
var finish = function (remote) {
remote.disconnect();
// XXX Because remote.disconnect() doesn't work:
process.exit();
};
console.log("args: ", process.argv.length);
console.log("args: ", process.argv);
if (process.argv.length < 4) {
usage();
}
else {
var remote = Remote.from_config({
websocket_ip: process.argv[2],
websocket_port: process.argv[3],
})
.once('ledger_closed', function (m) {
console.log("ledger_closed: ", JSON.stringify(m, undefined, 2));
if (process.argv.length === 5) {
var ledger_index = process.argv[4];
ledger_request(remote, ledger_index, function (l) {
if (l) {
ledger_verify(l);
}
finish(remote);
});
+ say_type + " "
+ (say_watch_irc || say_watch);
var output_irc =
m.engine_result === 'tesSUCCESS'
? output_irc_base
: m.engine_result.match('tecPATH_DRY|tecPATH_PARTIAL') === null
? irc.colors.wrap('light_red', m.engine_result)
: undefined;
writeWatch(output_irc, output_console);
}
};
remote =
Remote
.from_config(remote_config)
.once('ledger_closed', function (m) {
self.rippled = true;
console.log("*** Connected to rippled");
if (process.argv.length > 2)
{
remote
.request_tx(process.argv[2])
.on('success', function (m) {
// Send transaction as per normal.
console.log("REPLAY %s", JSON.stringify(m, undefined, 2));
remote.emit('transaction_all', {
transaction: m,