mirror of
https://github.com/Permissionless-Software-Foundation/bch-js.git
synced 2026-09-21 16:51:59 -07:00
add testnet integration tests
This commit is contained in:
@@ -3,7 +3,9 @@ const assert = chai.assert
|
||||
const sinon = require("sinon")
|
||||
|
||||
const BCHJS = require("../../../src/bch-js")
|
||||
const bchjs = new BCHJS({ ninsightURL: "https://trest.bitcoin.com/v2" })
|
||||
const bchjs = new BCHJS({
|
||||
ninsightURL: "https://trest.bitcoin.com/v2"
|
||||
})
|
||||
|
||||
describe(`#Ninsight`, () => {
|
||||
let sandbox
|
||||
@@ -139,6 +141,91 @@ describe(`#Ninsight`, () => {
|
||||
assert.property(result[0], "vout")
|
||||
})
|
||||
})
|
||||
|
||||
describe(`#detailsAddress`, () => {
|
||||
it(`should throw an error for improper input`, async () => {
|
||||
try {
|
||||
const addr = 12345
|
||||
|
||||
await bchjs.Ninsight.details(addr)
|
||||
assert.equal(true, false, "Unexpected result!")
|
||||
} catch (err) {
|
||||
//console.log(`err: `, err)
|
||||
assert.include(
|
||||
err.message,
|
||||
`Input address must be a string or array of strings.`
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
it(`should GET details for a single address`, async () => {
|
||||
const addr = "bchtest:qzjtnzcvzxx7s0na88yrg3zl28wwvfp97538sgrrmr"
|
||||
|
||||
const result = await bchjs.Ninsight.details(addr)
|
||||
//console.log(`result: ${JSON.stringify(result, null, 2)}`)
|
||||
assert.property(result[0], "balance")
|
||||
assert.property(result[0], "balanceSat")
|
||||
assert.property(result[0], "totalReceived")
|
||||
assert.property(result[0], "totalReceivedSat")
|
||||
assert.property(result[0], "totalSent")
|
||||
assert.property(result[0], "totalSentSat")
|
||||
assert.property(result[0], "unconfirmedBalance")
|
||||
assert.property(result[0], "unconfirmedBalanceSat")
|
||||
assert.property(result[0], "unconfirmedTxApperances")
|
||||
assert.property(result[0], "txApperances")
|
||||
assert.property(result[0], "transactions")
|
||||
assert.property(result[0], "legacyAddress")
|
||||
assert.property(result[0], "cashAddress")
|
||||
assert.property(result[0], "slpAddress")
|
||||
assert.property(result[0], "currentPage")
|
||||
assert.property(result[0], "pagesTotal")
|
||||
})
|
||||
|
||||
it(`should GET details for an array of addresses`, async () => {
|
||||
const addr = [
|
||||
"bchtest:qzjtnzcvzxx7s0na88yrg3zl28wwvfp97538sgrrmr",
|
||||
"bchtest:qp6hgvevf4gzz6l7pgcte3gaaud9km0l459fa23dul"
|
||||
]
|
||||
|
||||
const result = await bchjs.Ninsight.details(addr)
|
||||
//console.log(`result: ${JSON.stringify(result, null, 2)}`)
|
||||
|
||||
assert.isArray(result)
|
||||
assert.property(result[0], "balance")
|
||||
assert.property(result[0], "balanceSat")
|
||||
assert.property(result[0], "totalReceived")
|
||||
assert.property(result[0], "totalReceivedSat")
|
||||
assert.property(result[0], "totalSent")
|
||||
assert.property(result[0], "totalSentSat")
|
||||
assert.property(result[0], "unconfirmedBalance")
|
||||
assert.property(result[0], "unconfirmedBalanceSat")
|
||||
assert.property(result[0], "unconfirmedTxApperances")
|
||||
assert.property(result[0], "txApperances")
|
||||
assert.property(result[0], "transactions")
|
||||
assert.property(result[0], "legacyAddress")
|
||||
assert.property(result[1], "cashAddress")
|
||||
assert.property(result[1], "slpAddress")
|
||||
assert.property(result[1], "currentPage")
|
||||
assert.property(result[1], "pagesTotal")
|
||||
|
||||
/*
|
||||
If in any way possible, I would like to refactor this test
|
||||
according to the DRY principle to share it with the integration tests too
|
||||
Would that make sense or does that implicate anything unwanted?
|
||||
|
||||
assertDetails(result[0])
|
||||
|
||||
assertDetails(data) {
|
||||
assert.property(data, "balance")
|
||||
assert.property(data, "balanceSat")
|
||||
assert.property(data, "totalReceived")
|
||||
assert.property(data, "totalReceivedSat")
|
||||
assert.property(data, "totalSent")
|
||||
assert.property(data, "totalSentSat")
|
||||
}
|
||||
*/
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
function sleep(ms) {
|
||||
|
||||
Reference in New Issue
Block a user