mirror of https://github.com/lukechilds/vainjs.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
816 B
38 lines
816 B
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();
|
|
});
|
|
|