fix: zero pad correctly

This commit is contained in:
Michael Vines 2018-09-30 20:07:28 -07:00
parent 4f1112534d
commit aa1d6ba4d4
2 changed files with 5 additions and 1 deletions

View File

@ -56,7 +56,7 @@ export class PublicKey {
}
const zeroPad = new Buffer(32);
b.copy(zeroPad, 32 - b.length);
b.copy(zeroPad);
return zeroPad;
}

View File

@ -37,6 +37,10 @@ test('isPublicKey', () => {
test('toBase58', () => {
const key = new PublicKey('0x300000000000000000000000000000000000000000000000000000000000000');
expect(key.toBase58()).toBe('CiDwVBFgWV9E5MvXWoLgnEgn2hK7rJikbvfWavzAQz3');
const key2 = new PublicKey('123456789');
expect(key2.toBase58()).toBe('Vj3WURvtMv1mii1vhTqLhcSwVWDRs2E135KtTYUXtTq');
console.log(key2.toBuffer());
});
test('toBuffer', () => {