// Engine Room on LinkSpin: engine.js, kit.js, admin-kits.js and engine-room.js are the SAME files as InstantAdPay's. // This checks they have not drifted, then runs InstantAdPay's engine test (it covers build() and the LinkSpin facts). // Run: node qa/refuel-engine.test.cjs 'use strict'; const fs = require('fs'); const path = require('path'); const { spawnSync } = require('child_process'); const ROOT = path.join(__dirname, '..'); const IAP = path.join(ROOT, '..', '..', 'onchain-ad-membership', 'site'); if (!fs.existsSync(path.join(IAP, 'engine.js'))) { console.log('skip: InstantAdPay repo not beside this one'); process.exit(0); } let fails = 0; for (const f of ['engine.js', 'kit.js', 'public/assets/admin-kits.js', 'public/assets/engine-room.js']) { const same = fs.readFileSync(path.join(ROOT, f)).equals(fs.readFileSync(path.join(IAP, f))); console.log((same ? 'ok ' : 'FAIL ') + f + (same ? ' matches InstantAdPay' : ' differs from InstantAdPay: copy the newer one across')); if (!same) fails++; } const r = spawnSync(process.execPath, [path.join(IAP, 'qa', 'refuel-engine.test.cjs')], { encoding: 'utf8' }); process.stdout.write(r.stdout || ''); if (r.status !== 0) fails++; process.exit(fails ? 1 : 0);