aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/nwc-sw-test.js3
-rw-r--r--tools/nwc-test.js13
2 files changed, 16 insertions, 0 deletions
diff --git a/tools/nwc-sw-test.js b/tools/nwc-sw-test.js
index acf3027..ae79e18 100644
--- a/tools/nwc-sw-test.js
+++ b/tools/nwc-sw-test.js
@@ -51,6 +51,9 @@ function harness({ rec = baseRec(), recs = null, answered = false } = {}) {
published.push(JSON.parse(opts.body).event);
return { ok: true, json: async () => ({ ok: true }) };
}
+ if (url.includes('/claim')) {
+ return { ok: true, json: async () => ({ ok: true }) };
+ }
if (url.includes('/answered')) {
return { ok: true, json: async () => ({ answered: typeof answered === 'function' ? answered() : answered }) };
}
diff --git a/tools/nwc-test.js b/tools/nwc-test.js
index 5bb08e2..b68a89b 100644
--- a/tools/nwc-test.js
+++ b/tools/nwc-test.js
@@ -14,6 +14,7 @@ globalThis.localStorage = { getItem:k=>k in store?store[k]:null, setItem:(k,v)=>
let subHandler = null;
let priorReplies = [];
+let claimOk = true;
const published = [];
// fake relay transport: capture the subscription handler and any replies
const nwcTransport = {
@@ -21,6 +22,7 @@ const nwcTransport = {
publish: async (relays, evt) => { published.push(evt); return true; },
query: async () => priorReplies, // what other devices have answered (none, unless a test says so)
errGraceMs: 20, // the sibling-first hold, shortened for the harness
+ claim: async () => claimOk, // the notifier's first-come-first-pays verdict
};
let paid = [];
const wallet = {
@@ -133,6 +135,17 @@ console.log('\n[sibling payment in flight]');
delete hooks.arkLnOutcome;
}
+console.log('\n[cross-device claim]');
+{
+ claimOk = false;
+ const n = published.length, wasPaid = paid.length;
+ await request('pay_invoice', { invoice: INV21 });
+ check('unclaimed pay request stays silent and unpaid', published.length === n && paid.length === wasPaid);
+ claimOk = true;
+ r = await request('get_balance', {});
+ check('non-pay methods need no claim', r?.result?.balance === 42000*1000);
+}
+
console.log('\n[nip04 fallback]');
r = await request('get_balance', {}, 'nip04');
check('nip04 request answered', r?.result?.balance === 42000*1000);