-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.js
38 lines (29 loc) · 816 Bytes
/
events.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
import test from 'ava';
import * as bitcoin from 'bitcoinjs-lib';
import Vain from '..';
test('Vain instance emits `found` event when vanity address is found', t => {
t.plan(2);
const options = {
prefix: 'A'
};
const vain = new Vain(options);
vain.on('found', ({address, wif}) => {
const keyPair = bitcoin.ECPair.fromWIF(wif);
const {address: wifAddress} = bitcoin.payments.p2pkh({pubkey: keyPair.publicKey});
t.true(address.startsWith(`1${options.prefix}`));
t.is(address, wifAddress);
});
vain.generate();
});
test('Vain instance emits `update` event during address generation', t => {
t.plan(1);
const options = {
prefix: '1BitcoinEaterAddressDontSend'
};
const vain = new Vain(options);
vain.on('update', () => {
vain.generating = false;
t.pass();
});
vain.generate();
});