Files
xahau.js/packages/ripple-keypairs/test/utils-test.js
Pi Delport 0b9c27ff5f fix(ripple-keypairs): hexToBytes should produce [] for empty input, not [0] (#1977)
BN.toArray intentionally returns [0] rather than [] for length zero,
which may make sense for BigNum data, but not for byte strings.
2022-04-28 14:15:07 -07:00

27 lines
715 B
JavaScript

'use strict' // eslint-disable-line strict
const assert = require('assert')
const utils = require('../dist/utils')
describe('utils', () => {
it('hexToBytes - empty', () => {
assert.deepEqual(utils.hexToBytes(''), [])
})
it('hexToBytes - zero', () => {
assert.deepEqual(utils.hexToBytes('000000'), [0, 0, 0])
})
it('hexToBytes - DEADBEEF', () => {
assert.deepEqual(utils.hexToBytes('DEADBEEF'), [222, 173, 190, 239])
})
it('bytesToHex - DEADBEEF', () => {
assert.deepEqual(utils.bytesToHex([222, 173, 190, 239]), 'DEADBEEF')
});
it('bytesToHex - DEADBEEF (Uint8Array)', () => {
assert.deepEqual(utils.bytesToHex(new Uint8Array([222, 173, 190, 239])), 'DEADBEEF')
});
})