From 029dd4319849cbdb0a66a4bcd55e38b753021417 Mon Sep 17 00:00:00 2001 From: Willem Olding Date: Thu, 24 Oct 2024 15:38:30 +1100 Subject: [PATCH] adds e2e test showing the alternative way to create accounts (#47) --- packages/e2e-tests/e2e/web_wallet.spec.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/e2e-tests/e2e/web_wallet.spec.ts b/packages/e2e-tests/e2e/web_wallet.spec.ts index 21fe31d..6709115 100644 --- a/packages/e2e-tests/e2e/web_wallet.spec.ts +++ b/packages/e2e-tests/e2e/web_wallet.spec.ts @@ -1,8 +1,12 @@ import { test, expect } from '@playwright/test'; import { WebWallet } from "@webzjs/webz-wallet"; +import type * as WebZKeys from "@webzjs/webz-keys"; declare global { - interface Window { webWallet: WebWallet; } + interface Window { + webWallet: WebWallet; + WebZKeys: typeof WebZKeys; + } } const SEED = "mix sample clay sweet planet lava giraffe hand fashion switch away pool rookie earth purity truly square trumpet goose move actor save jaguar volume"; @@ -30,3 +34,16 @@ test('Wallet can be serialized', async ({ page }) => { return bytes; }); }); + +test('Accont can be added from ufvk', async ({ page }) => { + let result = await page.evaluate(async () => { + let seed = new Uint8Array(32); + let birthday = 2657762; + let usk = new window.WebZKeys.UnifiedSpendingKey("main", seed, 0); + let ufvk = usk.to_unified_full_viewing_key(); + await window.webWallet.create_account_ufvk(ufvk.encode("main"), birthday); + let summary = await window.webWallet.get_wallet_summary(); + return summary?.account_balances.length; + }); + expect(result).toBe(2); +});