aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-09 01:19:33 -0800
committerAdam Soltys <[email protected]>2026-02-09 01:19:33 -0800
commit6f933c6e989f934364a276815826364fec5a85b4 (patch)
tree54e5b7818250a8cadcbb20111f24c9a5ee4bc674 /test
parent3cde20ead47bf2fc895ea37789b824098b984f7a (diff)
downloadcoinos-server-6f933c6e989f934364a276815826364fec5a85b4.tar.gz
coinos-server-6f933c6e989f934364a276815826364fec5a85b4.zip
ark fixes
Diffstat (limited to 'test')
-rw-r--r--test/forward.test.ts12
-rw-r--r--test/preload.ts8
2 files changed, 13 insertions, 7 deletions
diff --git a/test/forward.test.ts b/test/forward.test.ts
index c387c489..1e0cd566 100644
--- a/test/forward.test.ts
+++ b/test/forward.test.ts
@@ -296,12 +296,12 @@ describe("arkReceive", () => {
describe("arkSync", () => {
beforeEach(resetAll);
- test("skips received/change VTXOs (positive amounts)", async () => {
+ test("records received VTXOs (positive amounts)", async () => {
const req = {
body: {
aid: arkAccountId,
transactions: [
- { hash: "change-vtxo-hash", amount: 9000, settled: true, createdAt: Date.now() },
+ { hash: "recv-vtxo-hash", amount: 9000, settled: true, createdAt: Date.now() },
],
},
user: makeUser(),
@@ -311,8 +311,9 @@ describe("arkSync", () => {
await routes.arkSync(req as any, res as any);
const sent = (res as any).getSent();
- expect(sent.synced).toBe(0);
- expect(store().listStore[`${arkAccountId}:payments`] ?? []).toHaveLength(0);
+ expect(sent.synced).toBe(1);
+ expect(sent.received).toBe(9000);
+ expect(store().listStore[`${arkAccountId}:payments`] ?? []).toHaveLength(1);
});
test("records sent transactions (negative amounts)", async () => {
@@ -335,7 +336,8 @@ describe("arkSync", () => {
});
test("deduplicates known transactions", async () => {
- // Pre-store a known tx hash
+ // Pre-store a known tx hash and its sync lock
+ store().kvStore[`arksync:${arkAccountId}:known-hash`] = "1";
store().kvStore[`payment:${arkAccountId}:known-hash`] = JSON.stringify("existing-id");
store().kvStore["payment:existing-id"] = JSON.stringify({ id: "existing-id", confirmed: false });
diff --git a/test/preload.ts b/test/preload.ts
index 0704561a..151c3c64 100644
--- a/test/preload.ts
+++ b/test/preload.ts
@@ -71,7 +71,11 @@ mock.module("$lib/db", () => {
return {
db: {
get: async (k: string) => kv()[k] ?? null,
- set: async (k: string, v: string) => { kv()[k] = v; return "OK"; },
+ set: async (k: string, v: string, opts?: any) => {
+ if (opts?.NX && kv()[k] !== undefined) return null;
+ kv()[k] = v;
+ return "OK";
+ },
del: async (k: string) => { delete kv()[k]; return 1; },
exists: async (k: string) => (kv()[k] !== undefined ? 1 : 0),
lPush: async (k: string, v: string) => {
@@ -185,7 +189,7 @@ mock.module("$lib/nostr", () => ({
}));
mock.module("$lib/mqtt", () => ({ default: { publish: () => {} } }));
mock.module("$lib/ark", () => ({
- getArkAddress: async () => "ark-addr", sendArk: async () => "ark-txid", getArkBalance: async () => 0,
+ getArkAddress: async () => "ark-addr", sendArk: async () => "ark-txid", getArkBalance: async () => 0, verifyArkVtxo: async () => true,
}));
mock.module("$lib/ecash", () => ({ request: async () => ({}) }));
mock.module("$lib/lightning", () => ({