fix(integration): Fixing integration tests

This commit is contained in:
Chris Troutner
2020-06-05 18:20:14 -07:00
parent 48b5afaef5
commit c81cb72001
2 changed files with 1 additions and 414 deletions
-408
View File
@@ -227,414 +227,6 @@ describe(`#SLP`, () => {
})
})
describe("#isTokenUtxo", () => {
it("should accurately analyze UTXOs from Blockbook", async () => {
const addr = "bitcoincash:qqkpnx2rff4q5jranf3wk9jsprhae9unxckq07gph4"
const utxos = await bchjs.Blockbook.utxo(addr)
// console.log(`utxos: ${JSON.stringify(utxos, null, 2)}`)
const isTokenUtxos = await bchjs.SLP.Utils.isTokenUtxo(utxos)
// console.log(`isTokenUtxos: ${JSON.stringify(isTokenUtxos, null, 2)}`)
// Filter out the result that is associated with the known non-slp tx.
const nonSlp = isTokenUtxos.filter(
x =>
x.txid ===
"2069e99a90499693e42cd1db82147e3e0acfe5e7315c6cc2f0252432f45300d7"
)
const isSlp = isTokenUtxos.filter(
x =>
x.txid ===
"99093e8a19e0a649bf943dbc33d926feb09c02e61258c1bdaf2caffa7183c730"
)
assert.isArray(isTokenUtxos)
assert.equal(nonSlp[0].isSlp, false)
assert.equal(isSlp[0].isSlp, true)
})
it("should accurately analyze UTXOs from Electrumx", async () => {
try {
const addr = "bitcoincash:qqkpnx2rff4q5jranf3wk9jsprhae9unxckq07gph4"
const utxos = await bchjs.Electrumx.utxo(addr)
// console.log(`utxos: ${JSON.stringify(utxos, null, 2)}`)
const isTokenUtxos = await bchjs.SLP.Utils.isTokenUtxo(utxos.utxos)
// console.log(`isTokenUtxos: ${JSON.stringify(isTokenUtxos, null, 2)}`)
// Filter out the result that is associated with the known non-slp tx.
const nonSlp = isTokenUtxos.filter(
x =>
x.tx_hash ===
"2069e99a90499693e42cd1db82147e3e0acfe5e7315c6cc2f0252432f45300d7"
)
const isSlp = isTokenUtxos.filter(
x =>
x.tx_hash ===
"99093e8a19e0a649bf943dbc33d926feb09c02e61258c1bdaf2caffa7183c730"
)
assert.isArray(isTokenUtxos)
assert.equal(nonSlp[0].isSlp, false)
assert.equal(isSlp[0].isSlp, true)
} catch (err) {
console.log(`Error: `, err)
}
})
// This captures an important corner-case. When an SLP token is created, the
// change UTXO will contain the same SLP txid, but it is not an SLP UTXO.
it("should return false for change in an SLP token creation transaction", async () => {
const utxos = [
{
txid:
"bd158c564dd4ef54305b14f44f8e94c44b649f246dab14bcb42fb0d0078b8a90",
vout: 3,
amount: 0.00002015,
satoshis: 2015,
height: 594892,
confirmations: 5
},
{
txid:
"bd158c564dd4ef54305b14f44f8e94c44b649f246dab14bcb42fb0d0078b8a90",
vout: 2,
amount: 0.00000546,
satoshis: 546,
height: 594892,
confirmations: 5
}
]
const data = await bchjs.SLP.Utils.isTokenUtxo(utxos)
// console.log(`data: ${JSON.stringify(data, null, 2)}`)
assert.equal(
data[0].isSlp,
false,
"Change should not be identified as SLP utxo."
)
assert.equal(data[1].isSlp, true, "SLP UTXO correctly identified.")
})
})
// describe("#tokenUtxoDetails", () => {
// it("should return token details on a valid UTXO", async () => {
// const utxos = [
// {
// txid:
// "266844d53e46bbd7dd37134688dffea6e54d944edff27a0add63dd0908839bc1",
// vout: 1,
// value: "546",
// height: 597740,
// confirmations: 1,
// satoshis: 546
// }
// ]
//
// const result = await bchjs.SLP.Utils.tokenUtxoDetails(utxos)
// // console.log(`result: ${JSON.stringify(result, null, 2)}`)
//
// assert.hasAllKeys(result[0], [
// "txid",
// "vout",
// "value",
// "height",
// "confirmations",
// "satoshis",
// "utxoType",
// "transactionType",
// "tokenId",
// "tokenTicker",
// "tokenName",
// "tokenDocumentUrl",
// "tokenDocumentHash",
// "decimals",
// "tokenQty",
// "isValid"
// ])
// })
//
// it("should not choke on this problematic utxo", async () => {
// const utxos = [
// {
// txid:
// "a8eb788b8ddda6faea00e6e2756624b8feb97655363d0400dd66839ea619d36e",
// vout: 1,
// value: "546",
// height: 603282,
// confirmations: 156,
// satoshis: 546
// }
// ]
//
// const result = await bchjs.SLP.Utils.tokenUtxoDetails(utxos)
// // console.log(`result: ${JSON.stringify(result, null, 2)}`)
//
// assert.hasAllKeys(result[0], [
// "txid",
// "vout",
// "value",
// "height",
// "confirmations",
// "satoshis",
// "utxoType",
// "transactionType",
// "tokenId",
// "tokenTicker",
// "tokenName",
// "tokenDocumentUrl",
// "tokenDocumentHash",
// "decimals",
// "tokenQty",
// "isValid"
// ])
// })
//
// it("should handle BCH and SLP utxos in the same TX", async () => {
// const utxos = [
// {
// txid:
// "d56a2b446d8149c39ca7e06163fe8097168c3604915f631bc58777d669135a56",
// vout: 3,
// value: "6816",
// height: 606848,
// confirmations: 13,
// satoshis: 6816
// },
// {
// txid:
// "d56a2b446d8149c39ca7e06163fe8097168c3604915f631bc58777d669135a56",
// vout: 2,
// value: "546",
// height: 606848,
// confirmations: 13,
// satoshis: 546
// }
// ]
//
// const result = await bchjs.SLP.Utils.tokenUtxoDetails(utxos)
// // console.log(`result: ${JSON.stringify(result, null, 2)}`)
//
// assert.isArray(result)
// assert.equal(result.length, 2)
// assert.equal(result[0], false)
// })
//
// // This captures an important corner-case. When an SLP token is created, the
// // change UTXO will contain the same SLP txid, but it is not an SLP UTXO.
// it("should return details on minting baton from genesis transaction", async () => {
// const utxos = [
// {
// txid:
// "bd158c564dd4ef54305b14f44f8e94c44b649f246dab14bcb42fb0d0078b8a90",
// vout: 3,
// amount: 0.00002015,
// satoshis: 2015,
// height: 594892,
// confirmations: 5
// },
// {
// txid:
// "bd158c564dd4ef54305b14f44f8e94c44b649f246dab14bcb42fb0d0078b8a90",
// vout: 2,
// amount: 0.00000546,
// satoshis: 546,
// height: 594892,
// confirmations: 5
// }
// ]
//
// const data = await bchjs.SLP.Utils.tokenUtxoDetails(utxos)
// // console.log(`data: ${JSON.stringify(data, null, 2)}`)
//
// assert.equal(data[0], false, "Change UTXO marked as false.")
//
// assert.property(data[1], "txid")
// assert.property(data[1], "vout")
// assert.property(data[1], "amount")
// assert.property(data[1], "satoshis")
// assert.property(data[1], "height")
// assert.property(data[1], "confirmations")
// assert.property(data[1], "tokenType")
// assert.property(data[1], "tokenId")
// assert.property(data[1], "tokenTicker")
// assert.property(data[1], "tokenName")
// assert.property(data[1], "tokenDocumentUrl")
// assert.property(data[1], "tokenDocumentHash")
// assert.property(data[1], "decimals")
// assert.property(data[1], "isValid")
// assert.equal(data[1].isValid, true)
// })
//
// it("should return details for a MINT token utxo", async () => {
// const utxos = [
// {
// txid:
// "cf4b922d1e1aa56b52d752d4206e1448ea76c3ebe69b3b97d8f8f65413bd5c76",
// vout: 1,
// amount: 0.00000546,
// satoshis: 546,
// height: 600297,
// confirmations: 76
// }
// ]
//
// const data = await bchjs.SLP.Utils.tokenUtxoDetails(utxos)
// // console.log(`data: ${JSON.stringify(data, null, 2)}`)
//
// assert.property(data[0], "txid")
// assert.property(data[0], "vout")
// assert.property(data[0], "amount")
// assert.property(data[0], "satoshis")
// assert.property(data[0], "height")
// assert.property(data[0], "confirmations")
// assert.property(data[0], "utxoType")
// assert.property(data[0], "transactionType")
// assert.property(data[0], "tokenId")
// assert.property(data[0], "tokenTicker")
// assert.property(data[0], "tokenName")
// assert.property(data[0], "tokenDocumentUrl")
// assert.property(data[0], "tokenDocumentHash")
// assert.property(data[0], "decimals")
// assert.property(data[0], "mintBatonVout")
// assert.property(data[0], "batonStillExists")
// assert.property(data[0], "tokenQty")
// assert.property(data[0], "isValid")
// assert.equal(data[0].isValid, true)
// })
//
// it("should return details for a simple SEND SLP token utxo", async () => {
// const utxos = [
// {
// txid:
// "fde117b1f176b231e2fa9a6cb022e0f7c31c288221df6bcb05f8b7d040ca87cb",
// vout: 1,
// amount: 0.00000546,
// satoshis: 546,
// height: 596089,
// confirmations: 748
// }
// ]
//
// const data = await bchjs.SLP.Utils.tokenUtxoDetails(utxos)
// // console.log(`data: ${JSON.stringify(data, null, 2)}`)
//
// assert.property(data[0], "txid")
// assert.property(data[0], "vout")
// assert.property(data[0], "amount")
// assert.property(data[0], "satoshis")
// assert.property(data[0], "height")
// assert.property(data[0], "confirmations")
// assert.property(data[0], "utxoType")
// assert.property(data[0], "tokenId")
// assert.property(data[0], "tokenTicker")
// assert.property(data[0], "tokenName")
// assert.property(data[0], "tokenDocumentUrl")
// assert.property(data[0], "tokenDocumentHash")
// assert.property(data[0], "decimals")
// assert.property(data[0], "tokenQty")
// assert.property(data[0], "isValid")
// assert.equal(data[0].isValid, true)
// })
//
// it("should handle BCH and SLP utxos in the same TX", async () => {
// const utxos = [
// {
// txid:
// "d56a2b446d8149c39ca7e06163fe8097168c3604915f631bc58777d669135a56",
// vout: 3,
// value: "6816",
// height: 606848,
// confirmations: 13,
// satoshis: 6816
// },
// {
// txid:
// "d56a2b446d8149c39ca7e06163fe8097168c3604915f631bc58777d669135a56",
// vout: 2,
// value: "546",
// height: 606848,
// confirmations: 13,
// satoshis: 546
// }
// ]
//
// const result = await bchjs.SLP.Utils.tokenUtxoDetails(utxos)
// // console.log(`result: ${JSON.stringify(result, null, 2)}`)
//
// assert.isArray(result)
// assert.equal(result.length, 2)
// assert.equal(result[0], false)
// assert.equal(result[1].isValid, true)
// })
//
// it("should handle problematic utxos", async () => {
// const utxos = [
// {
// txid:
// "0e3a217fc22612002031d317b4cecd9b692b66b52951a67b23c43041aefa3959",
// vout: 0,
// amount: 0.00018362,
// satoshis: 18362,
// height: 613483,
// confirmations: 124
// },
// {
// txid:
// "67fd3c7c3a6eb0fea9ab311b91039545086220f7eeeefa367fa28e6e43009f19",
// vout: 1,
// amount: 0.00000546,
// satoshis: 546,
// height: 612075,
// confirmations: 1532
// }
// ]
//
// const result = await bchjs.SLP.Utils.tokenUtxoDetails(utxos)
// // console.log(`result: ${JSON.stringify(result, null, 2)}`)
//
// assert.isArray(result)
// assert.equal(result.length, 2)
// assert.equal(result[0], false)
// assert.equal(result[1].isValid, true)
// })
//
// it("should return false for BCH-only UTXOs", async () => {
// const utxos = [
// {
// txid:
// "a937f792c7c9eb23b4f344ce5c233d1ac0909217d0a504d71e6b1e4efb864a3b",
// vout: 0,
// amount: 0.00001,
// satoshis: 1000,
// confirmations: 0,
// ts: 1578424704
// },
// {
// txid:
// "53fd141c2e999e080a5860887441a2c45e9cbe262027e2bd2ac998fc76e43c44",
// vout: 0,
// amount: 0.00001,
// satoshis: 1000,
// confirmations: 0,
// ts: 1578424634
// }
// ]
//
// const data = await bchjs.SLP.Utils.tokenUtxoDetails(utxos)
// // console.log(`data: ${JSON.stringify(data, null, 2)}`)
//
// assert.isArray(data)
// assert.equal(false, data[0])
// assert.equal(false, data[1])
// })
// })
describe("#tokenUtxoDetails", () => {
// // This captures an important corner-case. When an SLP token is created, the
// // change UTXO will contain the same SLP txid, but it is not an SLP UTXO.
+1 -6
View File
@@ -68,12 +68,7 @@ describe(`#SLP`, () => {
const result = await bchjs.SLP.Utils.decodeOpReturn(txid)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.hasAllKeys(result, [
"tokenType",
"transactionType",
"tokenId",
"spendData"
])
assert.hasAllKeys(result, ["amounts", "tokenType", "tokenId", "txType"])
})
})