fix(sweep balanceOnly): Added balanceOnly to retrieve just the balance of a WIF

This commit is contained in:
Chris Troutner
2019-10-28 09:55:42 -07:00
parent 83d47bfda9
commit 01c3e61d19
2 changed files with 41 additions and 3 deletions
+28
View File
@@ -389,6 +389,34 @@ describe("#Util", () => {
assert.equal(result, "test-txid")
})
it("should return balance if balance-only is true", async () => {
// Mock the RPC call for unit tests.
if (process.env.TEST === "unit") {
sandbox
.stub(
utilRouteInst.blockbook.testableComponents,
"balanceFromBlockbook"
)
.resolves(mockData.mockBalance)
}
// Mock sendRawTransaction() so that the hex does not actually get broadcast
// to the network.
sandbox
.stub(utilRouteInst.bchjs.RawTransactions, "sendRawTransaction")
.resolves("test-txid")
req.body = {
wif: "L5GEFg1tETLWBugmhSo9Zc4ms968qVmfmTroDxsJ982AiudAQGyt",
balanceOnly: true
}
const result = await utilRouteInst.sweepWif(req, res)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.isNumber(result)
})
// Unit tests only
if (process.env.TEST === "unit") {
it("should generate transaction for valid BCH-only sweep", async () => {