mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 19:55:51 +00:00
Switch to using `@noble/hashes`, `@noble/curves`, `@scure/base`, `@scure/bip32`, and `@scure/bip39`. This replaces `crypto` polyfills (such as `crypto-browserify`), `create-hash`, `elliptic`, `hash.js`, `bn.js` (both versions), and their many dependencies. This also means there are 33 less dependencies downloaded when running a fresh `npm install` and will make the project much easier to maintain. This reduces the bundle size by 44% (82kb minified and gzipped) over the current 3.0 branch as well as reducing the amount of configuration required to bundle. Closes #1814, #1817, #2272, and #2306 Co-authored-by: Caleb Kniffen <ckniffen@ripple.com>
32 lines
853 B
TypeScript
32 lines
853 B
TypeScript
import { bytesToHex, hexToBytes, randomBytes } from '../utils'
|
|
|
|
describe('utils', function () {
|
|
it('randomBytes', () => {
|
|
expect(randomBytes(16).byteLength).toEqual(16)
|
|
})
|
|
|
|
it('hexToBytes - empty', () => {
|
|
expect(hexToBytes('')).toEqual(new Uint8Array([]))
|
|
})
|
|
|
|
it('hexToBytes - zero', () => {
|
|
expect(hexToBytes('000000')).toEqual(new Uint8Array([0, 0, 0]))
|
|
})
|
|
|
|
it('hexToBytes - DEADBEEF', () => {
|
|
expect(hexToBytes('DEADBEEF')).toEqual(new Uint8Array([222, 173, 190, 239]))
|
|
})
|
|
|
|
it('bytesToHex - DEADBEEF', () => {
|
|
expect(bytesToHex([222, 173, 190, 239])).toEqual('DEADBEEF')
|
|
})
|
|
|
|
it('bytesToHex - 010203', () => {
|
|
expect(bytesToHex([1, 2, 3])).toEqual('010203')
|
|
})
|
|
|
|
it('bytesToHex - DEADBEEF (Uint8Array)', () => {
|
|
expect(bytesToHex(new Uint8Array([222, 173, 190, 239]))).toEqual('DEADBEEF')
|
|
})
|
|
})
|