f5976a2d74
* feat: moved tl-runtime to esm and native ArrayBuffers * feat: migration to esm * fix(core): web-related fixes * test: finally, some good fucking e2e * chore: fixed linters etc * ci: added e2e to ci * build(tl): fixed gen-code on node 20 * fix: codegen Uint8Array, not Buffer never `git reset --hard` kids * build: only do type-aware linting for `packages/*` * build: ignore no-unresolved in ci for e2e * fix: node 16 doesn't have subtle crypto apparently? * fix(tests): use Uint8Array for gods sake please can i just merge this already * ci: don't parallel tasks in ci because machines are utter garbage and it may just randomly break * ci: pass secrets to e2e tests * ci: separate cli command for ci apparently im retarded * fix: run codegen in e2e im actually retarded * ci: more fixes for e2e * ci: debugging stuff * ci: still debugging * ci: hopefully fix ci???
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import { expect } from 'chai'
|
|
import { describe, it } from 'mocha'
|
|
|
|
import { hexDecode, hexDecodeToBuffer, hexEncode } from '../../src/encodings/hex.js'
|
|
import { hexDecode as hexDecodeWeb, hexDecodeToBuffer as hexDecodeToBufferWeb, hexEncode as hexEncodeWeb } from '../../src/encodings/hex.web.js'
|
|
|
|
describe('hex', () => {
|
|
it('should decode hex string to existing buffer', () => {
|
|
const buf = new Uint8Array(4)
|
|
hexDecode(buf, '01020304')
|
|
expect(buf).eql(new Uint8Array([1, 2, 3, 4]))
|
|
})
|
|
|
|
it('should decode hex string to new buffer', () => {
|
|
const buf = hexDecodeToBuffer('01020304')
|
|
expect(buf).eql(new Uint8Array([1, 2, 3, 4]))
|
|
})
|
|
|
|
it('should encode buffer to hex string', () => {
|
|
const buf = new Uint8Array([1, 2, 3, 4])
|
|
expect(hexEncode(buf)).eq('01020304')
|
|
})
|
|
})
|
|
|
|
describe('hex.web', () => {
|
|
it('should decode hex string to existing buffer', () => {
|
|
const buf = new Uint8Array(4)
|
|
hexDecodeWeb(buf, '01020304')
|
|
expect(buf).eql(new Uint8Array([1, 2, 3, 4]))
|
|
})
|
|
|
|
it('should decode hex string to new buffer', () => {
|
|
const buf = hexDecodeToBufferWeb('01020304')
|
|
expect(buf).eql(new Uint8Array([1, 2, 3, 4]))
|
|
})
|
|
|
|
it('should encode buffer to hex string', () => {
|
|
const buf = new Uint8Array([1, 2, 3, 4])
|
|
expect(hexEncodeWeb(buf)).eq('01020304')
|
|
})
|
|
})
|