aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-11 15:25:59 -0800
committerAdam Soltys <[email protected]>2026-02-11 15:35:00 -0800
commit423344dc466fa913c55a8adf3619ca958116914a (patch)
tree725913e0de67de0d9fb8e25e2002114f8d8a1477
parente8ec5124f61d636e1487d9b544d55b0806822e68 (diff)
downloadcoinos-ui-423344dc466fa913c55a8adf3619ca958116914a.tar.gz
coinos-ui-423344dc466fa913c55a8adf3619ca958116914a.zip
ark tests
-rw-r--r--bun.lock9
-rwxr-xr-xbun.lockbbin264125 -> 257286 bytes
-rw-r--r--package.json1
-rw-r--r--src/lib/ark.ts48
-rw-r--r--test-ark-addr.mjs43
-rw-r--r--test-ark-create.mjs137
-rw-r--r--test-ark-invoice.mjs90
-rw-r--r--test-ark-receive.mjs87
-rw-r--r--test-ark-sync.mjs70
9 files changed, 473 insertions, 12 deletions
diff --git a/bun.lock b/bun.lock
index a38ab114..3f6fbccb 100644
--- a/bun.lock
+++ b/bun.lock
@@ -39,6 +39,7 @@
"iconify-icon": "^3.0.2",
"js-cookie": "^3.0.5",
"nostr-tools": "^2.23.0",
+ "playwright": "^1.58.2",
"prettier": "^3.8.1",
"prettier-plugin-svelte": "^3.4.1",
"qr-scanner": "^1.4.2",
@@ -669,7 +670,7 @@
"fs.realpath": ["[email protected]", "", {}, "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="],
- "fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
+ "fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA=="],
"function-bind": ["[email protected]", "", {}, "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="],
@@ -1375,8 +1376,6 @@
"path-type/pify": ["[email protected]", "", {}, "sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg=="],
- "playwright/fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA=="],
-
"plist/@xmldom/xmldom": ["@xmldom/[email protected]", "", {}, "sha512-cQzWCtO6C8TQiYl1ruKNn2U6Ao4o4WBBcbL61yJl84x+j5sOWWFU9X7DpND8XZG3daDppSsigMdfAIl2upQBRw=="],
"prebuild-install/tar-fs": ["[email protected]", "", { "dependencies": { "chownr": "^1.1.1", "mkdirp-classic": "^0.5.2", "pump": "^3.0.0", "tar-stream": "^2.1.4" } }, "sha512-090nwYJDmlhwFwEW3QQl+vaNnxsO2yVsd45eTKRBzSzu+hlb1w2K9inVq5b0ngXuLVqQ4ApvsUHHnu/zQNkWAg=="],
@@ -1393,6 +1392,8 @@
"replace/yargs": ["[email protected]", "", { "dependencies": { "cliui": "^6.0.0", "decamelize": "^1.2.0", "find-up": "^4.1.0", "get-caller-file": "^2.0.1", "require-directory": "^2.1.1", "require-main-filename": "^2.0.0", "set-blocking": "^2.0.0", "string-width": "^4.2.0", "which-module": "^2.0.0", "y18n": "^4.0.0", "yargs-parser": "^18.1.2" } }, "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A=="],
+ "rollup/fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
+
"sharp/node-addon-api": ["[email protected]", "", {}, "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA=="],
"simple-plist/bplist-parser": ["[email protected]", "", { "dependencies": { "big-integer": "1.6.x" } }, "sha512-PyJxiNtA5T2PlLIeBot4lbp7rj4OadzjnMZD/G5zuBNt8ei/yCU7+wW0h2bag9vr8c+/WuRWmSxbqAl9hL1rBA=="],
@@ -1401,6 +1402,8 @@
"ts-node/diff": ["[email protected]", "", {}, "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A=="],
+ "vite/fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
+
"xcode/uuid": ["[email protected]", "", { "bin": { "uuid": "dist/bin/uuid" } }, "sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg=="],
"xml2js/xmlbuilder": ["[email protected]", "", {}, "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA=="],
diff --git a/bun.lockb b/bun.lockb
index ab483486..c9fe8f62 100755
--- a/bun.lockb
+++ b/bun.lockb
Binary files differ
diff --git a/package.json b/package.json
index c7d3999c..acd1ce7d 100644
--- a/package.json
+++ b/package.json
@@ -28,6 +28,7 @@
"iconify-icon": "^3.0.2",
"js-cookie": "^3.0.5",
"nostr-tools": "^2.23.0",
+ "playwright": "^1.58.2",
"prettier": "^3.8.1",
"prettier-plugin-svelte": "^3.4.1",
"qr-scanner": "^1.4.2",
diff --git a/src/lib/ark.ts b/src/lib/ark.ts
index 0a31a31c..d045049e 100644
--- a/src/lib/ark.ts
+++ b/src/lib/ark.ts
@@ -1,8 +1,12 @@
+import { PUBLIC_COINOS_NETWORK } from "$env/static/public";
import { persistLocal } from "$lib/store";
import { post } from "$lib/utils";
import { get } from "svelte/store";
-export const arkServerUrl = "http://localhost:7070";
+export const arkServerUrl = {
+ bitcoin: "https://arkade.computer",
+ regtest: "http://localhost:7070",
+}[PUBLIC_COINOS_NETWORK || "regtest"];
export const arkkey = persistLocal("arkkey", "");
let arkSdkPromise: Promise<typeof import("@arkade-os/sdk")> | undefined;
@@ -51,16 +55,42 @@ export const syncTransactions = async (aid: string) => {
const wallet = await getWallet();
if (!wallet) return;
+ const transactions: any[] = [];
+
const history = await wallet.getTransactionHistory();
- if (!history.length) return;
+ const historyTxids = new Set<string>();
+ console.log("arkSync: history", history.length, history);
+
+ for (const tx of history) {
+ if (tx.key.arkTxid) historyTxids.add(tx.key.arkTxid);
+ if (tx.key.commitmentTxid) historyTxids.add(tx.key.commitmentTxid);
+ transactions.push({
+ arkTxid: tx.key.arkTxid || null,
+ commitmentTxid: tx.key.commitmentTxid || null,
+ amount: tx.type === "RECEIVED" ? tx.amount : -tx.amount,
+ settled: tx.settled,
+ createdAt: tx.createdAt,
+ });
+ }
+
+ // Include preconfirmed VTXOs not yet in transaction history
+ const vtxos = await wallet.getVtxos({ spendableOnly: false });
+ console.log("arkSync: vtxos", vtxos.length, vtxos);
+ for (const v of vtxos) {
+ if (v.virtualStatus?.state !== "preconfirmed") continue;
+ const id = v.arkTxId || v.txid;
+ if (!id || historyTxids.has(id)) continue;
+ historyTxids.add(id);
+ transactions.push({
+ arkTxid: v.arkTxId || null,
+ commitmentTxid: v.txid || null,
+ amount: Number(v.value),
+ settled: false,
+ createdAt: v.createdAt ? new Date(v.createdAt).getTime() : Date.now(),
+ });
+ }
- const transactions = history.map((tx) => ({
- arkTxid: tx.key.arkTxid || null,
- commitmentTxid: tx.key.commitmentTxid || null,
- amount: tx.type === "RECEIVED" ? tx.amount : -tx.amount,
- settled: tx.settled,
- createdAt: tx.createdAt,
- }));
+ if (!transactions.length) return;
return post("/post/ark/sync", { transactions, aid });
};
diff --git a/test-ark-addr.mjs b/test-ark-addr.mjs
new file mode 100644
index 00000000..b2b920d0
--- /dev/null
+++ b/test-ark-addr.mjs
@@ -0,0 +1,43 @@
+import { chromium } from "playwright";
+
+const BASE = "http://172.18.0.9:3000";
+const ARK_KEY = "1fed5c62c46ea3f72757e0baf1b83573ffd125eaba69a61c0f847c0d26d7b924";
+
+(async () => {
+ const browser = await chromium.launch({ headless: true });
+ const page = await browser.newPage({ ignoreHTTPSErrors: true });
+
+ await page.goto(BASE, { waitUntil: "domcontentloaded" });
+ await page.waitForTimeout(2000);
+
+ const result = await page.evaluate(async (key) => {
+ try {
+ const sdk = await import("/_app/immutable/chunks/Ciyv5OgZ.js");
+ const { SingleKey, Wallet } = sdk;
+
+ const identity = SingleKey.fromHex(key);
+ const wallet = await Wallet.create({
+ identity,
+ arkServerUrl: "https://arkade.computer",
+ });
+ const address = await wallet.getAddress();
+ const balance = await wallet.getBalance();
+ const vtxos = await wallet.getVtxos({ spendableOnly: false });
+ const history = await wallet.getTransactionHistory();
+ return {
+ address,
+ balance,
+ vtxoCount: vtxos.length,
+ vtxos: vtxos.map(v => ({
+ txid: v.txid, value: Number(v.value), state: v.virtualStatus?.state,
+ })),
+ historyCount: history.length,
+ };
+ } catch (e) {
+ return { error: e.message, stack: e.stack };
+ }
+ }, ARK_KEY);
+
+ console.log(JSON.stringify(result, null, 2));
+ await browser.close();
+})();
diff --git a/test-ark-create.mjs b/test-ark-create.mjs
new file mode 100644
index 00000000..7db6c79b
--- /dev/null
+++ b/test-ark-create.mjs
@@ -0,0 +1,137 @@
+import { chromium } from "playwright";
+
+const BASE = "http://172.18.0.9:3000";
+const API = "http://172.18.0.12:3119";
+const API_KEY = "test-playwright-key";
+
+(async () => {
+ const browser = await chromium.launch({ headless: true });
+ const context = await browser.newContext({ ignoreHTTPSErrors: true });
+ const page = await context.newPage();
+
+ page.on("console", (msg) => console.log(`[browser:${msg.type()}]`, msg.text()));
+ page.on("pageerror", (err) => console.log("[page error]", err.message));
+
+ page.on("request", (req) => {
+ const u = req.url();
+ if (u.includes("account") || u.includes("arkade.computer")) {
+ console.log(`[req] ${req.method()} ${u} ${req.postData()?.substring(0, 500) || ""}`);
+ }
+ });
+ page.on("response", (resp) => {
+ const u = resp.url();
+ if (u.includes("account") && !u.includes("__data")) {
+ resp.text().then((t) => console.log(`[resp] ${resp.status()} ${u} -> ${t.substring(0, 500)}`)).catch(() => {});
+ }
+ });
+
+ // 1. Login
+ console.log("--- Logging in ---");
+ const loginResp = await page.request.post(`${API}/login`, {
+ data: { username: "bob", password: "pw" },
+ headers: { "content-type": "application/json", "x-api-key": API_KEY },
+ });
+ console.log("Login:", loginResp.status());
+ for (const h of await loginResp.headersArray()) {
+ if (h.name.toLowerCase() === "set-cookie") {
+ const m = h.value.match(/token=([^;]+)/);
+ if (m) await context.addCookies([{ name: "token", value: m[1], domain: "172.18.0.9", path: "/" }]);
+ }
+ }
+
+ // 2. Go to ark account creation page
+ console.log("\n--- Going to /account/ark ---");
+ await page.goto(`${BASE}/account/ark`, { waitUntil: "domcontentloaded" });
+ await page.waitForTimeout(5000);
+
+ // Wait for the SDK to derive an address (it calls Wallet.create on mount)
+ console.log("Waiting for SDK to initialize...");
+ await page.waitForTimeout(10000);
+
+ // 3. Click "Reveal backup key"
+ console.log("\n--- Revealing backup key ---");
+ const revealBtn = page.locator("button", { hasText: "Reveal backup key" });
+ if (await revealBtn.count()) {
+ await revealBtn.click();
+ await page.waitForTimeout(1000);
+ const nsecText = await page.locator("button[aria-label='Copy backup key']").innerText().catch(() => "not found");
+ console.log("Backup key:", nsecText.substring(0, 30), "...");
+ }
+
+ // 4. Click "I've backed it up"
+ const confirmBtn = page.locator("button", { hasText: "backed it up" });
+ if (await confirmBtn.count()) {
+ await confirmBtn.click();
+ await page.waitForTimeout(1000);
+ console.log("Confirmed backup");
+ }
+
+ // 5. Set password and confirm
+ const pwInput = page.locator('input[name="password"]');
+ const confirmInput = page.locator('input[placeholder="Confirm password"]');
+ if (await pwInput.count()) {
+ await pwInput.fill("123");
+ await confirmInput.fill("123");
+ console.log("Filled passwords");
+
+ await page.screenshot({ path: "/tmp/ark-create-form.png" });
+
+ // 6. Submit
+ const submitBtn = page.locator('button[type="submit"]');
+ await submitBtn.click();
+ console.log("--- Submitted ---");
+ await page.waitForTimeout(15000);
+ console.log("URL after submit:", page.url());
+ } else {
+ console.log("Password form not found");
+ await page.screenshot({ path: "/tmp/ark-create-debug.png" });
+ }
+
+ // 7. Check accounts
+ console.log("\n--- Checking accounts ---");
+ const acctResp = await page.request.get(`${API}/accounts`, {
+ headers: {
+ cookie: (await context.cookies()).map((c) => `${c.name}=${c.value}`).join("; "),
+ },
+ });
+ const accounts = await acctResp.json();
+ for (const a of accounts) {
+ console.log(`Account: ${a.name} (${a.type}) balance=${a.balance}`);
+ if (a.type === "ark") {
+ console.log(" arkAddress:", a.arkAddress);
+ }
+ }
+
+ // 8. Verify SDK derives the same address
+ const arkAcct = accounts.find((a) => a.type === "ark");
+ if (arkAcct) {
+ const arkkey = await page.evaluate(() => {
+ const v = localStorage.getItem("arkkey");
+ return v ? JSON.parse(v) : null;
+ });
+ console.log("\narkkey from localStorage:", arkkey);
+
+ if (arkkey) {
+ // Use the bundled SDK to verify
+ const sdkAddr = await page.evaluate(async (key) => {
+ try {
+ const sdk = await import("/_app/immutable/chunks/Ciyv5OgZ.js");
+ const identity = sdk.SingleKey.fromHex(key);
+ const wallet = await sdk.Wallet.create({
+ identity,
+ arkServerUrl: "https://arkade.computer",
+ });
+ return await wallet.getAddress();
+ } catch (e) {
+ return "error: " + e.message;
+ }
+ }, arkkey);
+
+ console.log("SDK-derived address:", sdkAddr);
+ console.log("Stored address: ", arkAcct.arkAddress);
+ console.log("Match:", sdkAddr === arkAcct.arkAddress);
+ }
+ }
+
+ await browser.close();
+})();
diff --git a/test-ark-invoice.mjs b/test-ark-invoice.mjs
new file mode 100644
index 00000000..8b88d072
--- /dev/null
+++ b/test-ark-invoice.mjs
@@ -0,0 +1,90 @@
+import { chromium } from "playwright";
+
+const BASE = "https://staging.coinos.io";
+const API = "https://staging.coinos.io/api";
+const API_KEY = "test-playwright-key";
+
+(async () => {
+ const browser = await chromium.launch({ headless: true });
+ const context = await browser.newContext({ ignoreHTTPSErrors: true });
+ const page = await context.newPage();
+
+ page.on("console", (msg) => console.log(`[browser:${msg.type()}]`, msg.text()));
+ page.on("pageerror", (err) => console.log("[page error]", err.message));
+
+ // Monitor relevant requests
+ page.on("request", (req) => {
+ const u = req.url();
+ if (u.includes("ark") || u.includes("sync") || u.includes("invoice") || u.includes("ws")) {
+ if (!u.includes("__data") && !u.includes(".png") && !u.includes(".js") && !u.includes(".css")) {
+ console.log(`[req] ${req.method()} ${u.substring(0, 120)}`);
+ }
+ }
+ });
+ page.on("response", (resp) => {
+ const u = resp.url();
+ if (u.includes("ark/sync") || (u.includes("invoice") && !u.includes("__data"))) {
+ resp.text().then((t) => console.log(`[resp] ${resp.status()} ${u.substring(0, 80)} -> ${t.substring(0, 300)}`)).catch(() => {});
+ }
+ });
+
+ // 1. Login
+ console.log("--- Logging in ---");
+ const loginResp = await page.request.post(`${API}/login`, {
+ data: { username: "bob", password: "pw" },
+ headers: { "content-type": "application/json", "x-api-key": API_KEY },
+ });
+ console.log("Login:", loginResp.status());
+ for (const h of await loginResp.headersArray()) {
+ if (h.name.toLowerCase() === "set-cookie") {
+ const m = h.value.match(/token=([^;]+)/);
+ if (m) {
+ await context.addCookies([
+ { name: "token", value: m[1], domain: "staging.coinos.io", path: "/" },
+ ]);
+ }
+ }
+ }
+
+ // Set the ark account cookie so invoice page recognizes us as the owner
+ await context.addCookies([
+ { name: "aid", value: "6eb11dd0-e591-4331-a9a7-93e69804b28b", domain: "staging.coinos.io", path: "/" },
+ ]);
+
+ // 2. Create an ark invoice for 1000 sats (matches existing VTXO)
+ console.log("\n--- Creating ark invoice for 1000 sats ---");
+ const invResp = await page.request.post(`${API}/invoice`, {
+ data: {
+ invoice: { type: "ark", amount: 1000, aid: "6eb11dd0-e591-4331-a9a7-93e69804b28b" },
+ user: { username: "bob" },
+ },
+ headers: { "content-type": "application/json", "x-api-key": API_KEY },
+ });
+ const invoice = await invResp.json();
+ console.log("Invoice created:", invoice.id, "amount:", invoice.amount);
+
+ // 3. Wait a moment for watcher to process existing VTXOs
+ await new Promise((r) => setTimeout(r, 3000));
+
+ // 4. Navigate to the invoice page — should redirect to /paid
+ console.log("\n--- Navigating to invoice page ---");
+ const invoiceUrl = `${BASE}/invoice/${invoice.id}`;
+ console.log("URL:", invoiceUrl);
+ await page.goto(invoiceUrl, { waitUntil: "domcontentloaded" });
+ await page.waitForTimeout(3000);
+
+ const finalUrl = page.url();
+ console.log("Final URL:", finalUrl);
+ console.log("Redirected to paid?", finalUrl.includes("/paid"));
+
+ // 5. Check page content
+ const bodyText = await page.textContent("body");
+ if (bodyText.includes("1,000") || bodyText.includes("1000")) {
+ console.log("SUCCESS: Payment amount visible on page");
+ }
+
+ await page.screenshot({ path: "/tmp/ark-invoice-result.png" });
+ console.log("Screenshot saved to /tmp/ark-invoice-result.png");
+
+ await browser.close();
+})();
diff --git a/test-ark-receive.mjs b/test-ark-receive.mjs
new file mode 100644
index 00000000..106061dd
--- /dev/null
+++ b/test-ark-receive.mjs
@@ -0,0 +1,87 @@
+import { chromium } from "playwright";
+
+const BASE = "http://172.18.0.9:3000";
+const API = "http://172.18.0.12:3119";
+const API_KEY = "test-playwright-key";
+const ARK_KEY = "02b3ef049246a14b8a31e66f877dcb32be34945f270054ad97534af8e5ff75f0";
+
+(async () => {
+ const browser = await chromium.launch({ headless: true });
+ const context = await browser.newContext({ ignoreHTTPSErrors: true });
+ const page = await context.newPage();
+
+ page.on("console", (msg) => console.log(`[browser:${msg.type()}]`, msg.text()));
+ page.on("pageerror", (err) => console.log("[page error]", err.message));
+
+ page.on("request", (req) => {
+ const u = req.url();
+ if (u.includes("ark") || u.includes("indexer") || u.includes("sync")) {
+ console.log(`[req] ${req.method()} ${u} ${req.postData()?.substring(0, 500) || ""}`);
+ }
+ });
+ page.on("response", (resp) => {
+ const u = resp.url();
+ if ((u.includes("ark") && !u.includes("__data") && !u.includes(".png")) || u.includes("indexer") || u.includes("sync")) {
+ resp.text().then((t) => console.log(`[resp] ${resp.status()} ${u} -> ${t.substring(0, 500)}`)).catch(() => {});
+ }
+ });
+
+ // 1. Login
+ console.log("--- Logging in ---");
+ const loginResp = await page.request.post(`${API}/login`, {
+ data: { username: "bob", password: "pw" },
+ headers: { "content-type": "application/json", "x-api-key": API_KEY },
+ });
+ console.log("Login:", loginResp.status());
+ for (const h of await loginResp.headersArray()) {
+ if (h.name.toLowerCase() === "set-cookie") {
+ const m = h.value.match(/token=([^;]+)/);
+ if (m) await context.addCookies([{ name: "token", value: m[1], domain: "172.18.0.9", path: "/" }]);
+ }
+ }
+
+ // 2. Set arkkey in localStorage
+ await page.goto(`${BASE}/bob`, { waitUntil: "domcontentloaded" });
+ await page.waitForTimeout(2000);
+
+ await page.evaluate((key) => {
+ localStorage.setItem("arkkey", JSON.stringify(key));
+ }, ARK_KEY);
+
+ // 3. Reload to trigger sync
+ console.log("\n--- Reloading with arkkey set ---");
+ await page.goto(`${BASE}/bob`, { waitUntil: "domcontentloaded" });
+
+ console.log("--- Waiting 30s for SDK + sync ---");
+ await page.waitForTimeout(30000);
+
+ // 4. Check results
+ console.log("\n--- Checking accounts ---");
+ const acctResp = await page.request.get(`${API}/accounts`, {
+ headers: {
+ cookie: (await context.cookies()).map((c) => `${c.name}=${c.value}`).join("; "),
+ },
+ });
+ const accounts = await acctResp.json();
+ for (const a of accounts) {
+ console.log(`Account: ${a.name} (${a.type}) balance=${a.balance}`);
+ if (a.type === "ark") {
+ console.log(" arkAddress:", a.arkAddress);
+ }
+ }
+
+ // 5. Check payments
+ console.log("\n--- Checking payments ---");
+ const payResp = await page.request.get(`${API}/payments`, {
+ headers: {
+ cookie: (await context.cookies()).map((c) => `${c.name}=${c.value}`).join("; "),
+ },
+ });
+ const payments = await payResp.json();
+ console.log(`Total payments: ${payments.length}`);
+ for (const p of payments.slice(0, 5)) {
+ console.log(` ${p.type} ${p.amount} ${p.hash?.substring(0, 16)}...`);
+ }
+
+ await browser.close();
+})();
diff --git a/test-ark-sync.mjs b/test-ark-sync.mjs
new file mode 100644
index 00000000..f4fcf1ff
--- /dev/null
+++ b/test-ark-sync.mjs
@@ -0,0 +1,70 @@
+import { chromium } from "playwright";
+
+const BASE = "http://172.18.0.9:3000";
+const API = "http://172.18.0.12:3119";
+const API_KEY = "test-playwright-key";
+const ARK_KEY = "1fed5c62c46ea3f72757e0baf1b83573ffd125eaba69a61c0f847c0d26d7b924";
+
+(async () => {
+ const browser = await chromium.launch({ headless: true });
+ const context = await browser.newContext({ ignoreHTTPSErrors: true });
+ const page = await context.newPage();
+
+ page.on("console", (msg) => console.log(`[browser:${msg.type()}]`, msg.text()));
+ page.on("pageerror", (err) => console.log("[page error]", err.message));
+
+ // Monitor ALL arkade.computer requests
+ page.on("request", (req) => {
+ const u = req.url();
+ if (u.includes("arkade.computer")) {
+ console.log(`[req] ${req.method()} ${u} ${req.postData()?.substring(0, 300) || ""}`);
+ }
+ });
+ page.on("response", (resp) => {
+ const u = resp.url();
+ if (u.includes("arkade.computer") && !u.includes("subscription/")) {
+ resp.text().then((t) => console.log(`[resp] ${resp.status()} ${u} -> ${t.substring(0, 500)}`));
+ }
+ });
+
+ // 1. Login
+ console.log("--- Logging in ---");
+ const loginResp = await page.request.post(`${API}/login`, {
+ data: { username: "bob", password: "pw" },
+ headers: { "content-type": "application/json", "x-api-key": API_KEY },
+ });
+ console.log("Login:", loginResp.status());
+ const allHeaders = await loginResp.headersArray();
+ for (const h of allHeaders) {
+ if (h.name.toLowerCase() === "set-cookie") {
+ const m = h.value.match(/token=([^;]+)/);
+ if (m) await context.addCookies([{ name: "token", value: m[1], domain: "172.18.0.9", path: "/" }]);
+ }
+ }
+
+ // 2. Go to bob's page, set arkkey
+ await page.goto(`${BASE}/bob`, { waitUntil: "domcontentloaded" });
+ await page.evaluate((key) => localStorage.setItem("arkkey", JSON.stringify(key)), ARK_KEY);
+
+ // 3. Reload — don't wait for networkidle since SSE subscription stays open
+ console.log("--- Reloading with arkkey ---");
+ await page.goto(`${BASE}/bob`, { waitUntil: "domcontentloaded" });
+ console.log("--- Waiting 15s for SDK ---");
+ await page.waitForTimeout(15000);
+
+ // 4. Check SDK state by evaluating in browser context
+ console.log("\n--- Checking SDK balance/vtxos/history ---");
+ // The app's getWallet() should have created a wallet instance.
+ // We can't import the module directly, but we can check what the accounts endpoint returns.
+ const accountsData = await page.request.get(`${API}/accounts`, {
+ headers: {
+ "x-api-key": API_KEY,
+ cookie: (await context.cookies()).map((c) => `${c.name}=${c.value}`).join("; "),
+ },
+ });
+ console.log("Accounts:", (await accountsData.text()).substring(0, 500));
+
+ // 5. Check server logs
+ console.log("\n--- Done. Check docker logs app for arkSync entries ---");
+ await browser.close();
+})();