diff --git a/.npmignore b/.npmignore index ffb92eb1f6..928256a82b 100644 --- a/.npmignore +++ b/.npmignore @@ -1,3 +1,2 @@ -deploy lib-cov coverage.html diff --git a/.travis.yml b/.travis.yml index 7c71d80f76..5b666aaa3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ node_js: before_script: - npm install -g eslint - curl 'https://raw.githubusercontent.com/ripple/javascript-style-guide/master/eslintrc' > ./eslintrc - - eslint --reset -c ./eslintrc $(git --no-pager diff --name-only --diff-filter=AM --relative $(git merge-base FETCH_HEAD origin/HEAD) FETCH_HEAD | grep "\.js$") + - eslint --reset -c ./eslintrc $(git --no-pager diff --name-only -M100% --diff-filter=AM --relative $(git merge-base FETCH_HEAD origin/HEAD) FETCH_HEAD | grep "\.js$") script: MOCHA_REPORTER=tap npm test --coverage after_success: - npm run coveralls diff --git a/Gulpfile.js b/Gulpfile.js index d1d649b01d..0a6944224b 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -22,7 +22,7 @@ function logPluginError(error) { gulp.task('build', function(callback) { webpack({ cache: true, - entry: './src/js/ripple/index.js', + entry: './src/index.js', output: { library: 'ripple', path: './build/', @@ -41,7 +41,7 @@ gulp.task('build-min', ['build'], function() { gulp.task('build-debug', function(callback) { webpack({ cache: true, - entry: './src/js/ripple/index.js', + entry: './src/index.js', output: { library: 'ripple', path: './build/', @@ -66,7 +66,7 @@ function buildUseError(cons) { gulp.task('build-core', function(callback) { webpack({ entry: [ - './src/js/ripple/remote.js' + './src/remote.js' ], externals: [ { @@ -115,12 +115,12 @@ gulp.task('bower', ['bower-build', 'bower-build-min', 'bower-build-debug', 'bower-version']); gulp.task('watch', function() { - gulp.watch('src/js/ripple/*', ['build-debug']); + gulp.watch('src/*', ['build-debug']); }); // To use this, each javascript file must have /* @flow */ on the first line gulp.task('typecheck', function() { - return gulp.src('src/js/ripple/*.js') + return gulp.src('src/*.js') .pipe(flow({ // note: do not set the 'all' option, it is broken weak: true, // remove this after all errors are addressed killFlow: true @@ -128,8 +128,8 @@ gulp.task('typecheck', function() { }); gulp.task('strip', function() { - return gulp.src('src/js/ripple/*.js') - .pipe(watch('src/js/ripple/*.js')) + return gulp.src('src/*.js') + .pipe(watch('src/*.js')) .pipe(cleanDest('out')) // delete outdated output file before stripping .pipe(plumber()) // prevent an error in one file from ending build .pipe(react({stripTypes: true}).on('error', logPluginError)) diff --git a/deploy/start rippled.bat b/deploy/start rippled.bat deleted file mode 100644 index b23c09ade2..0000000000 --- a/deploy/start rippled.bat +++ /dev/null @@ -1,3 +0,0 @@ -start newcoin -sleep 4 -start index.html \ No newline at end of file diff --git a/package.json b/package.json index 50e9267860..8c18cb4b3a 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "Makefile", "Gulpfile.js" ], - "main": "src/js/ripple", + "main": "src/", "directories": { "test": "test" }, @@ -47,11 +47,11 @@ "yargs": "~1.3.1" }, "scripts": { - "build": "node_modules/.bin/gulp", + "build": "gulp", "postinstall": "cd node_modules/sjcl; ./configure --with-all --compress=none; make", - "test": "./node_modules/.bin/istanbul test -x build/sjcl.js -x src/js/jsbn/* ./node_modules/mocha/bin/_mocha -- --reporter ${MOCHA_REPORTER:=spec} --timeout 10000 --slow 500 test/*-test.js", - "coveralls": "cat ./coverage/lcov.info | ./node_modules/.bin/coveralls", - "lint": "if ! [ -f eslintrc ]; then curl -o eslintrc 'https://raw.githubusercontent.com/ripple/javascript-style-guide/master/eslintrc'; fi; eslint --reset -c eslintrc src/js/ripple/*.js", + "test": "istanbul test _mocha", + "coveralls": "cat ./coverage/lcov.info | coveralls", + "lint": "if ! [ -f eslintrc ]; then curl -o eslintrc 'https://raw.githubusercontent.com/ripple/javascript-style-guide/master/eslintrc'; fi; eslint --reset -c eslintrc src/*.js", "perf": "./scripts/perf_test.sh" }, "repository": { diff --git a/bench/modpow.js b/scripts/modpow.js similarity index 100% rename from bench/modpow.js rename to scripts/modpow.js diff --git a/src/js/ripple/account.js b/src/account.js similarity index 100% rename from src/js/ripple/account.js rename to src/account.js diff --git a/src/js/ripple/amount.js b/src/amount.js similarity index 100% rename from src/js/ripple/amount.js rename to src/amount.js diff --git a/src/js/ripple/autobridgecalculator.js b/src/autobridgecalculator.js similarity index 100% rename from src/js/ripple/autobridgecalculator.js rename to src/autobridgecalculator.js diff --git a/src/js/ripple/base.js b/src/base.js similarity index 100% rename from src/js/ripple/base.js rename to src/base.js diff --git a/src/js/ripple/baseconverter.js b/src/baseconverter.js similarity index 100% rename from src/js/ripple/baseconverter.js rename to src/baseconverter.js diff --git a/src/js/ripple/binformat.js b/src/binformat.js similarity index 100% rename from src/js/ripple/binformat.js rename to src/binformat.js diff --git a/src/cpp/TransactionErr.cpp b/src/cpp/TransactionErr.cpp deleted file mode 100644 index 1e03226fff..0000000000 --- a/src/cpp/TransactionErr.cpp +++ /dev/null @@ -1,126 +0,0 @@ -#include "TransactionErr.h" -#include "utils.h" - -bool transResultInfo(TER terCode, std::string& strToken, std::string& strHuman) -{ - static struct { - TER terCode; - const char* cpToken; - const char* cpHuman; - } transResultInfoA[] = { - { tecCLAIM, "tecCLAIM", "Fee claimed. Sequence used. No action." }, - { tecDIR_FULL, "tecDIR_FULL", "Can not add entry to full directory." }, - { tecFAILED_PROCESSING, "tecFAILED_PROCESSING", "Failed to correctly process transaction." }, - { tecINSUF_RESERVE_LINE, "tecINSUF_RESERVE_LINE", "Insufficient reserve to add trust line." }, - { tecINSUF_RESERVE_OFFER, "tecINSUF_RESERVE_OFFER", "Insufficient reserve to create offer." }, - { tecNO_DST, "tecNO_DST", "Destination does not exist. Send XRP to create it." }, - { tecNO_DST_INSUF_XRP, "tecNO_DST_INSUF_XRP", "Destination does not exist. Too little XRP sent to create it." }, - { tecNO_LINE_INSUF_RESERVE, "tecNO_LINE_INSUF_RESERVE", "No such line. Too little reserve to create it." }, - { tecNO_LINE_REDUNDANT, "tecNO_LINE_REDUNDANT", "Can't set non-existant line to default." }, - { tecPATH_DRY, "tecPATH_DRY", "Path could not send partial amount." }, - { tecPATH_PARTIAL, "tecPATH_PARTIAL", "Path could not send full amount." }, - - { tecUNFUNDED, "tecUNFUNDED", "One of _ADD, _OFFER, or _SEND. Deprecated." }, - { tecUNFUNDED_ADD, "tecUNFUNDED_ADD", "Insufficient XRP balance for WalletAdd." }, - { tecUNFUNDED_OFFER, "tecUNFUNDED_OFFER", "Insufficient balance to fund created offer." }, - { tecUNFUNDED_PAYMENT, "tecUNFUNDED_PAYMENT", "Insufficient XRP balance to send." }, - - { tefFAILURE, "tefFAILURE", "Failed to apply." }, - { tefALREADY, "tefALREADY", "The exact transaction was already in this ledger." }, - { tefBAD_ADD_AUTH, "tefBAD_ADD_AUTH", "Not authorized to add account." }, - { tefBAD_AUTH, "tefBAD_AUTH", "Transaction's public key is not authorized." }, - { tefBAD_CLAIM_ID, "tefBAD_CLAIM_ID", "Malformed: Bad claim id." }, - { tefBAD_GEN_AUTH, "tefBAD_GEN_AUTH", "Not authorized to claim generator." }, - { tefBAD_LEDGER, "tefBAD_LEDGER", "Ledger in unexpected state." }, - { tefCLAIMED, "tefCLAIMED", "Can not claim a previously claimed account." }, - { tefCREATED, "tefCREATED", "Can't add an already created account." }, - { tefDST_TAG_NEEDED, "tefDST_TAG_NEEDED", "Destination tag required." }, - { tefEXCEPTION, "tefEXCEPTION", "Unexpected program state." }, - { tefGEN_IN_USE, "tefGEN_IN_USE", "Generator already in use." }, - { tefINTERNAL, "tefINTERNAL", "Internal error." }, - { tefNO_AUTH_REQUIRED, "tefNO_AUTH_REQUIRED", "Auth is not required." }, - { tefPAST_SEQ, "tefPAST_SEQ", "This sequence number has already past." }, - - { telLOCAL_ERROR, "telLOCAL_ERROR", "Local failure." }, - { telBAD_DOMAIN, "telBAD_DOMAIN", "Domain too long." }, - { telBAD_PATH_COUNT, "telBAD_PATH_COUNT", "Malformed: Too many paths." }, - { telBAD_PUBLIC_KEY, "telBAD_PUBLIC_KEY", "Public key too long." }, - { telFAILED_PROCESSING, "telFAILED_PROCESSING", "Failed to correctly process transaction." }, - { telINSUF_FEE_P, "telINSUF_FEE_P", "Fee insufficient." }, - { telNO_DST_PARTIAL, "telNO_DST_PARTIAL", "Partial payment to create account not allowed." }, - - { temMALFORMED, "temMALFORMED", "Malformed transaction." }, - { temBAD_AMOUNT, "temBAD_AMOUNT", "Can only send positive amounts." }, - { temBAD_AUTH_MASTER, "temBAD_AUTH_MASTER", "Auth for unclaimed account needs correct master key." }, - { temBAD_CURRENCY, "temBAD_CURRENCY", "Malformed: Bad currency." }, - { temBAD_FEE, "temBAD_FEE", "Invalid fee, negative or not XRP." }, - { temBAD_EXPIRATION, "temBAD_EXPIRATION", "Malformed: Bad expiration." }, - { temBAD_ISSUER, "temBAD_ISSUER", "Malformed: Bad issuer." }, - { temBAD_LIMIT, "temBAD_LIMIT", "Limits must be non-negative." }, - { temBAD_OFFER, "temBAD_OFFER", "Malformed: Bad offer." }, - { temBAD_PATH, "temBAD_PATH", "Malformed: Bad path." }, - { temBAD_PATH_LOOP, "temBAD_PATH_LOOP", "Malformed: Loop in path." }, - { temBAD_PUBLISH, "temBAD_PUBLISH", "Malformed: Bad publish." }, - { temBAD_SIGNATURE, "temBAD_SIGNATURE", "Malformed: Bad signature." }, - { temBAD_SRC_ACCOUNT, "temBAD_SRC_ACCOUNT", "Malformed: Bad source account." }, - { temBAD_TRANSFER_RATE, "temBAD_TRANSFER_RATE", "Malformed: Transfer rate must be >= 1.0" }, - { temBAD_SEQUENCE, "temBAD_SEQUENCE", "Malformed: Sequence is not in the past." }, - { temBAD_SEND_XRP_LIMIT, "temBAD_SEND_XRP_LIMIT", "Malformed: Limit quality is not allowed for XRP to XRP." }, - { temBAD_SEND_XRP_MAX, "temBAD_SEND_XRP_MAX", "Malformed: Send max is not allowed for XRP to XRP." }, - { temBAD_SEND_XRP_NO_DIRECT, "temBAD_SEND_XRP_NO_DIRECT", "Malformed: No Ripple direct is not allowed for XRP to XRP." }, - { temBAD_SEND_XRP_PARTIAL, "temBAD_SEND_XRP_PARTIAL", "Malformed: Partial payment is not allowed for XRP to XRP." }, - { temBAD_SEND_XRP_PATHS, "temBAD_SEND_XRP_PATHS", "Malformed: Paths are not allowed for XRP to XRP." }, - { temDST_IS_SRC, "temDST_IS_SRC", "Destination may not be source." }, - { temDST_NEEDED, "temDST_NEEDED", "Destination not specified." }, - { temINVALID, "temINVALID", "The transaction is ill-formed." }, - { temINVALID_FLAG, "temINVALID_FLAG", "The transaction has an invalid flag." }, - { temREDUNDANT, "temREDUNDANT", "Sends same currency to self." }, - { temREDUNDANT_SEND_MAX, "temREDUNDANT_SEND_MAX", "Send max is redundant." }, - { temRIPPLE_EMPTY, "temRIPPLE_EMPTY", "PathSet with no paths." }, - { temUNCERTAIN, "temUNCERTAIN", "In process of determining result. Never returned." }, - { temUNKNOWN, "temUNKNOWN", "The transactions requires logic not implemented yet." }, - - { terRETRY, "terRETRY", "Retry transaction." }, - { terFUNDS_SPENT, "terFUNDS_SPENT", "Can't set password, password set funds already spent." }, - { terINSUF_FEE_B, "terINSUF_FEE_B", "Account balance can't pay fee." }, - { terLAST, "terLAST", "Process last." }, - { terNO_ACCOUNT, "terNO_ACCOUNT", "The source account does not exist." }, - { terNO_AUTH, "terNO_AUTH", "Not authorized to hold IOUs." }, - { terNO_LINE, "terNO_LINE", "No such line." }, - { terPRE_SEQ, "terPRE_SEQ", "Missing/inapplicable prior transaction." }, - { terOWNERS, "terOWNERS", "Non-zero owner count." }, - - { tesSUCCESS, "tesSUCCESS", "The transaction was applied." }, - }; - - int iIndex = NUMBER(transResultInfoA); - - while (iIndex-- && transResultInfoA[iIndex].terCode != terCode) - ; - - if (iIndex >= 0) - { - strToken = transResultInfoA[iIndex].cpToken; - strHuman = transResultInfoA[iIndex].cpHuman; - } - - return iIndex >= 0; -} - -std::string transToken(TER terCode) -{ - std::string strToken; - std::string strHuman; - - return transResultInfo(terCode, strToken, strHuman) ? strToken : "-"; -} - -std::string transHuman(TER terCode) -{ - std::string strToken; - std::string strHuman; - - return transResultInfo(terCode, strToken, strHuman) ? strHuman : "-"; -} - -// vim:ts=4 diff --git a/src/cpp/TransactionErr.h b/src/cpp/TransactionErr.h deleted file mode 100644 index 2e18d5f164..0000000000 --- a/src/cpp/TransactionErr.h +++ /dev/null @@ -1,153 +0,0 @@ -#ifndef _TRANSACTION_ERR_ -#define _TRANSACTION_ERR_ - -#include - -enum TER // aka TransactionEngineResult -{ - // Note: Range is stable. Exact numbers are currently unstable. Use tokens. - - // -399 .. -300: L Local error (transaction fee inadequate, exceeds local limit) - // Only valid during non-consensus processing. - // Implications: - // - Not forwarded - // - No fee check - telLOCAL_ERROR = -399, - telBAD_DOMAIN, - telBAD_PATH_COUNT, - telBAD_PUBLIC_KEY, - telFAILED_PROCESSING, - telINSUF_FEE_P, - telNO_DST_PARTIAL, - - // -299 .. -200: M Malformed (bad signature) - // Causes: - // - Transaction corrupt. - // Implications: - // - Not applied - // - Not forwarded - // - Reject - // - Can not succeed in any imagined ledger. - temMALFORMED = -299, - temBAD_AMOUNT, - temBAD_AUTH_MASTER, - temBAD_CURRENCY, - temBAD_FEE, - temBAD_EXPIRATION, - temBAD_ISSUER, - temBAD_LIMIT, - temBAD_OFFER, - temBAD_PATH, - temBAD_PATH_LOOP, - temBAD_PUBLISH, - temBAD_TRANSFER_RATE, - temBAD_SEND_XRP_LIMIT, - temBAD_SEND_XRP_MAX, - temBAD_SEND_XRP_NO_DIRECT, - temBAD_SEND_XRP_PARTIAL, - temBAD_SEND_XRP_PATHS, - temBAD_SIGNATURE, - temBAD_SRC_ACCOUNT, - temBAD_SEQUENCE, - temDST_IS_SRC, - temDST_NEEDED, - temINVALID, - temINVALID_FLAG, - temREDUNDANT, - temREDUNDANT_SEND_MAX, - temRIPPLE_EMPTY, - temUNCERTAIN, // An intermediate result used internally, should never be returned. - temUNKNOWN, - - // -199 .. -100: F Failure (sequence number previously used) - // Causes: - // - Transaction cannot succeed because of ledger state. - // - Unexpected ledger state. - // - C++ exception. - // Implications: - // - Not applied - // - Not forwarded - // - Could succeed in an imagined ledger. - tefFAILURE = -199, - tefALREADY, - tefBAD_ADD_AUTH, - tefBAD_AUTH, - tefBAD_CLAIM_ID, - tefBAD_GEN_AUTH, - tefBAD_LEDGER, - tefCLAIMED, - tefCREATED, - tefDST_TAG_NEEDED, - tefEXCEPTION, - tefGEN_IN_USE, - tefINTERNAL, - tefNO_AUTH_REQUIRED, // Can't set auth if auth is not required. - tefPAST_SEQ, - - // -99 .. -1: R Retry (sequence too high, no funds for txn fee, originating account non-existent) - // Causes: - // - Prior application of another, possibly non-existant, another transaction could allow this transaction to succeed. - // Implications: - // - Not applied - // - Not forwarded - // - Might succeed later - // - Hold - // - Makes hole in sequence which jams transactions. - terRETRY = -99, - terFUNDS_SPENT, // This is a free transaction, therefore don't burden network. - terINSUF_FEE_B, // Can't pay fee, therefore don't burden network. - terNO_ACCOUNT, // Can't pay fee, therefore don't burden network. - terNO_AUTH, // Not authorized to hold IOUs. - terNO_LINE, // Internal flag. - terOWNERS, // Can't succeed with non-zero owner count. - terPRE_SEQ, // Can't pay fee, no point in forwarding, therefore don't burden network. - terLAST, // Process after all other transactions - - // 0: S Success (success) - // Causes: - // - Success. - // Implications: - // - Applied - // - Forwarded - tesSUCCESS = 0, - - // 100 .. 129 C Claim fee only (ripple transaction with no good paths, pay to non-existent account, no path) - // Causes: - // - Success, but does not achieve optimal result. - // - Invalid transaction or no effect, but claim fee to use the sequence number. - // Implications: - // - Applied - // - Forwarded - // Only allowed as a return code of appliedTransaction when !tapRetry. Otherwise, treated as terRETRY. - // - // DO NOT CHANGE THESE NUMBERS: They appear in ledger meta data. - tecCLAIM = 100, - tecPATH_PARTIAL = 101, - tecUNFUNDED_ADD = 102, - tecUNFUNDED_OFFER = 103, - tecUNFUNDED_PAYMENT = 104, - tecFAILED_PROCESSING = 105, - tecDIR_FULL = 121, - tecINSUF_RESERVE_LINE = 122, - tecINSUF_RESERVE_OFFER = 123, - tecNO_DST = 124, - tecNO_DST_INSUF_XRP = 125, - tecNO_LINE_INSUF_RESERVE = 126, - tecNO_LINE_REDUNDANT = 127, - tecPATH_DRY = 128, - tecUNFUNDED = 129, // Deprecated, old ambiguous unfunded. -}; - -#define isTelLocal(x) ((x) >= telLOCAL_ERROR && (x) < temMALFORMED) -#define isTemMalformed(x) ((x) >= temMALFORMED && (x) < tefFAILURE) -#define isTefFailure(x) ((x) >= tefFAILURE && (x) < terRETRY) -#define isTerRetry(x) ((x) >= terRETRY && (x) < tesSUCCESS) -#define isTesSuccess(x) ((x) == tesSUCCESS) -#define isTecClaim(x) ((x) >= tecCLAIM) - -bool transResultInfo(TER terCode, std::string& strToken, std::string& strHuman); -std::string transToken(TER terCode); -std::string transHuman(TER terCode); - -#endif -// vim:ts=4 diff --git a/src/js/ripple/currency.js b/src/currency.js similarity index 100% rename from src/js/ripple/currency.js rename to src/currency.js diff --git a/src/js/ripple/hashprefixes.js b/src/hashprefixes.js similarity index 100% rename from src/js/ripple/hashprefixes.js rename to src/hashprefixes.js diff --git a/src/js/ripple/ieee754.js b/src/ieee754.js similarity index 100% rename from src/js/ripple/ieee754.js rename to src/ieee754.js diff --git a/src/js/ripple/index.js b/src/index.js similarity index 93% rename from src/js/ripple/index.js rename to src/index.js index 1c0b5fade2..9c52fad5af 100644 --- a/src/js/ripple/index.js +++ b/src/index.js @@ -22,6 +22,11 @@ exports.TransactionQueue = require('./transactionqueue').TransactionQueue; exports.RangeSet = require('./rangeset').RangeSet; exports.convertBase = require('./baseconverter'); +exports._test = { + PathFind: require('./pathfind').PathFind, + TransactionManager: require('./transactionmanager').TransactionManager +}; + // Important: We do not guarantee any specific version of SJCL or for any // specific features to be included. The version and configuration may change at // any time without warning. diff --git a/src/js/ripple/keypair.js b/src/keypair.js similarity index 100% rename from src/js/ripple/keypair.js rename to src/keypair.js diff --git a/src/js/ripple/ledger.js b/src/ledger.js similarity index 100% rename from src/js/ripple/ledger.js rename to src/ledger.js diff --git a/src/js/ripple/ledgerspaces.js b/src/ledgerspaces.js similarity index 100% rename from src/js/ripple/ledgerspaces.js rename to src/ledgerspaces.js diff --git a/src/js/ripple/log.js b/src/log.js similarity index 100% rename from src/js/ripple/log.js rename to src/log.js diff --git a/src/js/ripple/message.js b/src/message.js similarity index 100% rename from src/js/ripple/message.js rename to src/message.js diff --git a/src/js/ripple/meta.js b/src/meta.js similarity index 100% rename from src/js/ripple/meta.js rename to src/meta.js diff --git a/src/js/ripple/orderbook.js b/src/orderbook.js similarity index 100% rename from src/js/ripple/orderbook.js rename to src/orderbook.js diff --git a/src/js/ripple/orderbookutils.js b/src/orderbookutils.js similarity index 100% rename from src/js/ripple/orderbookutils.js rename to src/orderbookutils.js diff --git a/src/js/ripple/pathfind.js b/src/pathfind.js similarity index 100% rename from src/js/ripple/pathfind.js rename to src/pathfind.js diff --git a/src/js/ripple/rangeset.js b/src/rangeset.js similarity index 100% rename from src/js/ripple/rangeset.js rename to src/rangeset.js diff --git a/src/js/ripple/remote.js b/src/remote.js similarity index 100% rename from src/js/ripple/remote.js rename to src/remote.js diff --git a/src/js/ripple/request.js b/src/request.js similarity index 100% rename from src/js/ripple/request.js rename to src/request.js diff --git a/src/js/ripple/rippleerror.js b/src/rippleerror.js similarity index 100% rename from src/js/ripple/rippleerror.js rename to src/rippleerror.js diff --git a/src/js/ripple/seed.js b/src/seed.js similarity index 100% rename from src/js/ripple/seed.js rename to src/seed.js diff --git a/src/js/ripple/serializedobject.js b/src/serializedobject.js similarity index 100% rename from src/js/ripple/serializedobject.js rename to src/serializedobject.js diff --git a/src/js/ripple/serializedtypes.js b/src/serializedtypes.js similarity index 100% rename from src/js/ripple/serializedtypes.js rename to src/serializedtypes.js diff --git a/src/js/ripple/server.js b/src/server.js similarity index 100% rename from src/js/ripple/server.js rename to src/server.js diff --git a/src/js/ripple/shamap.js b/src/shamap.js similarity index 100% rename from src/js/ripple/shamap.js rename to src/shamap.js diff --git a/src/js/sjcl-custom/index.js b/src/sjcl-custom/index.js similarity index 100% rename from src/js/sjcl-custom/index.js rename to src/sjcl-custom/index.js diff --git a/src/js/sjcl-custom/sjcl-ecc-pointextras.js b/src/sjcl-custom/sjcl-ecc-pointextras.js similarity index 100% rename from src/js/sjcl-custom/sjcl-ecc-pointextras.js rename to src/sjcl-custom/sjcl-ecc-pointextras.js diff --git a/src/js/sjcl-custom/sjcl-ecdsa-canonical.js b/src/sjcl-custom/sjcl-ecdsa-canonical.js similarity index 100% rename from src/js/sjcl-custom/sjcl-ecdsa-canonical.js rename to src/sjcl-custom/sjcl-ecdsa-canonical.js diff --git a/src/js/sjcl-custom/sjcl-ecdsa-der.js b/src/sjcl-custom/sjcl-ecdsa-der.js similarity index 100% rename from src/js/sjcl-custom/sjcl-ecdsa-der.js rename to src/sjcl-custom/sjcl-ecdsa-der.js diff --git a/src/js/sjcl-custom/sjcl-ecdsa-recoverablepublickey.js b/src/sjcl-custom/sjcl-ecdsa-recoverablepublickey.js similarity index 100% rename from src/js/sjcl-custom/sjcl-ecdsa-recoverablepublickey.js rename to src/sjcl-custom/sjcl-ecdsa-recoverablepublickey.js diff --git a/src/js/sjcl-custom/sjcl-extramath.js b/src/sjcl-custom/sjcl-extramath.js similarity index 100% rename from src/js/sjcl-custom/sjcl-extramath.js rename to src/sjcl-custom/sjcl-extramath.js diff --git a/src/js/sjcl-custom/sjcl-jacobi.js b/src/sjcl-custom/sjcl-jacobi.js similarity index 100% rename from src/js/sjcl-custom/sjcl-jacobi.js rename to src/sjcl-custom/sjcl-jacobi.js diff --git a/src/js/sjcl-custom/sjcl-montgomery.js b/src/sjcl-custom/sjcl-montgomery.js similarity index 100% rename from src/js/sjcl-custom/sjcl-montgomery.js rename to src/sjcl-custom/sjcl-montgomery.js diff --git a/src/js/sjcl-custom/sjcl-ripemd160.js b/src/sjcl-custom/sjcl-ripemd160.js similarity index 100% rename from src/js/sjcl-custom/sjcl-ripemd160.js rename to src/sjcl-custom/sjcl-ripemd160.js diff --git a/src/js/sjcl-custom/sjcl-secp256k1.js b/src/sjcl-custom/sjcl-secp256k1.js similarity index 100% rename from src/js/sjcl-custom/sjcl-secp256k1.js rename to src/sjcl-custom/sjcl-secp256k1.js diff --git a/src/js/sjcl-custom/sjcl-validecc.js b/src/sjcl-custom/sjcl-validecc.js similarity index 100% rename from src/js/sjcl-custom/sjcl-validecc.js rename to src/sjcl-custom/sjcl-validecc.js diff --git a/src/js/ripple/transaction.js b/src/transaction.js similarity index 100% rename from src/js/ripple/transaction.js rename to src/transaction.js diff --git a/src/js/ripple/transactionmanager.js b/src/transactionmanager.js similarity index 100% rename from src/js/ripple/transactionmanager.js rename to src/transactionmanager.js diff --git a/src/js/ripple/transactionqueue.js b/src/transactionqueue.js similarity index 100% rename from src/js/ripple/transactionqueue.js rename to src/transactionqueue.js diff --git a/src/js/ripple/uint.js b/src/uint.js similarity index 100% rename from src/js/ripple/uint.js rename to src/uint.js diff --git a/src/js/ripple/uint128.js b/src/uint128.js similarity index 100% rename from src/js/ripple/uint128.js rename to src/uint128.js diff --git a/src/js/ripple/uint160.js b/src/uint160.js similarity index 100% rename from src/js/ripple/uint160.js rename to src/uint160.js diff --git a/src/js/ripple/uint256.js b/src/uint256.js similarity index 100% rename from src/js/ripple/uint256.js rename to src/uint256.js diff --git a/src/js/ripple/utils.js b/src/utils.js similarity index 99% rename from src/js/ripple/utils.js rename to src/utils.js index 620d5594cd..b371f032ff 100644 --- a/src/js/ripple/utils.js +++ b/src/utils.js @@ -158,6 +158,6 @@ exports.fromTimestamp = fromTimestamp; exports.getMantissaDecimalString = getMantissaDecimalString; exports.sjcl = require('sjcl'); -require('../sjcl-custom'); +require('./sjcl-custom'); // vim:sw=2:sts=2:ts=8:et diff --git a/test/mocha.opts b/test/mocha.opts new file mode 100644 index 0000000000..ccd434ecf5 --- /dev/null +++ b/test/mocha.opts @@ -0,0 +1 @@ +--reporter spec --timeout 10000 --slow 500 diff --git a/test/node_modules/ripple-lib b/test/node_modules/ripple-lib index 3db6ddeb30..a8d2a67557 120000 --- a/test/node_modules/ripple-lib +++ b/test/node_modules/ripple-lib @@ -1 +1 @@ -../../src/js/ripple/ \ No newline at end of file +../../src/ \ No newline at end of file diff --git a/test/remote-test.js b/test/remote-test.js index a9d9e4c0bb..4dfdd4cd6b 100644 --- a/test/remote-test.js +++ b/test/remote-test.js @@ -1,34 +1,40 @@ +'use strict'; var assert = require('assert'); var Remote = require('ripple-lib').Remote; var Server = require('ripple-lib').Server; -var Request = require('ripple-lib').Request; var Transaction = require('ripple-lib').Transaction; var UInt160 = require('ripple-lib').UInt160; var Currency = require('ripple-lib').Currency; var Amount = require('ripple-lib').Amount; -var PathFind = require('../src/js/ripple/pathfind').PathFind; +var PathFind = require('ripple-lib')._test.PathFind; -var options, remote, callback, database, tx; +var options, remote, callback; var ADDRESS = 'r4qLSAzv4LZ9TLsR7diphGwKnSEAMQTSjS'; -var PEER_ADDRESS = 'rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX'; var LEDGER_INDEX = 9592219; -var LEDGER_HASH = 'B4FD84A73DBD8F0DA9E320D137176EBFED969691DC0AAC7882B76B595A0841AE'; -var PAGING_MARKER = '29F992CC252056BF690107D1E8F2D9FBAFF29FF107B62B1D1F4E4E11ADF2CC73'; -var TRANSACTION_HASH = '14576FFD5D59FFA73CAA90547BE4DE09926AAB59E981306C32CCE04408CBF8EA'; +var LEDGER_HASH = + 'B4FD84A73DBD8F0DA9E320D137176EBFED969691DC0AAC7882B76B595A0841AE'; +var PAGING_MARKER = + '29F992CC252056BF690107D1E8F2D9FBAFF29FF107B62B1D1F4E4E11ADF2CC73'; +var TRANSACTION_HASH = + '14576FFD5D59FFA73CAA90547BE4DE09926AAB59E981306C32CCE04408CBF8EA'; describe('Remote', function() { beforeEach(function() { options = { trusted: true, - servers: [ 'wss://s1.ripple.com:443' ] + servers: ['wss://s1.ripple.com:443'] }; remote = new Remote(options); }); it('Server initialization -- url object', function() { - var remote = new Remote({ - servers: [ { host: 's-west.ripple.com', port: 443, secure: true } ] + remote = new Remote({ + servers: [{ + host: 's-west.ripple.com', + port: 443, + secure: true + }] }); assert(Array.isArray(remote._servers)); assert(remote._servers[0] instanceof Server); @@ -36,8 +42,11 @@ describe('Remote', function() { }); it('Server initialization -- url object -- no secure property', function() { - var remote = new Remote({ - servers: [ { host: 's-west.ripple.com', port: 443 } ] + remote = new Remote({ + servers: [{ + host: 's-west.ripple.com', + port: 443 + }] }); assert(Array.isArray(remote._servers)); assert(remote._servers[0] instanceof Server); @@ -45,8 +54,12 @@ describe('Remote', function() { }); it('Server initialization -- url object -- secure: false', function() { - var remote = new Remote({ - servers: [ { host: 's-west.ripple.com', port: 443, secure: false } ] + remote = new Remote({ + servers: [{ + host: 's-west.ripple.com', + port: 443, + secure: false + }] }); assert(Array.isArray(remote._servers)); assert(remote._servers[0] instanceof Server); @@ -54,8 +67,12 @@ describe('Remote', function() { }); it('Server initialization -- url object -- string port', function() { - var remote = new Remote({ - servers: [ { host: 's-west.ripple.com', port: '443', secure: true } ] + remote = new Remote({ + servers: [{ + host: 's-west.ripple.com', + port: '443', + secure: true + }] }); assert(Array.isArray(remote._servers)); assert(remote._servers[0] instanceof Server); @@ -65,8 +82,12 @@ describe('Remote', function() { it('Server initialization -- url object -- invalid host', function() { assert.throws( function() { - var remote = new Remote({ - servers: [ { host: '+', port: 443, secure: true } ] + remote = new Remote({ + servers: [{ + host: '+', + port: 443, + secure: true + }] }); }, Error); }); @@ -74,8 +95,12 @@ describe('Remote', function() { it('Server initialization -- url object -- invalid port', function() { assert.throws( function() { - var remote = new Remote({ - servers: [ { host: 's-west.ripple.com', port: null, secure: true } ] + remote = new Remote({ + servers: [{ + host: 's-west.ripple.com', + port: null, + secure: true + }] }); }, TypeError); }); @@ -83,15 +108,19 @@ describe('Remote', function() { it('Server initialization -- url object -- port out of range', function() { assert.throws( function() { - var remote = new Remote({ - servers: [ { host: 's-west.ripple.com', port: 65537, secure: true } ] + remote = new Remote({ + servers: [{ + host: 's-west.ripple.com', + port: 65537, + secure: true + }] }); }, Error); }); it('Server initialization -- url string', function() { - var remote = new Remote({ - servers: [ 'wss://s-west.ripple.com:443' ] + remote = new Remote({ + servers: ['wss://s-west.ripple.com:443'] }); assert(Array.isArray(remote._servers)); assert(remote._servers[0] instanceof Server); @@ -99,8 +128,8 @@ describe('Remote', function() { }); it('Server initialization -- url string -- ws://', function() { - var remote = new Remote({ - servers: [ 'ws://s-west.ripple.com:443' ] + remote = new Remote({ + servers: ['ws://s-west.ripple.com:443'] }); assert(Array.isArray(remote._servers)); assert(remote._servers[0] instanceof Server); @@ -110,8 +139,8 @@ describe('Remote', function() { it('Server initialization -- url string -- invalid host', function() { assert.throws( function() { - var remote = new Remote({ - servers: [ 'ws://+:443' ] + remote = new Remote({ + servers: ['ws://+:443'] }); }, Error ); @@ -120,8 +149,8 @@ describe('Remote', function() { it('Server initialization -- url string -- invalid port', function() { assert.throws( function() { - var remote = new Remote({ - servers: [ 'ws://s-west.ripple.com:null' ] + remote = new Remote({ + servers: ['ws://s-west.ripple.com:null'] }); }, Error ); @@ -130,15 +159,15 @@ describe('Remote', function() { it('Server initialization -- url string -- port out of range', function() { assert.throws( function() { - var remote = new Remote({ - servers: [ 'ws://s-west.ripple.com:65537:' ] + remote = new Remote({ + servers: ['ws://s-west.ripple.com:65537:'] }); }, Error ); }); it('Server initialization -- set max_fee', function() { - var remote = new Remote({ + remote = new Remote({ max_fee: 10 }); assert.strictEqual(remote.max_fee, 10); @@ -151,106 +180,129 @@ describe('Remote', function() { it('Server initialization -- set max_fee -- invalid', function() { assert.throws(function() { - var remote = new Remote({ + remote = new Remote({ max_fee: '1234567890' }); }); }); it('Server initialization -- set trusted', function() { - var remote = new Remote({ trusted: true }); + remote = new Remote({ + trusted: true + }); assert.strictEqual(remote.trusted, true); }); it('Server initialization -- set trusted -- invalid', function() { assert.throws(function() { - var remote = new Remote({ + remote = new Remote({ trusted: '1234567890' }); }); }); it('Server initialization -- set trace', function() { - var remote = new Remote({ trace: true }); + remote = new Remote({ + trace: true + }); assert.strictEqual(remote.trace, true); }); it('Server initialization -- set trace -- invalid', function() { assert.throws(function() { - var remote = new Remote({ + remote = new Remote({ trace: '1234567890' }); }); }); it('Server initialization -- set allow_partial_history', function() { - var remote = new Remote({ allow_partial_history: true }); + remote = new Remote({ + allow_partial_history: true + }); assert.strictEqual(remote.allow_partial_history, true); }); - it('Server initialization -- set allow_partial_history -- invalid', function() { + it('Server initialization -- set allow_partial_history -- invalid', + function() { assert.throws(function() { - var remote = new Remote({ + remote = new Remote({ allow_partial_history: '1234567890' }); }); }); it('Server initialization -- set max_attempts', function() { - var remote = new Remote({ max_attempts: 10 }); + remote = new Remote({ + max_attempts: 10 + }); assert.strictEqual(remote.max_attempts, 10); }); it('Server initialization -- set max_attempts -- invalid', function() { assert.throws(function() { - var remote = new Remote({ + remote = new Remote({ max_attempts: '1234567890' }); }); }); it('Server initialization -- set fee_cushion', function() { - var remote = new Remote({ fee_cushion: 1.3 }); + remote = new Remote({ + fee_cushion: 1.3 + }); assert.strictEqual(remote.fee_cushion, 1.3); }); it('Server initialization -- set fee_cushion -- invalid', function() { assert.throws(function() { - var remote = new Remote({ + remote = new Remote({ fee_cushion: '1234567890' }); }); }); it('Server initialization -- set local_signing', function() { - var remote = new Remote({ local_signing: false }); + remote = new Remote({ + local_signing: false + }); assert.strictEqual(remote.local_signing, false); }); it('Server initialization -- set local_signing -- invalid', function() { assert.throws(function() { - var remote = new Remote({ + remote = new Remote({ local_signing: '1234567890' }); }); }); it('Server initialization -- set local_fee', function() { - var remote = new Remote({ local_fee: false }); + remote = new Remote({ + local_fee: false + }); assert.strictEqual(remote.local_fee, true); - var remote = new Remote({ local_signing: false, local_fee: false }); + remote = new Remote({ + local_signing: false, + local_fee: false + }); assert.strictEqual(remote.local_fee, false); }); it('Server initialization -- set local_fee -- invalid', function() { assert.throws(function() { - var remote = new Remote({ + remote = new Remote({ local_signing: false, local_fee: '1234567890' }); }); }); it('Server initialization -- set local_sequence', function() { - var remote = new Remote({ local_sequence: false }); + remote = new Remote({ + local_sequence: false + }); assert.strictEqual(remote.local_sequence, true); - var remote = new Remote({ local_signing: false, local_sequence: false }); + remote = new Remote({ + local_signing: false, + local_sequence: false + }); assert.strictEqual(remote.local_sequence, false); }); it('Server initialization -- set local_sequence -- invalid', function() { assert.throws(function() { - var remote = new Remote({ + remote = new Remote({ local_signing: false, local_sequence: '1234567890' }); @@ -258,55 +310,63 @@ describe('Remote', function() { }); it('Server initialization -- set canonical_signing', function() { - var remote = new Remote({ canonical_signing: false }); + remote = new Remote({ + canonical_signing: false + }); assert.strictEqual(remote.canonical_signing, false); }); it('Server initialization -- set canonical_signing -- invalid', function() { assert.throws(function() { - var remote = new Remote({ + remote = new Remote({ canonical_signing: '1234567890' }); }); }); it('Server initialization -- set submission_timeout', function() { - var remote = new Remote({ submission_timeout: 10 }); + remote = new Remote({ + submission_timeout: 10 + }); assert.strictEqual(remote.submission_timeout, 10); }); it('Server initialization -- set submission_timeout -- invalid', function() { assert.throws(function() { - var remote = new Remote({ + remote = new Remote({ submission_timeout: '1234567890' }); }); }); it('Server initialization -- set last_ledger_offset', function() { - var remote = new Remote({ last_ledger_offset: 10 }); + remote = new Remote({ + last_ledger_offset: 10 + }); assert.strictEqual(remote.last_ledger_offset, 10); }); it('Server initialization -- set last_ledger_offset -- invalid', function() { assert.throws(function() { - var remote = new Remote({ + remote = new Remote({ last_ledger_offset: '1234567890' }); }); }); it('Server initialization -- set servers', function() { - var remote = new Remote({ servers: [ ] }); - assert.deepEqual(remote.servers, [ ]); + remote = new Remote({ + servers: [] + }); + assert.deepEqual(remote.servers, []); }); it('Server initialization -- set servers -- invalid', function() { assert.throws(function() { - var remote = new Remote({ + remote = new Remote({ servers: '1234567890' }); }); }); it('Automatic transactions subscription', function(done) { - var remote = new Remote(options); + remote = new Remote(options); var i = 0; remote.request = function(request) { @@ -319,52 +379,71 @@ describe('Remote', function() { done(); break; } - assert.deepEqual(request.message.streams, [ 'transactions' ]); + assert.deepEqual(request.message.streams, ['transactions']); }; - remote.on('transaction', function(){}); + remote.on('transaction', function() {}); remote.removeAllListeners('transaction'); }); it('Check is valid message', function() { - assert(Remote.isValidMessage({ type: 'response' })); + assert(Remote.isValidMessage({ + type: 'response' + })); assert(!Remote.isValidMessage({ })); assert(!Remote.isValidMessage('')); }); it('Check is valid ledger data', function() { assert(Remote.isValidLedgerData({ - fee_base: 10, fee_ref: 10, + fee_base: 10, + fee_ref: 10, ledger_hash: LEDGER_HASH, - ledger_index: 1, ledger_time: 1, - reserve_base: 10, reserve_inc: 10 + ledger_index: 1, + ledger_time: 1, + reserve_base: 10, + reserve_inc: 10 })); assert(!Remote.isValidLedgerData({ - fee_base: 10, fee_ref: 10, - ledger_hash: LEDGER_HASH, - ledger_index: 1, ledger_time: 1, - reserve_base: 10, reserve_inc: '10' - })); + fee_base: 10, + fee_ref: 10, + ledger_hash: LEDGER_HASH, + ledger_index: 1, + ledger_time: 1, + reserve_base: 10, + reserve_inc: '10' + })); assert(!Remote.isValidLedgerData({ - fee_base: 10, fee_ref: 10, - ledger_hash: LEDGER_HASH, ledger_index: 1, - reserve_base: 10, reserve_inc: 10 - })); + fee_base: 10, + fee_ref: 10, + ledger_hash: LEDGER_HASH, + ledger_index: 1, + reserve_base: 10, + reserve_inc: 10 + })); }); it('Check is valid load status', function() { assert(Remote.isValidLoadStatus({ - load_base: 10, load_factor: 10 + load_base: 10, + load_factor: 10 })); assert(!Remote.isValidLoadStatus({ - load_base: 10, load_factor: '10' - })); + load_base: 10, + load_factor: '10' + })); assert(!Remote.isValidLoadStatus({ - load_base: 10 - })); + load_base: 10 + })); }); it('Check is validated', function() { - assert(Remote.isValidated({ validated: true })); - assert(!Remote.isValidated({ validated: false })); - assert(!Remote.isValidated({ validated: 'true' })); + assert(Remote.isValidated({ + validated: true + })); + assert(!Remote.isValidated({ + validated: false + })); + assert(!Remote.isValidated({ + validated: 'true' + })); assert(!Remote.isValidated({ })); assert(!Remote.isValidated(null)); }); @@ -454,7 +533,9 @@ describe('Remote', function() { var i = 0; remote._servers.forEach(function(s) { - s.connect = function() { ++i }; + s.connect = function() { + ++i; + }; }); remote.connect(); @@ -468,7 +549,9 @@ describe('Remote', function() { var i = 0; remote._servers.forEach(function(s) { - s.connect = function() { ++i }; + s.connect = function() { + ++i; + }; }); remote.connect(done); @@ -480,7 +563,7 @@ describe('Remote', function() { }); it('Connect -- no servers', function() { - remote._servers = [ ]; + remote._servers = []; assert.throws(function() { remote.connect(); }); @@ -491,7 +574,9 @@ describe('Remote', function() { var i = 0; remote._servers.forEach(function(s) { - s.disconnect = function() { ++i }; + s.disconnect = function() { + ++i; + }; s.emit('connect'); }); @@ -505,7 +590,9 @@ describe('Remote', function() { var i = 0; remote._servers.forEach(function(s) { - s.disconnect = function() { ++i }; + s.disconnect = function() { + ++i; + }; s.emit('connect'); }); @@ -523,7 +610,9 @@ describe('Remote', function() { var i = 0; remote._servers.forEach(function(s) { - s.disconnect = function() { ++i }; + s.disconnect = function() { + ++i; + }; }); remote.disconnect(done); @@ -531,7 +620,7 @@ describe('Remote', function() { assert.strictEqual(i, 0, 'Should not attempt disconnect'); }); it('Disconnect -- no servers', function() { - remote._servers = [ ]; + remote._servers = []; assert.throws(function() { remote.disconnect(); }); @@ -542,7 +631,8 @@ describe('Remote', function() { type: 'ledgerClosed', fee_base: 10, fee_ref: 10, - ledger_hash: 'F824560DD788E5E4B65F5843A6616872873EAB74AA759C73A992355FFDFC4237', + ledger_hash: + 'F824560DD788E5E4B65F5843A6616872873EAB74AA759C73A992355FFDFC4237', ledger_index: 11368614, ledger_time: 475696280, reserve_base: 20000000, @@ -563,7 +653,8 @@ describe('Remote', function() { type: 'ledgerClosed', fee_base: 10, fee_ref: 10, - ledger_hash: 'F824560DD788E5E4B65F5843A6616872873EAB74AA759C73A992355FFDFC4237', + ledger_hash: + 'F824560DD788E5E4B65F5843A6616872873EAB74AA759C73A992355FFDFC4237', ledger_index: 11368614, ledger_time: 475696280, reserve_base: 20000000, @@ -620,7 +711,8 @@ describe('Remote', function() { remote._servers[0].emit('message', message); assert.strictEqual(i, 1); }); - it('Handle server message -- transaction -- with account notification', function() { + it('Handle server message -- transaction -- with account notification', + function() { var message = require('./fixtures/transaction'); var i = 0; var account = remote.addAccount(message.transaction.Account); @@ -639,7 +731,8 @@ describe('Remote', function() { remote._servers[0].emit('message', message); assert.strictEqual(i, 2); }); - it('Handle server message -- transaction proposed -- with account notification', function() { + it('Handle server message -- transaction proposed' + + ' -- with account notification', function() { var message = require('./fixtures/transaction-proposed'); var i = 0; var account = remote.addAccount(message.transaction.Account); @@ -658,7 +751,8 @@ describe('Remote', function() { remote._servers[0].emit('message', message); assert.strictEqual(i, 2); }); - it('Handle server message -- transaction -- with orderbook notification', function() { + it('Handle server message -- transaction' + + ' -- with orderbook notification', function() { var message = require('./fixtures/transaction-offercreate'); var i = 0; var orderbook = remote.createOrderBook({ @@ -688,9 +782,11 @@ describe('Remote', function() { var i = 0; var amount = Amount.from_json( - { currency: 'USD', + { + currency: 'USD', issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', - value: '0.001' } + value: '0.001' + } ); var path = new PathFind(remote, 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59', @@ -714,21 +810,25 @@ describe('Remote', function() { assert.strictEqual(i, 2); }); it('Handle server message -- invalid message', function() { - var message = require('./fixtures/pathfind'); var i = 0; - remote.on('error', function(err) { ++i; }); + remote.on('error', function() { + ++i; + }); remote._servers[0].emit('message', '1'); remote._servers[0].emit('message', { }); - remote._servers[0].emit('message', { type: 'response' }); - remote._servers[0].emit('message', JSON.stringify({ type: 'response' })); + remote._servers[0].emit('message', { + type: 'response' + }); + remote._servers[0].emit('message', JSON.stringify({ + type: 'response' + })); assert.strictEqual(i, 2, 'Failed to receive all invalid message errors'); }); it('Get server', function() { - var server = remote.addServer('wss://sasdf.ripple.com:443'); - + remote.addServer('wss://sasdf.ripple.com:443'); remote.connect(); remote._connected = true; remote._servers.forEach(function(s) { @@ -739,7 +839,8 @@ describe('Remote', function() { type: 'ledgerClosed', fee_base: 10, fee_ref: 10, - ledger_hash: 'F824560DD788E5E4B65F5843A6616872873EAB74AA759C73A992355FFDFC4237', + ledger_hash: + 'F824560DD788E5E4B65F5843A6616872873EAB74AA759C73A992355FFDFC4237', ledger_index: 1, ledger_time: 475696280, reserve_base: 20000000, @@ -760,7 +861,7 @@ describe('Remote', function() { assert.strictEqual(new Remote().getServer(), null); }); it('Get server -- no connected servers', function() { - var server = remote.addServer('wss://sasdf.ripple.com:443'); + remote.addServer('wss://sasdf.ripple.com:443'); assert.strictEqual(remote._servers.length, 2); assert.strictEqual(remote.getServer(), null); }); @@ -781,48 +882,68 @@ describe('Remote', function() { it('Parse binary transaction', function() { var binaryTransaction = require('./fixtures/binary-transaction.json'); - var parsedSourceTag = Remote.parseBinaryTransaction(binaryTransaction.PaymentWithSourceTag.binary); - assert.deepEqual(parsedSourceTag, binaryTransaction.PaymentWithSourceTag.parsed); + var parsedSourceTag = Remote.parseBinaryTransaction( + binaryTransaction.PaymentWithSourceTag.binary); + assert.deepEqual(parsedSourceTag, + binaryTransaction.PaymentWithSourceTag.parsed); - var parsedMemosAndPaths = Remote.parseBinaryTransaction(binaryTransaction.PaymentWithMemosAndPaths.binary); - assert.deepEqual(parsedMemosAndPaths, binaryTransaction.PaymentWithMemosAndPaths.parsed); + var parsedMemosAndPaths = Remote.parseBinaryTransaction( + binaryTransaction.PaymentWithMemosAndPaths.binary); + assert.deepEqual(parsedMemosAndPaths, + binaryTransaction.PaymentWithMemosAndPaths.parsed); - var parsedPartialPayment = Remote.parseBinaryTransaction(binaryTransaction.PartialPayment.binary); - assert.deepEqual(parsedPartialPayment, binaryTransaction.PartialPayment.parsed); + var parsedPartialPayment = Remote.parseBinaryTransaction( + binaryTransaction.PartialPayment.binary); + assert.deepEqual(parsedPartialPayment, + binaryTransaction.PartialPayment.parsed); - var parsedOfferCreate = Remote.parseBinaryTransaction(binaryTransaction.OfferCreate.binary); + var parsedOfferCreate = Remote.parseBinaryTransaction( + binaryTransaction.OfferCreate.binary); assert.deepEqual(parsedOfferCreate, binaryTransaction.OfferCreate.parsed); - var parsedPartialPaymentWithXRPDelieveredAmount = Remote.parseBinaryTransaction(binaryTransaction.PartialPaymentWithXRPDeliveredAmount.binary); - assert.deepEqual(parsedPartialPaymentWithXRPDelieveredAmount, binaryTransaction.PartialPaymentWithXRPDeliveredAmount.parsed); + var parsedPartialPaymentWithXRPDelieveredAmount = + Remote.parseBinaryTransaction( + binaryTransaction.PartialPaymentWithXRPDeliveredAmount.binary); + assert.deepEqual(parsedPartialPaymentWithXRPDelieveredAmount, + binaryTransaction.PartialPaymentWithXRPDeliveredAmount.parsed); }); it('Parse binary account transaction', function() { - var binaryAccountTransaction = require('./fixtures/binary-account-transaction.json'); + var binaryAccountTransaction = + require('./fixtures/binary-account-transaction.json'); - var parsed = Remote.parseBinaryAccountTransaction(binaryAccountTransaction.OfferCreate.binary); + var parsed = Remote.parseBinaryAccountTransaction( + binaryAccountTransaction.OfferCreate.binary); assert.deepEqual(parsed, binaryAccountTransaction.OfferCreate.parsed); - var parsedPartialPayment = Remote.parseBinaryAccountTransaction(binaryAccountTransaction.PartialPayment.binary); - assert.deepEqual(parsedPartialPayment, binaryAccountTransaction.PartialPayment.parsed); + var parsedPartialPayment = Remote.parseBinaryAccountTransaction( + binaryAccountTransaction.PartialPayment.binary); + assert.deepEqual(parsedPartialPayment, + binaryAccountTransaction.PartialPayment.parsed); - var parsedPayment = Remote.parseBinaryAccountTransaction(binaryAccountTransaction.Payment.binary); + var parsedPayment = Remote.parseBinaryAccountTransaction( + binaryAccountTransaction.Payment.binary); assert.deepEqual(parsedPayment, binaryAccountTransaction.Payment.parsed); }); it('Parse binary ledger', function() { var binaryLedgerData = require('./fixtures/binary-ledger-data.json'); - var parsedAccountRoot = Remote.parseBinaryLedgerData(binaryLedgerData.AccountRoot.binary); + var parsedAccountRoot = Remote.parseBinaryLedgerData( + binaryLedgerData.AccountRoot.binary); assert.deepEqual(parsedAccountRoot, binaryLedgerData.AccountRoot.parsed); - var parsedOffer = Remote.parseBinaryLedgerData(binaryLedgerData.Offer.binary); + var parsedOffer = Remote.parseBinaryLedgerData( + binaryLedgerData.Offer.binary); assert.deepEqual(parsedOffer, binaryLedgerData.Offer.parsed); - var parsedDirectoryNode = Remote.parseBinaryLedgerData(binaryLedgerData.DirectoryNode.binary); - assert.deepEqual(parsedDirectoryNode, binaryLedgerData.DirectoryNode.parsed); + var parsedDirectoryNode = Remote.parseBinaryLedgerData( + binaryLedgerData.DirectoryNode.binary); + assert.deepEqual(parsedDirectoryNode, + binaryLedgerData.DirectoryNode.parsed); - var parsedRippleState = Remote.parseBinaryLedgerData(binaryLedgerData.RippleState.binary); + var parsedRippleState = Remote.parseBinaryLedgerData( + binaryLedgerData.RippleState.binary); assert.deepEqual(parsedRippleState, binaryLedgerData.RippleState.parsed); }); @@ -841,7 +962,7 @@ describe('Remote', function() { remote._connected = true; remote._servers[0]._connected = true; assert.strictEqual(remote.feeTx(10).to_json(), '12'); - remote._servers = [ ]; + remote._servers = []; assert.throws(function() { remote.feeTx(10).to_json(); }); @@ -850,7 +971,7 @@ describe('Remote', function() { remote._connected = true; remote._servers[0]._connected = true; assert.strictEqual(remote.feeTxUnit(), 1.2); - remote._servers = [ ]; + remote._servers = []; assert.throws(function() { remote.feeTxUnit(10).to_json(); }); @@ -859,7 +980,7 @@ describe('Remote', function() { remote._connected = true; remote._servers[0]._connected = true; assert.strictEqual(remote.reserve(1).to_json(), 'NaN'); - remote._servers = [ ]; + remote._servers = []; assert.throws(function() { remote.reserve(10).to_json(); }); @@ -870,13 +991,15 @@ describe('Remote', function() { assert.deepEqual(request.message, { command: 'server_info', - id: void(0) + id: undefined }); - var i =0; + var i = 0; remote._connected = true; remote._servers[0]._connected = true; - remote._servers[0]._request = function() { ++i; }; + remote._servers[0]._request = function() { + ++i; + }; remote.request(request); assert.strictEqual(i, 1, 'Did not initiate request'); @@ -886,13 +1009,15 @@ describe('Remote', function() { assert.deepEqual(request.message, { command: 'server_info', - id: void(0) + id: undefined }); - var i =0; + var i = 0; remote._connected = true; remote._servers[0]._connected = true; - remote._servers[0]._request = function() { ++i; }; + remote._servers[0]._request = function() { + ++i; + }; remote.request(request); assert.strictEqual(i, 1, 'Did not initiate request'); @@ -907,7 +1032,10 @@ describe('Remote', function() { remote.request({ }); }); assert.throws(function() { - remote.request({ command: 'server_info', id: 1 }); + remote.request({ + command: 'server_info', + id: 1 + }); }); }); it('Initiate request -- set non-existent servers', function() { @@ -924,77 +1052,91 @@ describe('Remote', function() { var request = remote.requestLedger(); assert.deepEqual(request.message, { command: 'ledger', - id: void(0) + id: undefined }); }); it('Construct ledger request -- with ledger index', function() { - var request = remote.requestLedger({ ledger: 1 }); + var request = remote.requestLedger({ + ledger: 1 + }); assert.deepEqual(request.message, { command: 'ledger', - id: void(0), + id: undefined, + ledger_index: 1 + }); + request = remote.requestLedger({ ledger_index: 1 }); - request = remote.requestLedger({ ledger_index: 1 }); assert.deepEqual(request.message, { command: 'ledger', - id: void(0), + id: undefined, ledger_index: 1 }); request = remote.requestLedger(1); assert.deepEqual(request.message, { command: 'ledger', - id: void(0), + id: undefined, ledger_index: 1 }); request = remote.requestLedger(null); assert.deepEqual(request.message, { command: 'ledger', - id: void(0) + id: undefined }); }); it('Construct ledger request -- with ledger hash', function() { - var request = remote.requestLedger({ ledger: LEDGER_HASH }); + var request = remote.requestLedger({ + ledger: LEDGER_HASH + }); assert.deepEqual(request.message, { command: 'ledger', - id: void(0), + id: undefined, + ledger_hash: LEDGER_HASH + }); + request = remote.requestLedger({ ledger_hash: LEDGER_HASH }); - var request = remote.requestLedger({ ledger_hash: LEDGER_HASH }); assert.deepEqual(request.message, { command: 'ledger', - id: void(0), + id: undefined, ledger_hash: LEDGER_HASH }); - var request = remote.requestLedger(LEDGER_HASH); + request = remote.requestLedger(LEDGER_HASH); assert.deepEqual(request.message, { command: 'ledger', - id: void(0), + id: undefined, ledger_hash: LEDGER_HASH }); }); it('Construct ledger request -- with ledger identifier', function() { - var request = remote.requestLedger({ ledger: 'validated' }); + var request = remote.requestLedger({ + ledger: 'validated' + }); assert.deepEqual(request.message, { command: 'ledger', - id: void(0), + id: undefined, ledger_index: 'validated' }); - request = remote.requestLedger({ ledger: 'current' }); + request = remote.requestLedger({ + ledger: 'current' + }); assert.deepEqual(request.message, { command: 'ledger', - id: void(0), + id: undefined, ledger_index: 'current' }); request = remote.requestLedger('validated'); assert.deepEqual(request.message, { command: 'ledger', - id: void(0), + id: undefined, ledger_index: 'validated' }); - request = remote.requestLedger({ validated: true }); + request = remote.requestLedger({ + validated: true + }); assert.deepEqual(request.message, { command: 'ledger', - id: void(0), + id: undefined, ledger_index: 'validated' }); }); @@ -1005,7 +1147,7 @@ describe('Remote', function() { }); assert.deepEqual(request.message, { command: 'ledger', - id: void(0), + id: undefined, ledger_index: 'validated', transactions: true }); @@ -1015,25 +1157,25 @@ describe('Remote', function() { var request = remote.requestLedgerClosed(); assert.deepEqual(request.message, { command: 'ledger_closed', - id: void(0), + id: undefined }); }); it('Construct ledger_header request', function() { var request = remote.requestLedgerHeader(); assert.deepEqual(request.message, { command: 'ledger_header', - id: void(0) + id: undefined }); }); it('Construct ledger_current request', function() { var request = remote.requestLedgerCurrent(); assert.deepEqual(request.message, { command: 'ledger_current', - id: void(0) + id: undefined }); }); - it ('Construct ledger_data request -- with ledger hash', function() { + it('Construct ledger_data request -- with ledger hash', function() { var request = remote.requestLedgerData({ ledger: LEDGER_HASH, limit: 5 @@ -1048,8 +1190,8 @@ describe('Remote', function() { }); }); - it ('Construct ledger_data request -- with ledger index', function() { - var request = remote.requestLedgerData( { + it('Construct ledger_data request -- with ledger index', function() { + var request = remote.requestLedgerData({ ledger: LEDGER_INDEX, limit: 5 }); @@ -1059,12 +1201,12 @@ describe('Remote', function() { id: undefined, binary: true, ledger_index: LEDGER_INDEX, - limit: 5, + limit: 5 }); }); - it ('Construct ledger_data request -- no binary', function() { - var request = remote.requestLedgerData( { + it('Construct ledger_data request -- no binary', function() { + var request = remote.requestLedgerData({ ledger: LEDGER_HASH, limit: 5, binary: false @@ -1075,7 +1217,7 @@ describe('Remote', function() { id: undefined, binary: false, ledger_hash: LEDGER_HASH, - limit: 5, + limit: 5 }); }); @@ -1083,15 +1225,15 @@ describe('Remote', function() { var request = remote.requestServerInfo(); assert.deepEqual(request.message, { command: 'server_info', - id: void(0) + id: undefined }); - }) + }); it('Construct peers request', function() { var request = remote.requestPeers(); assert.deepEqual(request.message, { command: 'peers', - id: void(0) + id: undefined }); }); @@ -1099,7 +1241,7 @@ describe('Remote', function() { var request = remote.requestConnect('0.0.0.0', '443'); assert.deepEqual(request.message, { command: 'connect', - id: void(0), + id: undefined, ip: '0.0.0.0', port: '443' }); @@ -1110,7 +1252,7 @@ describe('Remote', function() { assert.deepEqual(request.message, { command: 'unl_add', node: '0.0.0.0', - id: void(0) + id: undefined }); }); @@ -1118,7 +1260,7 @@ describe('Remote', function() { var request = remote.requestUnlList(); assert.deepEqual(request.message, { command: 'unl_list', - id: void(0) + id: undefined }); }); @@ -1127,24 +1269,24 @@ describe('Remote', function() { assert.deepEqual(request.message, { command: 'unl_delete', node: '0.0.0.0', - id: void(0) + id: undefined }); }); it('Construct subscribe request', function() { - var request = remote.requestSubscribe([ 'server', 'ledger' ]); + var request = remote.requestSubscribe(['server', 'ledger']); assert.deepEqual(request.message, { command: 'subscribe', - id: void(0), - streams: [ 'server', 'ledger' ] + id: undefined, + streams: ['server', 'ledger'] }); }); it('Construct unsubscribe request', function() { - var request = remote.requestUnsubscribe([ 'server', 'ledger' ]); + var request = remote.requestUnsubscribe(['server', 'ledger']); assert.deepEqual(request.message, { command: 'unsubscribe', - id: void(0), - streams: [ 'server', 'ledger' ] + id: undefined, + streams: ['server', 'ledger'] }); }); @@ -1152,7 +1294,7 @@ describe('Remote', function() { var request = remote.requestPing(); assert.deepEqual(request.message, { command: 'ping', - id: void(0) + id: undefined }); }); it('Construct ping request -- with server', function() { @@ -1160,67 +1302,93 @@ describe('Remote', function() { assert.strictEqual(request.server, remote._servers[0]); assert.deepEqual(request.message, { command: 'ping', - id: void(0) + id: undefined }); }); it('Construct account_currencies request -- with ledger index', function() { - var request = remote.requestAccountCurrencies({account: ADDRESS}); + var request = remote.requestAccountCurrencies({ + account: ADDRESS + }); assert.strictEqual(request.message.command, 'account_currencies'); assert.strictEqual(request.message.account, ADDRESS); }); it('Construct account_info request -- with ledger index', function() { - var request = remote.requestAccountInfo({account: ADDRESS, ledger: 9592219}); + var request = remote.requestAccountInfo({ + account: ADDRESS, + ledger: 9592219 + }); assert.strictEqual(request.message.command, 'account_info'); assert.strictEqual(request.message.account, ADDRESS); assert.strictEqual(request.message.ledger_index, 9592219); }); it('Construct account_info request -- with ledger hash', function() { - var request = remote.requestAccountInfo({account: ADDRESS, ledger: LEDGER_HASH}); + var request = remote.requestAccountInfo({ + account: ADDRESS, + ledger: LEDGER_HASH + }); assert.strictEqual(request.message.command, 'account_info'); assert.strictEqual(request.message.account, ADDRESS); assert.strictEqual(request.message.ledger_hash, LEDGER_HASH); }); it('Construct account_info request -- with ledger identifier', function() { - var request = remote.requestAccountInfo({account: ADDRESS, ledger: 'validated'}); + var request = remote.requestAccountInfo({ + account: ADDRESS, + ledger: 'validated' + }); assert.strictEqual(request.message.command, 'account_info'); assert.strictEqual(request.message.account, ADDRESS); assert.strictEqual(request.message.ledger_index, 'validated'); }); it('Construct account balance request -- with ledger index', function() { - var request = remote.requestAccountBalance({account:ADDRESS, ledger:9592219}); + var request = remote.requestAccountBalance({ + account: ADDRESS, + ledger: 9592219 + }); assert.strictEqual(request.message.command, 'ledger_entry'); assert.strictEqual(request.message.account_root, ADDRESS); assert.strictEqual(request.message.ledger_index, 9592219); }); it('Construct account balance request -- with ledger hash', function() { - var request = remote.requestAccountBalance({account:ADDRESS, ledger:LEDGER_HASH}); + var request = remote.requestAccountBalance({ + account: ADDRESS, + ledger: LEDGER_HASH + }); assert.strictEqual(request.message.command, 'ledger_entry'); assert.strictEqual(request.message.account_root, ADDRESS); assert.strictEqual(request.message.ledger_hash, LEDGER_HASH); }); it('Construct account balance request -- with ledger identifier', function() { - var request = remote.requestAccountBalance({account:ADDRESS, ledger:'validated'}); + var request = remote.requestAccountBalance({ + account: ADDRESS, + ledger: 'validated' + }); assert.strictEqual(request.message.command, 'ledger_entry'); assert.strictEqual(request.message.account_root, ADDRESS); assert.strictEqual(request.message.ledger_index, 'validated'); }); it('Construct account flags request', function() { - var request = remote.requestAccountFlags({account:ADDRESS}); + var request = remote.requestAccountFlags({ + account: ADDRESS + }); assert.strictEqual(request.message.command, 'ledger_entry'); assert.strictEqual(request.message.account_root, ADDRESS); }); it('Construct account owner count request', function() { - var request = remote.requestOwnerCount({account:ADDRESS}); + var request = remote.requestOwnerCount({ + account: ADDRESS + }); assert.strictEqual(request.message.command, 'ledger_entry'); assert.strictEqual(request.message.account_root, ADDRESS); }); it('Construct account_lines request', function() { - var request = remote.requestAccountLines({ account: ADDRESS }); + var request = remote.requestAccountLines({ + account: ADDRESS + }); assert.deepEqual(request.message, { command: 'account_lines', id: undefined, @@ -1240,7 +1408,10 @@ describe('Remote', function() { }); }); it('Construct account_lines request -- with limit', function() { - var request = remote.requestAccountLines({account: ADDRESS, limit: 100}); + var request = remote.requestAccountLines({ + account: ADDRESS, + limit: 100 + }); assert.deepEqual(request.message, { command: 'account_lines', id: undefined, @@ -1250,7 +1421,10 @@ describe('Remote', function() { }); it('Construct account_lines request -- with limit and marker', function() { var request = remote.requestAccountLines({ - account: ADDRESS, limit: 100, marker: PAGING_MARKER, ledger: 9592219 + account: ADDRESS, + limit: 100, + marker: PAGING_MARKER, + ledger: 9592219 }); assert.deepEqual(request.message, { command: 'account_lines', @@ -1262,41 +1436,85 @@ describe('Remote', function() { }); }); it('Construct account_lines request -- with min limit', function() { - assert.strictEqual(remote.requestAccountLines({account: ADDRESS, limit: 0}).message.limit, 0); - assert.strictEqual(remote.requestAccountLines({account: ADDRESS, limit: -1}).message.limit, 0); - assert.strictEqual(remote.requestAccountLines({account: ADDRESS, limit: -1e9}).message.limit, 0); - assert.strictEqual(remote.requestAccountLines({account: ADDRESS, limit: -1e24}).message.limit, 0); + assert.strictEqual(remote.requestAccountLines({ + account: ADDRESS, + limit: 0 + }).message.limit, 0); + assert.strictEqual(remote.requestAccountLines({ + account: ADDRESS, + limit: -1 + }).message.limit, 0); + assert.strictEqual(remote.requestAccountLines({ + account: ADDRESS, + limit: -1e9 + }).message.limit, 0); + assert.strictEqual(remote.requestAccountLines({ + account: ADDRESS, + limit: -1e24 + }).message.limit, 0); }); it('Construct account_lines request -- with max limit', function() { - assert.strictEqual(remote.requestAccountLines({account: ADDRESS, limit: 1e9}).message.limit, 1e9); - assert.strictEqual(remote.requestAccountLines({account: ADDRESS, limit: 1e9+1}).message.limit, 1e9); - assert.strictEqual(remote.requestAccountLines({account: ADDRESS, limit: 1e10}).message.limit, 1e9); - assert.strictEqual(remote.requestAccountLines({account: ADDRESS, limit: 1e24}).message.limit, 1e9); + assert.strictEqual(remote.requestAccountLines({ + account: ADDRESS, + limit: 1e9 + }).message.limit, 1e9); + assert.strictEqual(remote.requestAccountLines({ + account: ADDRESS, + limit: 1e9 + 1 + }).message.limit, 1e9); + assert.strictEqual(remote.requestAccountLines({ + account: ADDRESS, + limit: 1e10 + }).message.limit, 1e9); + assert.strictEqual(remote.requestAccountLines({ + account: ADDRESS, + limit: 1e24 + }).message.limit, 1e9); }); - it('Construct account_lines request -- with marker -- missing ledger', function() { + it('Construct account_lines request -- with marker -- missing ledger', + function() { assert.throws(function() { - remote.requestAccountLines({account: ADDRESS, marker: PAGING_MARKER}) - },'A ledger_index or ledger_hash must be provided when using a marker'); + remote.requestAccountLines({ + account: ADDRESS, + marker: PAGING_MARKER + }); + }, 'A ledger_index or ledger_hash must be provided when using a marker'); assert.throws(function() { - remote.requestAccountLines({account: ADDRESS, marker: PAGING_MARKER, ledger:'validated'}) - },'A ledger_index or ledger_hash must be provided when using a marker'); + remote.requestAccountLines({ + account: ADDRESS, + marker: PAGING_MARKER, + ledger: 'validated' + }); + }, 'A ledger_index or ledger_hash must be provided when using a marker'); assert.throws(function() { - remote.requestAccountLines({account: ADDRESS, marker: PAGING_MARKER, ledger:NaN}) - },'A ledger_index or ledger_hash must be provided when using a marker'); + remote.requestAccountLines({ + account: ADDRESS, + marker: PAGING_MARKER, + ledger: NaN + }); + }, 'A ledger_index or ledger_hash must be provided when using a marker'); assert.throws(function() { - remote.requestAccountLines({account: ADDRESS, marker: PAGING_MARKER, ledger:LEDGER_HASH.substr(0,63)}) - },'A ledger_index or ledger_hash must be provided when using a marker'); + remote.requestAccountLines({ + account: ADDRESS, + marker: PAGING_MARKER, + ledger: LEDGER_HASH.substr(0, 63) + }); + }, 'A ledger_index or ledger_hash must be provided when using a marker'); assert.throws(function() { - remote.requestAccountLines({account: ADDRESS, marker: PAGING_MARKER, ledger:LEDGER_HASH+'F'}) - },'A ledger_index or ledger_hash must be provided when using a marker'); + remote.requestAccountLines({ + account: ADDRESS, + marker: PAGING_MARKER, + ledger: LEDGER_HASH + 'F' + }); + }, 'A ledger_index or ledger_hash must be provided when using a marker'); }); it('Construct account_lines request -- with callback', function() { var request = remote.requestAccountLines({ - account: ADDRESS, + account: ADDRESS }, callback); assert.deepEqual(request.message, { @@ -1306,7 +1524,7 @@ describe('Remote', function() { }); }); - it ('Construct account_tx request', function() { + it('Construct account_tx request', function() { var request = remote.requestAccountTransactions({ account: UInt160.ACCOUNT_ONE, ledger_index_min: -1, @@ -1328,7 +1546,7 @@ describe('Remote', function() { marker: PAGING_MARKER }); - var request = remote.requestAccountTransactions({ + request = remote.requestAccountTransactions({ account: UInt160.ACCOUNT_ONE, min_ledger: -1, max_ledger: -1 @@ -1342,7 +1560,7 @@ describe('Remote', function() { ledger_index_max: -1 }); }); - it ('Construct account_tx request -- no binary', function() { + it('Construct account_tx request -- no binary', function() { var request = remote.requestAccountTransactions({ account: UInt160.ACCOUNT_ONE, ledger_index_min: -1, @@ -1366,8 +1584,10 @@ describe('Remote', function() { }); }); - it ('Construct account_offers request -- no binary', function() { - var request = remote.requestAccountOffers({ account: ADDRESS }); + it('Construct account_offers request -- no binary', function() { + var request = remote.requestAccountOffers({ + account: ADDRESS + }); assert.deepEqual(request.message, { command: 'account_offers', id: undefined, @@ -1376,27 +1596,43 @@ describe('Remote', function() { }); it('Construct offer request -- with ledger index', function() { - var request = remote.requestOffer({ index: TRANSACTION_HASH, ledger: LEDGER_INDEX}); + var request = remote.requestOffer({ + index: TRANSACTION_HASH, + ledger: LEDGER_INDEX + }); assert.strictEqual(request.message.command, 'ledger_entry'); assert.strictEqual(request.message.offer, TRANSACTION_HASH); assert.strictEqual(request.message.ledger_index, LEDGER_INDEX); }); it('Construct offer request -- with ledger index and sequence', function() { - var request = remote.requestOffer({account: ADDRESS, ledger: LEDGER_INDEX, sequence: 5}); + var request = remote.requestOffer({ + account: ADDRESS, + ledger: LEDGER_INDEX, + sequence: 5 + }); assert.strictEqual(request.message.command, 'ledger_entry'); assert.strictEqual(request.message.offer.account, ADDRESS); assert.strictEqual(request.message.offer.seq, 5); assert.strictEqual(request.message.ledger_index, LEDGER_INDEX); }); it('Construct offer request -- with ledger hash', function() { - var request = remote.requestOffer({account: ADDRESS, ledger: LEDGER_HASH, sequence: 5}); + var request = remote.requestOffer({ + account: ADDRESS, + ledger: LEDGER_HASH, + sequence: 5 + }); assert.strictEqual(request.message.command, 'ledger_entry'); assert.strictEqual(request.message.offer.account, ADDRESS); assert.strictEqual(request.message.offer.seq, 5); assert.strictEqual(request.message.ledger_hash, LEDGER_HASH); }); - it('Construct offer request -- with ledger identifier and sequence', function() { - var request = remote.requestOffer({account: ADDRESS, ledger: 'validated', sequence: 5}); + it('Construct offer request -- with ledger identifier and sequence', + function() { + var request = remote.requestOffer({ + account: ADDRESS, + ledger: 'validated', + sequence: 5 + }); assert.strictEqual(request.message.command, 'ledger_entry'); assert.strictEqual(request.message.offer.account, ADDRESS); assert.strictEqual(request.message.offer.seq, 5); @@ -1457,7 +1693,7 @@ describe('Remote', function() { }); }); - it ('Construct tx request', function() { + it('Construct tx request', function() { var request = remote.requestTransaction({ hash: TRANSACTION_HASH }); @@ -1469,8 +1705,8 @@ describe('Remote', function() { transaction: TRANSACTION_HASH }); }); - it ('Construct tx request -- no binary', function() { - var request = remote.requestTransaction( { + it('Construct tx request -- no binary', function() { + var request = remote.requestTransaction({ hash: TRANSACTION_HASH, binary: false }); @@ -1523,7 +1759,7 @@ describe('Remote', function() { }); it('Construct transaction_entry request -- with invalid ledger', function() { assert.throws(function() { - var request = remote.requestTransactionEntry({ + remote.requestTransactionEntry({ hash: TRANSACTION_HASH, ledger: {} }); @@ -1557,7 +1793,7 @@ describe('Remote', function() { remote.trusted = false; assert.throws(function() { - var request = remote.requestWalletAccounts({ + remote.requestWalletAccounts({ seed: 'shmnpxY42DaoyNbNQDoGuymNT1T9U' }); }); @@ -1588,7 +1824,7 @@ describe('Remote', function() { remote.trusted = false; assert.throws(function() { - var request = remote.requestSign({ + remote.requestSign({ secret: 'shmnpxY42DaoyNbNQDoGuymNT1T9U', tx_json: { Flags: 0, @@ -1627,7 +1863,7 @@ describe('Remote', function() { }); it('Construct transaction -- invalid type', function() { assert.throws(function() { - var tx = remote.createTransaction('AccountSetz', { + remote.createTransaction('AccountSetz', { account: 'rwLZs9MUVv28XZdYXDk9uNRUpAh1c6jij8', flags: 0 }); @@ -1640,7 +1876,7 @@ describe('Remote', function() { assert.deepEqual(request.message, { command: 'ledger_accept', - id: void(0) + id: undefined }); remote._servers[0].emit('connect'); @@ -1648,7 +1884,8 @@ describe('Remote', function() { type: 'ledgerClosed', fee_base: 10, fee_ref: 10, - ledger_hash: 'F824560DD788E5E4B65F5843A6616872873EAB74AA759C73A992355FFDFC4237', + ledger_hash: + 'F824560DD788E5E4B65F5843A6616872873EAB74AA759C73A992355FFDFC4237', ledger_index: 11368614, ledger_time: 475696280, reserve_base: 20000000, @@ -1659,7 +1896,7 @@ describe('Remote', function() { }); it('Construct ledger_accept request -- not standalone', function() { assert.throws(function() { - var request = remote.requestLedgerAccept(); + remote.requestLedgerAccept(); }); }); @@ -1673,7 +1910,7 @@ describe('Remote', function() { assert.deepEqual(request.message, { command: 'ledger_entry', - id: void(0), + id: undefined, ripple_state: { currency: 'USD', accounts: [ @@ -1690,12 +1927,15 @@ describe('Remote', function() { src_account: 'rGr9PjmVe7MqEXTSbd3njhgJc2s5vpHV54', dst_account: 'rwxBjBC9fPzyQ9GgPZw6YYLNeRTSx5c2W6', dst_amount: '1/USD/rGr9PjmVe7MqEXTSbd3njhgJc2s5vpHV54', - src_currencies: [ { currency: 'BTC', issuer: 'rwxBjBC9fPzyQ9GgPZw6YYLNeRTSx5c2W6' } ] + src_currencies: [{ + currency: 'BTC', + issuer: 'rwxBjBC9fPzyQ9GgPZw6YYLNeRTSx5c2W6' + }] }); assert.deepEqual(request.message, { command: 'ripple_path_find', - id: void(0), + id: undefined, source_account: 'rGr9PjmVe7MqEXTSbd3njhgJc2s5vpHV54', destination_account: 'rwxBjBC9fPzyQ9GgPZw6YYLNeRTSx5c2W6', destination_amount: { @@ -1715,12 +1955,15 @@ describe('Remote', function() { src_account: 'rGr9PjmVe7MqEXTSbd3njhgJc2s5vpHV54', dst_account: 'rwxBjBC9fPzyQ9GgPZw6YYLNeRTSx5c2W6', dst_amount: '1/USD/rGr9PjmVe7MqEXTSbd3njhgJc2s5vpHV54', - src_currencies: [ { currency: 'BTC', issuer: 'rwxBjBC9fPzyQ9GgPZw6YYLNeRTSx5c2W6' } ] + src_currencies: [{ + currency: 'BTC', + issuer: 'rwxBjBC9fPzyQ9GgPZw6YYLNeRTSx5c2W6' + }] }); assert.deepEqual(request.message, { command: 'path_find', - id: void(0), + id: undefined, subcommand: 'create', source_account: 'rGr9PjmVe7MqEXTSbd3njhgJc2s5vpHV54', destination_account: 'rwxBjBC9fPzyQ9GgPZw6YYLNeRTSx5c2W6', @@ -1741,8 +1984,8 @@ describe('Remote', function() { assert.deepEqual(request.message, { command: 'path_find', - id: void(0), - subcommand: 'close', + id: undefined, + subcommand: 'close' }); }); }); diff --git a/test/transaction-manager-test.js b/test/transaction-manager-test.js index 7bd390795f..2c92c7a4dd 100644 --- a/test/transaction-manager-test.js +++ b/test/transaction-manager-test.js @@ -7,8 +7,7 @@ var sjcl = require('ripple-lib').sjcl; var Remote = require('ripple-lib').Remote; var SerializedObject = require('ripple-lib').SerializedObject; var Transaction = require('ripple-lib').Transaction; -var TransactionManager = require('../src/js/ripple/transactionmanager') -.TransactionManager; +var TransactionManager = require('ripple-lib')._test.TransactionManager; var LEDGER = require('./fixtures/transactionmanager').LEDGER; var ACCOUNT = require('./fixtures/transactionmanager').ACCOUNT;