mirror of
https://github.com/Permissionless-Software-Foundation/bch-js.git
synced 2026-09-22 17:12:01 -07:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac6b45b162 | ||
|
|
66a99c0560 | ||
|
|
17e4a32ff4 |
+7
-2
@@ -434,7 +434,7 @@ class Utils {
|
|||||||
async validateTxid(txid) {
|
async validateTxid(txid) {
|
||||||
const path = `${this.restURL}slp/validateTxid`
|
const path = `${this.restURL}slp/validateTxid`
|
||||||
|
|
||||||
// console.log(`txid: ${JSON.stringify(txid, null, 2)}`)
|
console.log(`txid: ${JSON.stringify(txid, null, 2)}`)
|
||||||
|
|
||||||
// Handle a single TXID or an array of TXIDs.
|
// Handle a single TXID or an array of TXIDs.
|
||||||
let txids
|
let txids
|
||||||
@@ -449,7 +449,9 @@ class Utils {
|
|||||||
},
|
},
|
||||||
_this.axiosOptions
|
_this.axiosOptions
|
||||||
)
|
)
|
||||||
// console.log(`response.data: ${JSON.stringify(response.data, null, 2)}`)
|
console.log(
|
||||||
|
`validateTxid response.data: ${JSON.stringify(response.data, null, 2)}`
|
||||||
|
)
|
||||||
|
|
||||||
const validatedTxids = response.data
|
const validatedTxids = response.data
|
||||||
|
|
||||||
@@ -1291,6 +1293,9 @@ class Utils {
|
|||||||
// If the value has been cached, use the cached version first.
|
// If the value has been cached, use the cached version first.
|
||||||
let isValid = cachedTxValidation[utxo.txid]
|
let isValid = cachedTxValidation[utxo.txid]
|
||||||
|
|
||||||
|
// There are two possible responses from SLPDB. If SLPDB is functioning
|
||||||
|
// correctly...
|
||||||
|
|
||||||
// If not in the cache, try the general SLPDB.
|
// If not in the cache, try the general SLPDB.
|
||||||
if (isValid == null) {
|
if (isValid == null) {
|
||||||
console.log(`utxo: ${JSON.stringify(utxo, null, 2)}`)
|
console.log(`utxo: ${JSON.stringify(utxo, null, 2)}`)
|
||||||
|
|||||||
+69
-26
@@ -464,20 +464,20 @@ describe(`#SLP`, () => {
|
|||||||
assert.equal(data[0].isValid, false)
|
assert.equal(data[0].isValid, false)
|
||||||
})
|
})
|
||||||
|
|
||||||
// it("should handle null SLPDB validations", async () => {
|
it("should handle null SLPDB validations", async () => {
|
||||||
// const utxos = [
|
const utxos = [
|
||||||
// {
|
{
|
||||||
// height: 665577,
|
height: 665577,
|
||||||
// tx_hash:
|
tx_hash:
|
||||||
// "4b89405c54d1c0bde8aa476a47561a42a6e7a5e927daa2ec69d428810eae3419",
|
"4b89405c54d1c0bde8aa476a47561a42a6e7a5e927daa2ec69d428810eae3419",
|
||||||
// tx_pos: 1,
|
tx_pos: 1,
|
||||||
// value: 546
|
value: 546
|
||||||
// }
|
}
|
||||||
// ]
|
]
|
||||||
//
|
|
||||||
// const data = await bchjs.SLP.Utils.tokenUtxoDetails(utxos)
|
const data = await bchjs.SLP.Utils.tokenUtxoDetails(utxos)
|
||||||
// console.log(`data: ${JSON.stringify(data, null, 2)}`)
|
console.log(`data: ${JSON.stringify(data, null, 2)}`)
|
||||||
// })
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("#balancesForAddress", () => {
|
describe("#balancesForAddress", () => {
|
||||||
@@ -619,19 +619,62 @@ describe(`#SLP`, () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// it("should handle null SLPDB validations", async () => {
|
it("should handle null SLPDB validations", async () => {
|
||||||
// const utxos = [
|
const utxos = [
|
||||||
// {
|
{
|
||||||
// height: 665577,
|
height: 665577,
|
||||||
// tx_hash:
|
tx_hash:
|
||||||
// "4b89405c54d1c0bde8aa476a47561a42a6e7a5e927daa2ec69d428810eae3419",
|
"4b89405c54d1c0bde8aa476a47561a42a6e7a5e927daa2ec69d428810eae3419",
|
||||||
// tx_pos: 1,
|
tx_pos: 1,
|
||||||
// value: 546
|
value: 546
|
||||||
// }
|
}
|
||||||
// ]
|
]
|
||||||
|
|
||||||
|
const data = await bchjs.SLP.Utils.hydrateUtxos([{ utxos: utxos }])
|
||||||
|
console.log(`data: ${JSON.stringify(data, null, 2)}`)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("#validateTxid", () => {
|
||||||
|
it("should return null on a known invalid TXID", async () => {
|
||||||
|
const txid =
|
||||||
|
"f7e5199ef6669ad4d078093b3ad56e355b6ab84567e59ad0f08a5ad0244f783a"
|
||||||
|
|
||||||
|
const result = await bchjs.SLP.Utils.validateTxid(txid)
|
||||||
|
console.log(`result: ${JSON.stringify(result, null, 2)}`)
|
||||||
|
|
||||||
|
assert.isArray(result)
|
||||||
|
|
||||||
|
assert.property(result[0], "txid")
|
||||||
|
assert.equal(result[0].txid, txid)
|
||||||
|
|
||||||
|
assert.property(result[0], "valid")
|
||||||
|
assert.equal(result[0].valid, null)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should return true a known valid TXID", async () => {
|
||||||
|
const txid =
|
||||||
|
"3a4b628cbcc183ab376d44ce5252325f042268307ffa4a53443e92b6d24fb488"
|
||||||
|
|
||||||
|
const result = await bchjs.SLP.Utils.validateTxid(txid)
|
||||||
|
console.log(`result: ${JSON.stringify(result, null, 2)}`)
|
||||||
|
|
||||||
|
assert.isArray(result)
|
||||||
|
|
||||||
|
assert.property(result[0], "txid")
|
||||||
|
assert.equal(result[0].txid, txid)
|
||||||
|
|
||||||
|
assert.property(result[0], "valid")
|
||||||
|
assert.equal(result[0].valid, true)
|
||||||
|
})
|
||||||
|
|
||||||
|
// This test is not necessary.
|
||||||
|
// it("should handle a null response from SLPDB", async () => {
|
||||||
|
// const txid =
|
||||||
|
// "4b89405c54d1c0bde8aa476a47561a42a6e7a5e927daa2ec69d428810eae3419"
|
||||||
//
|
//
|
||||||
// const data = await bchjs.SLP.Utils.hydrateUtxos([{ utxos: utxos }])
|
// const result = await bchjs.SLP.Utils.validateTxid(txid)
|
||||||
// console.log(`data: ${JSON.stringify(data, null, 2)}`)
|
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
|
||||||
// })
|
// })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user