// Hybrid-Chain offline teaching model: crypto-payments-gateway // Fictional fields/states; NOT an API client, authorization system or production implementation. // No network calls, credentials, payments or file writes. Review before running. // Requires Node.js 22+. Run: node --test crypto-payments-gateway.mjs import test from 'node:test'; import assert from 'node:assert/strict'; export function inspect(record) { if (!record.notificationVerified) return 'REJECT_NOTIFICATION'; if (record.fulfilled) return 'ALREADY_FULFILLED'; if (record.authoritativeState !== 'paid') return 'WAIT_FOR_PAYMENT'; return 'READY_FOR_FULFILLMENT_REVIEW'; } const baseline = { "notificationVerified": true, "authoritativeState": "paid", "fulfilled": false }; const cases = [ { "name": "payment ready for delivery review", "patch": {}, "expected": "READY_FOR_FULFILLMENT_REVIEW" }, { "name": "invalid callback", "patch": { "notificationVerified": false }, "expected": "REJECT_NOTIFICATION" }, { "name": "pending payment", "patch": { "authoritativeState": "pending" }, "expected": "WAIT_FOR_PAYMENT" }, { "name": "repeated paid notification", "patch": { "fulfilled": true }, "expected": "ALREADY_FULFILLED" } ]; for (const example of cases) { test(example.name, () => { assert.equal(inspect({...baseline, ...example.patch}), example.expected); }); }