Changeset 30d0e2c in Klonkt for test/guardianship.test.js
- Timestamp:
- 08/03/2026 06:38:16 AM (5 weeks ago)
- Branches:
- main
- Children:
- 3d882bd
- Parents:
- 69bd747
- File:
-
- 1 edited
-
test/guardianship.test.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
test/guardianship.test.js
r69bd747 r30d0e2c 187 187 ); 188 188 assert.deepEqual(G.listGuardians('zed'), []); 189 }); 190 191 test('an unreadable candidate defers the commit, and the window names that failure (§4.2)', async () => { 192 const offers = await import('../src/services/guardianship/offers.js'); 193 const noor = site('s16', 'noor'); 194 const NOOR = A('noor'); 195 const MARA = 'https://elders.example/users/mara'; // remote; fetchActor returns null here 196 const offerId = `${MARA}/offers/m1`; 197 198 // The Offer arrives and is STORED: unreachable is not malformed, and 199 // refusing on a failed fetch would let any outage block an adoption. 200 const taken = await G.handleGuardianshipInbox(noor, { 201 id: offerId, type: 'Offer', actor: MARA, to: [NOOR], 202 object: { type: 'Relationship', subject: NOOR, relationship: 'shaer:Guardian', object: MARA }, 203 }); 204 assert.equal(taken, true); 205 206 // Noor accepts. Free ward + candidate's own offer = the tally is complete, 207 // so this WOULD commit — except the candidate cannot be read. 208 const done = await G.handleGuardianshipOutbox(noor, { type: 'Accept', object: offerId }); 209 assert.equal(done.committed, false, 'not committed: nobody verified the candidate'); 210 assert.ok(!done.refused, 'and not refused either — that would blame a candidate nobody could look at'); 211 assert.deepEqual(G.listGuardians('noor'), []); 212 assert.equal(offers.getOffer('noor', offerId).status, 'pending', 'deferred, not decided'); 213 214 // A week later the §3.5 window closes and it fails closed — under its own 215 // name. Not 'void': the parties must not be told the candidate was refused. 216 const later = Date.now() + offers.OFFER_WINDOW_MS + 1000; 217 offers.expireIfDue('noor', offerId, later); 218 assert.equal(offers.getOffer('noor', offerId).status, 'unverified'); 219 220 const q = G.offersCollection(`${NOOR}/queues/offers`, 'noor', NOOR).orderedItems; 221 assert.deepEqual(q.filter((o) => o.id === offerId), [], 'and it stops looking like a live choice'); 222 }); 223 224 test('a handshake nobody finished expires under a different name (§3.5)', async () => { 225 const offers = await import('../src/services/guardianship/offers.js'); 226 const finn = site('s17', 'finn'); 227 const iris = site('s18', 'iris'); 228 const [FINN, IRIS] = [A('finn'), A('iris')]; 229 230 const off = await G.handleGuardianshipOutbox(finn, { 231 type: 'Offer', object: { type: 'Relationship', subject: IRIS, relationship: 'shaer:Guardian', object: FINN }, 232 }); 233 // Iris never answers. Reading the queue after the window settles it. 234 G.offersCollection(`${IRIS}/queues/offers`, 'iris', IRIS); // still open now 235 assert.equal(offers.getOffer('iris', off.id).status, 'pending'); 236 offers.listForParty('iris', IRIS, Date.now() + offers.OFFER_WINDOW_MS + 1000); 237 assert.equal(offers.getOffer('iris', off.id).status, 'expired', 238 'nobody answered — that says nothing about the candidate, so it is not "unverified"'); 189 239 }); 190 240
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)