Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4992ee5
commit ee11391
Showing
2 changed files
with
45 additions
and
0 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 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,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(); | ||
}); |