- Add GETTING_STARTED.md with quick start guide and development modes - Add INSTALL.sh automated installation script - Add INSTALLATION_CHECKLIST.md, INSTALLATION_SUCCESS.md, and INSTALLATION_SUMMARY.md - Add QUICK_REFERENCE.md for common commands - Add SETUP_GUIDE.md with detailed setup instructions - Update README.md with improved project overview - Add did-wallet app dependencies and node_modules
25 lines
814 B
JavaScript
25 lines
814 B
JavaScript
/* globals describe, it */
|
|
|
|
import { varint } from '../src/index.js'
|
|
import { assert } from 'aegir/chai'
|
|
|
|
const UTF8 = new TextEncoder()
|
|
|
|
describe('varint', () => {
|
|
it('can decode with offset', () => {
|
|
const message = UTF8.encode('hello-world')
|
|
const outerTag = 0x55
|
|
const innerTag = 0xe3
|
|
const outerTagSize = varint.encodingLength(outerTag)
|
|
const innerTagSize = varint.encodingLength(innerTag)
|
|
|
|
const bytes = new Uint8Array(message.byteLength + outerTagSize + innerTagSize)
|
|
varint.encodeTo(outerTag, bytes)
|
|
varint.encodeTo(innerTag, bytes, outerTagSize)
|
|
bytes.set(message, outerTagSize + innerTagSize)
|
|
|
|
assert.deepStrictEqual(varint.decode(bytes), [outerTag, outerTagSize])
|
|
assert.deepStrictEqual(varint.decode(bytes, outerTagSize), [innerTag, innerTagSize])
|
|
})
|
|
})
|