test: run binary-codec tests in the browser (#2566)

- Convert tests to typescript
- Update type definitions causing errors in tests
  - `makeParser` to accept a `Buffer` in addition to `string`
  - `SerializedType` constructor allows not passing in a byte array
  - `Comparable` is now a generic type so that it allows `compareTo`
methods to take more that the type itself. Example: `Uint64.compareTo`
can accept `number`
- Update tests to use jasmine compatible functions
  - Switching from `test` to `it`.
  - Updated test checking if coretypes all implement SerializedType
  - Import fixtures directly instead of using `loadFixture` utility
- Remove importing of `buffer/` explicitly.  It was throwing off type
checking in tests.  Buffer is going away in a future PR anyway.
- Fixed `npm run clean` not clearing `.tsbuildinfo` files for keypairs
- Remove unused account-tx-transactions.db. It was likely used in the
past to test historical ledgers.
This commit is contained in:
Caleb Kniffen
2023-11-14 19:13:19 -06:00
parent 4c7f46c111
commit e2433101cb
58 changed files with 382 additions and 367 deletions

View File

@@ -0,0 +1,15 @@
const { quality } = require('../src/coretypes')
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(bytes.toString('hex').toUpperCase()).toBe(bookDirectory.slice(-16))
})
})