Files
xahau.js/packages/ripple-binary-codec/test/quality.test.ts
Caleb Kniffen 38b385969b feat: remove Buffer support and bundle polyfill (#2526)
- Removes need for bundlers to polyfill the `Buffer` class. `UInt8Array` are used instead which are native to the browser and node.
- Reduces bundle size 7.1kb gzipped and eliminates 4 runtime dependencies: `base-x`, `base64-js`, `buffer`, and `ieee754`.

BREAKING CHANGE: All methods that previously took a `Buffer` now accept a `UInt8Array`.

---------

Co-authored-by: Jackson Mills <jmills@ripple.com>
2024-02-01 13:53:41 -06:00

17 lines
589 B
TypeScript

const { quality } = require('../src/coretypes')
const { bytesToHex } = require('@xrplf/isomorphic/utils')
describe('Quality encode/decode', function () {
const bookDirectory =
'4627DFFCFF8B5A265EDBD8AE8C14A52325DBFEDAF4F5C32E5D06F4C3362FE1D0'
const expectedQuality = '195796912.5171664'
it('can decode', function () {
const decimal = quality.decode(bookDirectory)
expect(decimal.toString()).toBe(expectedQuality)
})
it('can encode', function () {
const bytes = quality.encode(expectedQuality)
expect(bytesToHex(bytes)).toBe(bookDirectory.slice(-16))
})
})