mirror of
https://github.com/Permissionless-Software-Foundation/ipfs-bch-wallet-service.git
synced 2026-09-21 16:52:03 -07:00
98 lines
2.4 KiB
JavaScript
98 lines
2.4 KiB
JavaScript
/*
|
|
Integration tests for the endpoints in controllers/json-rpc/bch
|
|
*/
|
|
|
|
// Global npm libraries
|
|
const assert = require('chai').assert
|
|
|
|
// Local libraries
|
|
const BCHController = require('../../../../src/controllers/json-rpc/bch')
|
|
const Adapters = require('../../../../src/adapters')
|
|
const UseCases = require('../../../../src/use-cases')
|
|
|
|
describe('#BCH', () => {
|
|
let uut
|
|
|
|
before(async () => {
|
|
const adapters = new Adapters()
|
|
const useCases = new UseCases({ adapters })
|
|
// await adapters.start()
|
|
|
|
uut = new BCHController({ adapters, useCases })
|
|
})
|
|
|
|
describe('#utxoIsValid', () => {
|
|
it('should return true for valid UTXO with fullnode properties', async () => {
|
|
const rpcData = {
|
|
payload: {
|
|
params: {
|
|
utxo: {
|
|
txid: 'b94e1ff82eb5781f98296f0af2488ff06202f12ee92b0175963b8dba688d1b40',
|
|
vout: 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
const result = await uut.utxoIsValid(rpcData)
|
|
// console.log('result: ', result)
|
|
|
|
assert.equal(result.isValid, true)
|
|
})
|
|
|
|
it('should return true for valid UTXO with fulcrum properties', async () => {
|
|
const rpcData = {
|
|
payload: {
|
|
params: {
|
|
utxo: {
|
|
tx_hash: 'b94e1ff82eb5781f98296f0af2488ff06202f12ee92b0175963b8dba688d1b40',
|
|
tx_pos: 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
const result = await uut.utxoIsValid(rpcData)
|
|
// console.log('result: ', result)
|
|
|
|
assert.equal(result.isValid, true)
|
|
})
|
|
|
|
it('should return false for valid UTXO with fullnode properties', async () => {
|
|
const rpcData = {
|
|
payload: {
|
|
params: {
|
|
utxo: {
|
|
txid: '17754221b29f189532d4fc2ae89fb467ad2dede30fdec4854eb2129b3ba90d7a',
|
|
vout: 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
const result = await uut.utxoIsValid(rpcData)
|
|
// console.log('result: ', result)
|
|
|
|
assert.equal(result.isValid, false)
|
|
})
|
|
|
|
it('should return false for valid UTXO with fulcrum properties', async () => {
|
|
const rpcData = {
|
|
payload: {
|
|
params: {
|
|
utxo: {
|
|
tx_hash: '17754221b29f189532d4fc2ae89fb467ad2dede30fdec4854eb2129b3ba90d7a',
|
|
tx_pos: 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
const result = await uut.utxoIsValid(rpcData)
|
|
// console.log('result: ', result
|
|
|
|
assert.equal(result.isValid, false)
|
|
})
|
|
})
|
|
})
|