From c53b6e09407ddead71ffc653593477ee57fb9833 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Mon, 2 Dec 2019 19:25:10 -0800 Subject: [PATCH] fix(SLP balancesForAddress): Fixed unit tests --- src/routes/v3/slp.js | 11 +++++++---- test/v3/slp.js | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/routes/v3/slp.js b/src/routes/v3/slp.js index 6f6e1af..40357a7 100644 --- a/src/routes/v3/slp.js +++ b/src/routes/v3/slp.js @@ -9,6 +9,9 @@ const routeUtils = require("./route-utils") const strftime = require("strftime") const wlogger = require("../../util/winston-logging") +const BCHJS = require("@chris.troutner/bch-js") +const bchjs = new BCHJS() + // Used to convert error messages to strings, to safely pass to users. const util = require("util") util.inspect.defaultOptions = { depth: 5 } @@ -363,7 +366,7 @@ async function balancesForAddress(req, res, next) { // Ensure the input is a valid BCH address. try { - const cash = utils.toCashAddress(address) + const cash = bchjs.SLP.Address.toCashAddress(address) } catch (err) { res.status(400) return res.json({ @@ -372,7 +375,7 @@ async function balancesForAddress(req, res, next) { } // Prevent a common user error. Ensure they are using the correct network address. - const cashAddr = utils.toCashAddress(address) + const cashAddr = bchjs.SLP.Address.toCashAddress(address) const networkIsValid = routeUtils.validateNetwork(cashAddr) if (!networkIsValid) { res.status(400) @@ -386,7 +389,7 @@ async function balancesForAddress(req, res, next) { q: { db: ["a"], find: { - address: SLP.Address.toSLPAddress(address), + address: bchjs.SLP.Address.toSLPAddress(address), token_balance: { $gte: 0 } }, limit: 10000 @@ -469,7 +472,7 @@ async function balancesForAddress(req, res, next) { res.status(500) return res.json({ - error: `Error in /ddress/:address: ${err.message}` + error: `Error in /address/:address: ${err.message}` }) } } diff --git a/test/v3/slp.js b/test/v3/slp.js index 3592ae9..6a2440c 100644 --- a/test/v3/slp.js +++ b/test/v3/slp.js @@ -429,7 +429,7 @@ describe("#SLP", () => { ]) }) }) - +*/ describe("balancesForAddress()", () => { const balancesForAddress = slpRoute.testableComponents.balancesForAddress @@ -513,7 +513,7 @@ describe("#SLP", () => { ]) }) }) - + /* describe("balancesForAddressBulk()", () => { const balancesForAddressBulk = slpRoute.testableComponents.balancesForAddressBulk