Skip to content

Commit

Permalink
test: lookahead test
Browse files Browse the repository at this point in the history
  • Loading branch information
emjshrx committed Feb 18, 2024
1 parent 1554033 commit 96d3516
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions test/wallet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import { BitcoinRpcClient } from './helpers/bitcoin-rpc-client';
describe('Wallet', () => {
let wallet: Wallet;
let address: string;
let walletDB: WalletDB;
let bitcoinRpcClient: BitcoinRpcClient;
let silentPaymentAddress: string;

beforeAll(async () => {
const walletDB = new WalletDB({
walletDB = new WalletDB({
location: './test/wallet',
});

Expand All @@ -31,11 +32,24 @@ describe('Wallet', () => {
);
});

it('should initialise the wallet', async () => {
it('should initialise the wallet and save lookahead addresses', async () => {
await wallet.init({
mnemonic:
'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
});
const allAddresses = await walletDB.getAllAddresses();
expect(allAddresses).toStrictEqual([
'bcrt1qcr8te4kr609gcawutmrza0j4xv80jy8zeqchgx',
'bcrt1qgl5vlg0zdl7yvprgxj9fevsc6q6x5dmcvenxlt',
'bcrt1qgswpjzsqgrm2qkfkf9kzqpw6642ptrgz4wwff7',
'bcrt1qhxgzmkmwvrlwvlfn4qe57lx2qdfg8physujr0f',
'bcrt1qm97vqzgj934vnaq9s53ynkyf9dgr05rat8p3ef',
'bcrt1qncdts3qm2guw3hjstun7dd6t3689qg42eqsfxf',
'bcrt1qnjg0jd8228aq7egyzacy8cys3knf9xvr3v5hfj',
'bcrt1qnpzzqjzet8gd5gl8l6gzhuc4s9xv0djt8vazj8',
'bcrt1qp59yckz4ae5c4efgw2s5wfyvrz0ala7rqr7utc',
'bcrt1qtet8q6cd5vqm0zjfcfm8mfsydju0a29gq0p9sl',
]);
});

it('should set a new password, close and reopen the wallet with the same password', async () => {
Expand All @@ -48,11 +62,15 @@ describe('Wallet', () => {
it('should derive first receive address', async () => {
address = await wallet.deriveReceiveAddress();
expect(address).toBe('bcrt1qcr8te4kr609gcawutmrza0j4xv80jy8zeqchgx');
const allAddresses = await walletDB.getAllAddresses();
expect(allAddresses.length).toStrictEqual(11);
});

it('should derive second receive address', async () => {
const address = await wallet.deriveReceiveAddress();
expect(address).toBe('bcrt1qnjg0jd8228aq7egyzacy8cys3knf9xvr3v5hfj');
const allAddresses = await walletDB.getAllAddresses();
expect(allAddresses.length).toStrictEqual(12);
});

it('should derive first change address', async () => {
Expand Down

0 comments on commit 96d3516

Please sign in to comment.