2021-01-02 15:41:12 -08:00
|
|
|
const assert = require('assert')
|
|
|
|
|
const axios = require('axios')
|
|
|
|
|
const BCHJS = require('../../src/bch-js')
|
2020-07-27 21:32:51 -07:00
|
|
|
const bchjs = new BCHJS()
|
2021-01-02 15:41:12 -08:00
|
|
|
const sinon = require('sinon')
|
2020-07-27 21:32:51 -07:00
|
|
|
|
2021-01-02 15:41:12 -08:00
|
|
|
describe('#Util', () => {
|
|
|
|
|
describe('#validateAddress', () => {
|
2020-07-27 21:32:51 -07:00
|
|
|
let sandbox
|
|
|
|
|
beforeEach(() => (sandbox = sinon.createSandbox()))
|
|
|
|
|
afterEach(() => sandbox.restore())
|
|
|
|
|
|
2021-01-02 15:41:12 -08:00
|
|
|
it('should validate address', done => {
|
2020-07-27 21:32:51 -07:00
|
|
|
const data = {
|
|
|
|
|
isvalid: true,
|
2021-01-02 15:41:12 -08:00
|
|
|
address: 'bitcoincash:qpz7qtkuyhrsz4qmnnrvf8gz9zd0u9v7eqsewyk4w5',
|
|
|
|
|
scriptPubKey: '76a91445e02edc25c701541b9cc6c49d02289afe159ec888ac',
|
2020-07-27 21:32:51 -07:00
|
|
|
ismine: false,
|
|
|
|
|
iswatchonly: false,
|
|
|
|
|
isscript: false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const resolved = new Promise(r => r({ data: data }))
|
2021-01-02 15:41:12 -08:00
|
|
|
sandbox.stub(axios, 'get').returns(resolved)
|
2020-07-27 21:32:51 -07:00
|
|
|
|
|
|
|
|
bchjs.Util.validateAddress(
|
2021-01-02 15:41:12 -08:00
|
|
|
'bitcoincash:qpz7qtkuyhrsz4qmnnrvf8gz9zd0u9v7eqsewyk4w5'
|
2020-07-27 21:32:51 -07:00
|
|
|
)
|
|
|
|
|
.then(result => {
|
|
|
|
|
assert.deepEqual(data, result)
|
|
|
|
|
})
|
|
|
|
|
.then(done, done)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|