Skip to content

Commit

Permalink
fix: do not wait for refresh to finish on wallet create
Browse files Browse the repository at this point in the history
  • Loading branch information
limpbrains committed Nov 19, 2024
1 parent 8491108 commit 940e4bc
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "beignet",
"version": "0.0.46",
"version": "0.0.47",
"description": "A self-custodial, JS Bitcoin wallet management library.",
"main": "dist/index.js",
"scripts": {
Expand Down
3 changes: 1 addition & 2 deletions src/wallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,7 @@ export class Wallet {
const res = await wallet.setWalletData();
if (res.isErr()) return err(res.error.message);
wallet.updateFeeEstimates(true);
console.log('Syncing Wallet...');
await wallet.refreshWallet({});
wallet.refreshWallet({});
if (wallet._disableMessagesOnCreate) wallet.disableMessages = false;
return ok(wallet);
} catch (e) {
Expand Down
1 change: 1 addition & 0 deletions tests/boost.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ beforeEach(async function () {
throw res.error;
}
wallet = res.value;
await wallet.refreshWallet({});
});

describe('Boost', async function () {
Expand Down
4 changes: 3 additions & 1 deletion tests/electrum.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const expect = chai.expect;

const testTimeout = 60000;

let wallet;
let wallet: Wallet;

before(async function () {
this.timeout(testTimeout);
Expand All @@ -33,13 +33,15 @@ before(async function () {
return;
}
wallet = res.value;
await wallet.refreshWallet({});
});

describe('Electrum Methods', async function (): Promise<void> {
this.timeout(testTimeout);
it('connectToElectrum: Should connect to a random Electrum server', async () => {
const connectResponse = await wallet.connectToElectrum();
expect(connectResponse.isErr()).to.equal(false);
if (connectResponse.isErr()) return;
expect(connectResponse.value).to.equal('Connected to Electrum server.');
});

Expand Down
2 changes: 1 addition & 1 deletion tests/storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const expect = chai.expect;

const testTimeout = 60000;

let wallet;
let wallet: Wallet;
const WALLET_NAME = 'storagetestwallet0';

before(async function () {
Expand Down
9 changes: 7 additions & 2 deletions tests/transaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const expect = chai.expect;

const testTimeout = 60000;

let wallet;
let wallet: Wallet;

before(async function () {
this.timeout(testTimeout);
Expand All @@ -35,6 +35,7 @@ before(async function () {
return;
}
wallet = res.value;
await wallet.refreshWallet({});
});

describe('Transaction Test', async function (): Promise<void> {
Expand Down Expand Up @@ -158,7 +159,11 @@ describe('Transaction Test', async function (): Promise<void> {
await wallet.transaction.resetSendTransaction();
const setupResponse = await wallet.transaction.setupTransaction({
outputs: [
{ address: 'tb1qaq7jszepjuntxx494xhwrxs746v94583ls02ke', value: 5000 }
{
index: 0,
address: 'tb1qaq7jszepjuntxx494xhwrxs746v94583ls02ke',
value: 5000
}
]
});
expect(setupResponse.isErr()).to.equal(false);
Expand Down
1 change: 1 addition & 0 deletions tests/wallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ before(async function () {
return;
}
wallet = res.value;
await wallet.refreshWallet({});
});

describe('Wallet Library', async function () {
Expand Down

0 comments on commit 940e4bc

Please sign in to comment.