Files
bch-js/test/integration/encryption.js
T

40 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-01-02 15:41:12 -08:00
const assert = require('chai').assert
2020-07-27 21:32:51 -07:00
2021-01-02 15:41:12 -08:00
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
describe('#Encryption', () => {
beforeEach(async () => {
if (process.env.IS_USING_FREE_TIER) await sleep(1500)
})
2021-01-02 15:41:12 -08:00
describe('#getPubKey', () => {
it('should get a public key', async () => {
const addr = 'bitcoincash:qpf8jv9hmqcda0502gjp7nm3g24y5h5s4unutghsxq'
2020-07-27 21:32:51 -07:00
const result = await bchjs.encryption.getPubKey(addr)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
2021-01-02 15:41:12 -08:00
assert.property(result, 'success')
2020-07-27 21:32:51 -07:00
assert.equal(result.success, true)
2021-01-02 15:41:12 -08:00
assert.property(result, 'publicKey')
2020-07-27 21:32:51 -07:00
})
2021-01-02 15:41:12 -08:00
it('should report when public key can not be found', async () => {
const addr = 'bitcoincash:qrgqqkky28jdkv3w0ctrah0mz3jcsnsklc34gtukrh'
2020-07-27 21:32:51 -07:00
const result = await bchjs.encryption.getPubKey(addr)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
2021-01-02 15:41:12 -08:00
assert.property(result, 'success')
2020-07-27 21:32:51 -07:00
assert.equal(result.success, false)
2021-01-02 15:41:12 -08:00
assert.property(result, 'publicKey')
assert.equal(result.publicKey, 'not found')
2020-07-27 21:32:51 -07:00
})
})
})
2021-01-02 15:41:12 -08:00
function sleep (ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}