fix(SLP balancesForAddress): Fixed unit tests

This commit is contained in:
Chris Troutner
2019-12-02 19:25:10 -08:00
parent b6b8d54cda
commit c53b6e0940
2 changed files with 9 additions and 6 deletions
+7 -4
View File
@@ -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}`
})
}
}
+2 -2
View File
@@ -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