// LOCAL TESTS ONLY (qa/sov-passes-local.mjs preloads it with `node -r`): seeds purchased-grade credits on one fake position so the // REAL ads.gamePurchase(purchasedOnly) path can be exercised without a chain. Refuses to load in production. // QA_SEED_EMAIL the account that owns the position (gets memberId QA_SEED_ID on its sessions) // QA_SEED_ID the fake position's member id // QA_SEED_CREDITS the on-chain credit balance that position reports 'use strict'; if (process.env.NODE_ENV === 'production') throw new Error('qa/sov-passes-stub.cjs must never load in production'); const path = require('path'); const SITE = path.resolve(__dirname, '..'); const chain = require(path.join(SITE, 'chain.js')); const auth = require(path.join(SITE, 'auth.js')); const EMAIL = String(process.env.QA_SEED_EMAIL || '').toLowerCase(), ID = Number(process.env.QA_SEED_ID) || 0, CREDITS = Number(process.env.QA_SEED_CREDITS) || 0; const origBal = chain.creditBalance; chain.creditBalance = async (id, type) => (ID && Number(id) === ID) ? CREDITS : origBal(id, type); const origMember = chain.member; chain.member = async id => (ID && Number(id) === ID) ? null : origMember(id); const origRefresh = auth.refreshMemberId; auth.refreshMemberId = async sess => (sess && EMAIL && String(sess.email || '').toLowerCase() === EMAIL) ? ID : origRefresh(sess); console.log('qa stub: position #' + ID + ' holds ' + CREDITS + ' purchased credits for ' + EMAIL);