generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug in bytesToBase58btcMultibase() and add tests
Signed-off-by: Frank Hinek <[email protected]>
- Loading branch information
1 parent
9aa02be
commit 771c54e
Showing
3 changed files
with
33 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { expect } from 'chai'; | ||
|
||
import { bytesToBase58btcMultibase } from '../src/utils.js'; | ||
|
||
describe('Crypto Utils', () => { | ||
describe('bytesToBase58btcMultibase()', () => { | ||
it('returns a multibase encoded string', () => { | ||
// Test Vector 1. | ||
const input = { | ||
header : new Uint8Array([0x00, 0x00]), | ||
data : new Uint8Array([0x00, 0x00]) | ||
}; | ||
const output = 'z1111'; | ||
const encoded = bytesToBase58btcMultibase(input.header, input.data); | ||
expect(encoded).to.be.a.string; | ||
expect(encoded.substring(0, 1)).to.equal('z'); | ||
expect(encoded).to.deep.equal(output); | ||
}); | ||
|
||
it('returns multibase encoded value with specified header', () => { | ||
// Test Vector 1. | ||
const input = { | ||
header : new Uint8Array([0x01, 0x02]), | ||
data : new Uint8Array([3, 4, 5, 6, 7]) | ||
}; | ||
const output = 'z3DUyZY2dc'; | ||
|
||
const encoded = bytesToBase58btcMultibase(input.header, input.data); | ||
expect(encoded).to.deep.equal(output); | ||
}); | ||
}); | ||
}); |