Skip to content

Commit

Permalink
extra case for bgsync (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCyjaneK authored Jan 16, 2025
1 parent b4c3fba commit 9526921
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
4 changes: 4 additions & 0 deletions impls/monero.ts/src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ export class Wallet {
);
}

async setRefreshFromBlockHeight(height = 0n): Promise<void> {
return await fns.Wallet_setRefreshFromBlockHeight(this.#ptr, height);
}

async balance(accountIndex = 0): Promise<bigint> {
return await fns.Wallet_balance(this.#ptr, accountIndex);
}
Expand Down
48 changes: 47 additions & 1 deletion tests/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,12 @@ Deno.test("0001-polyseed.patch", async (t) => {
}
});

Deno.test("0002-wallet-background-sync-with-just-the-view-key.patch", async () => {
Deno.test("0002-wallet-background-sync-with-just-the-view-key.patch (close)", async () => {
await clearWallets();

const walletManager = await WalletManager.new();
const wallet = await walletManager.createWallet("tests/wallets/squirrel", "belka");
await wallet.setRefreshFromBlockHeight(3310000n);
await wallet.init({
address: NODE_URL,
});
Expand Down Expand Up @@ -289,6 +290,51 @@ Deno.test("0002-wallet-background-sync-with-just-the-view-key.patch", async () =
await reopenedWallet.close(true);
});

Deno.test("0002-wallet-background-sync-with-just-the-view-key.patch (stopBackgroundSync)", async () => {
await clearWallets();

const walletManager = await WalletManager.new();
const wallet = await walletManager.createWallet("tests/wallets/squirrel", "belka");
await wallet.setRefreshFromBlockHeight(3310000n);
await wallet.init({
address: NODE_URL,
});


const walletInfo = {
address: await wallet.address(),
publicSpendKey: await wallet.publicSpendKey(),
secretSpendKey: await wallet.secretSpendKey(),
publicViewKey: await wallet.publicViewKey(),
secretViewKey: await wallet.secretViewKey(),
};

await wallet.setupBackgroundSync(2, "belka", "background-belka");
await wallet.startBackgroundSync();


await wallet.init({ address: NODE_URL });
await wallet.refreshAsync();

const blockChainHeight = await syncBlockchain(wallet);

await wallet.stopBackgroundSync("belka");

assertEquals(await wallet.blockChainHeight(), blockChainHeight);
assertEquals(
walletInfo,
{
address: await wallet.address(),
publicSpendKey: await wallet.publicSpendKey(),
secretSpendKey: await wallet.secretSpendKey(),
publicViewKey: await wallet.publicViewKey(),
secretViewKey: await wallet.secretViewKey(),
},
);

await wallet.close(true);
});

Deno.test("0004-coin-control.patch", {
ignore: coin === "wownero" || !(
Deno.env.get("SECRET_WALLET_PASSWORD") &&
Expand Down

0 comments on commit 9526921

Please sign in to comment.