diff --git a/src/js/amount.js b/src/js/amount.js index e9426d461f..3fd7c357d7 100644 --- a/src/js/amount.js +++ b/src/js/amount.js @@ -6,13 +6,10 @@ var bn = require('./sjcl/core.js').bn; var utils = require('./utils.js'); var jsbn = require('./jsbn.js'); -// Don't include in browser context. -var config = require('../../test/config.js'); - var BigInteger = jsbn.BigInteger; var nbi = jsbn.nbi; -var alphabets = { +var alphabets = { 'ripple' : "rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz", 'bitcoin' : "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" }; @@ -158,8 +155,8 @@ UInt160.prototype.equals = function(d) { // value = NaN on error. UInt160.prototype.parse_json = function (j) { // Canonicalize and validate - if (config.accounts && j in config.accounts) - j = config.accounts[j].account; + if (exports.config.accounts && j in exports.config.accounts) + j = exports.config.accounts[j].account; switch (j) { case undefined: @@ -603,6 +600,8 @@ exports.Amount = Amount; exports.Currency = Currency; exports.UInt160 = UInt160; +exports.config = {}; + exports.consts = { 'address_xns' : "rrrrrrrrrrrrrrrrrrrrrhoLvTp", 'address_one' : "rrrrrrrrrrrrrrrrrrrrBZbvji", diff --git a/src/js/remote.js b/src/js/remote.js index 3ab91051b7..44ed3b38bb 100644 --- a/src/js/remote.js +++ b/src/js/remote.js @@ -21,9 +21,6 @@ var EventEmitter = require('events').EventEmitter; var Amount = require('./amount.js').Amount; var UInt160 = require('./amount.js').UInt160; -// Don't include in browser context. -var config = require('../../test/config.js'); - // Request events emmitted: // 'success' : Request successful. // 'error' : Request failed. @@ -159,7 +156,6 @@ var Remote = function (trusted, websocket_ip, websocket_port, trace) { this.state = 'offline'; // 'online', 'offline' this.retry_timer = undefined; this.retry = undefined; - this.config = config || { 'accounts' : {}}; // Cache information for accounts. this.accounts = { @@ -182,7 +178,7 @@ var Remote = function (trusted, websocket_ip, websocket_port, trace) { Remote.prototype = new EventEmitter; Remote.from_config = function (name, trace) { - var serverConfig = config.servers[name]; + var serverConfig = exports.config.servers[name]; return new Remote(serverConfig.trusted, serverConfig.websocket_ip, serverConfig.websocket_port, trace); }; @@ -1141,7 +1137,7 @@ Transaction.prototype.set_flags = function (flags) { Transaction.prototype._account_secret = function (account) { // Fill in secret from config, if needed. - return this.remote.config.accounts[account] ? this.remote.config.accounts[account].secret : undefined; + return exports.config.accounts && exports.config.accounts[account] ? exports.config.accounts[account].secret : undefined; }; // Options: @@ -1268,6 +1264,7 @@ Transaction.prototype.wallet_add = function (src, amount, authorized_key, public return this; }; +exports.config = {}; exports.Remote = Remote; // vim:sw=2:sts=2:ts=8 diff --git a/test/amount-test.js b/test/amount-test.js index 4c7388708b..841b07893f 100644 --- a/test/amount-test.js +++ b/test/amount-test.js @@ -8,6 +8,8 @@ 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"); + var config = require('./config.js'); buster.testCase("Amount", { diff --git a/test/offer-test.js b/test/offer-test.js index b4b5e437eb..10ec4444bf 100644 --- a/test/offer-test.js +++ b/test/offer-test.js @@ -8,6 +8,9 @@ var Server = require("./server.js").Server; 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("Offer tests", { diff --git a/test/remote-test.js b/test/remote-test.js index f2596cbfb2..ab5d2c9b09 100644 --- a/test/remote-test.js +++ b/test/remote-test.js @@ -6,6 +6,9 @@ var Server = require("./server.js").Server; var testutils = require("./testutils.js"); +require("../src/js/amount.js").config = require("./config.js"); +require("../src/js/remote.js").config = require("./config.js"); + var fastTearDown = true; // How long to wait for server to start. diff --git a/test/send-test.js b/test/send-test.js index ad316ffa3b..5061414538 100644 --- a/test/send-test.js +++ b/test/send-test.js @@ -7,6 +7,9 @@ var Server = require("./server.js").Server; 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; diff --git a/test/testutils.js b/test/testutils.js index 94883eaf4b..a82cc1a415 100644 --- a/test/testutils.js +++ b/test/testutils.js @@ -5,6 +5,9 @@ var Amount = require("../src/js/amount.js").Amount; var Remote = require("../src/js/remote.js").Remote; var Server = require("./server.js").Server; +require("../src/js/amount.js").config = require("./config.js"); +require("../src/js/remote.js").config = require("./config.js"); + var config = require("./config.js"); /** diff --git a/test/websocket-test.js b/test/websocket-test.js index 1afccc943d..c401165302 100644 --- a/test/websocket-test.js +++ b/test/websocket-test.js @@ -3,6 +3,8 @@ var buster = require("buster"); var Server = require("./server.js").Server; var Remote = require("../src/js/remote.js").Remote; +require("../src/js/remote.js").config = require("./config.js"); + // How long to wait for server to start. var serverDelay = 1500;