forked from bcoin-org/bcoin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeyring-test.js
52 lines (42 loc) · 1.57 KB
/
keyring-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* eslint-env mocha */
/* eslint prefer-arrow-callback: "off" */
'use strict';
const assert = require('./util/assert');
const KeyRing = require('../lib/primitives/keyring');
const uncompressed = KeyRing.fromSecret(
'5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss', 'main');
const compressed = KeyRing.fromSecret(
'L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1', 'main');
describe('KeyRing', function() {
it('should get uncompressed public key', () => {
assert.strictEqual(
'04a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd5b'
+ '8dec5235a0fa8722476c7709c02559e3aa73aa03918ba2d492eea75abea235',
uncompressed.getPublicKey('hex'));
});
it('should get uncompressed public key address', () => {
assert.strictEqual(
'1HZwkjkeaoZfTSaJxDw6aKkxp45agDiEzN',
uncompressed.getKeyAddress('base58', 'main'));
});
it('should get uncompressed WIF', () => {
assert.strictEqual(
'5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss',
uncompressed.toSecret('main'));
});
it('should get compressed public key', () => {
assert.strictEqual(
'03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd',
compressed.getPublicKey('hex'));
});
it('should get compressed public key address', () => {
assert.strictEqual(
'1F3sAm6ZtwLAUnj7d38pGFxtP3RVEvtsbV',
compressed.getKeyAddress('base58', 'main'));
});
it('should get compressed WIF', () => {
assert.strictEqual(
'L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1',
compressed.toSecret('main'));
});
});