mirror of
https://github.com/fullstack-cash/bch-api.git
synced 2026-09-22 17:22:04 -07:00
feat(GET MempoolAncestors): Added wrapper for full node RPC call
This commit is contained in:
@@ -786,6 +786,56 @@ describe("#BlockchainRouter", () => {
|
||||
}
|
||||
})
|
||||
|
||||
describe("getMempoolAncestorsSingle()", () => {
|
||||
// block route handler.
|
||||
const getMempoolAncestorsSingle =
|
||||
blockchainRoute.testableComponents.getMempoolAncestorsSingle
|
||||
|
||||
it("should throw 400 if txid is empty", async () => {
|
||||
const result = await getMempoolAncestorsSingle(req, res)
|
||||
//console.log(`result: ${util.inspect(result)}`)
|
||||
|
||||
assert.hasAllKeys(result, ["error"])
|
||||
assert.include(result.error, "txid can not be empty")
|
||||
})
|
||||
|
||||
it("should throw 503 when network issues", async () => {
|
||||
// Save the existing RPC URL.
|
||||
const savedUrl2 = process.env.RPC_BASEURL
|
||||
|
||||
// Manipulate the URL to cause a 500 network error.
|
||||
process.env.RPC_BASEURL = "http://fakeurl/api/"
|
||||
|
||||
req.params.txid = `d65881582ff2bff36747d7a0d0e273f10281abc8bd5c15df5d72f8f3fa779cde`
|
||||
|
||||
const result = await getMempoolAncestorsSingle(req, res)
|
||||
//console.log(`result: ${util.inspect(result)}`)
|
||||
|
||||
// Restore the saved URL.
|
||||
process.env.RPC_BASEURL = savedUrl2
|
||||
|
||||
assert.isAbove(res.statusCode, 499, "HTTP status code 503 expected.")
|
||||
assert.include(
|
||||
result.error,
|
||||
"Could not communicate with full node",
|
||||
"Error message expected"
|
||||
)
|
||||
})
|
||||
|
||||
it("should GET /getMempoolAncestorsSingle", async () => {
|
||||
nock(`${process.env.RPC_BASEURL}`)
|
||||
.post(uri => uri.includes("/"))
|
||||
.reply(200, { result: mockData.mockAncestors })
|
||||
|
||||
req.params.txid = `bb0d349892d351da2767f8c45f6f7949713ff09bd12838d53e76158ddee3ce93`
|
||||
|
||||
const result = await getMempoolAncestorsSingle(req, res)
|
||||
// console.log(`result: ${util.inspect(result)}`)
|
||||
|
||||
assert.isArray(result)
|
||||
})
|
||||
})
|
||||
|
||||
describe("getTxOut()", () => {
|
||||
// block route handler.
|
||||
const getTxOut = blockchainRoute.testableComponents.getTxOut
|
||||
|
||||
Reference in New Issue
Block a user