LinkSpin Banner Spins in Viral Banner Blitz (Marty 2026-11-14: "make sure Viral Banner Blitz incorporates banner spins that could be pulled in just like downline banners"), the Downline Banners pattern. lsspins.js calls LinkSpin's /api/partner/bl/spins with { site: 'vbb' }, signed with NETWORK_SSO_SECRET (by wallet; the network username too for network-verified members). My Banners: "Use my LinkSpin Banner Spin" lists the member's 125x125 / 250x250 spins (GET /api/my/lsspins) and one tap posts one (POST /api/my/banners { spinId }): one credit, same credit + waiting rules, image + link from LinkSpin's signed answer only (https, same host), the image is the spin's rotating image and the link its click link, so clicks count in LinkSpin Reports under a Viral Banner Blitz source. /go/ fills {clickid}, {spot} (banner number) and {type} (loop or waiting). Splash: the loop's open places (one stays "post yours") and the empty waiting line show members' Banner Spins (SPIN tiles, refreshed every 10 minutes, one per member, none for a member with a banner on the page, no image twice, same picks for 2 minutes); they are never in the loop list, never shift it, cycle or earn, and a note says so. Admin status: lsSpins. LS_PARTNER_URL for the smoke stand-in. common.js?v=4, splash.js?v=3, my.js?v=3, vbb.css?v=5. Smoke 227/227 (35 new, stand-in LinkSpin), chain 29/29. Needs LinkSpin 5d630ec.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-14 10:07:41 -06:00
parent aee1ccc36a
commit d049c529ac
16 changed files with 306 additions and 29 deletions
+111 -1
View File
@@ -63,9 +63,29 @@ require('node:http').createServer(async (q, r) => { let b = ''; for await (const
else if (j.email && HUBMAIL.has(j.email)) return r.end(JSON.stringify({ person: { id: 'h_' + '9'.repeat(16), username: HUBMAIL.get(j.email), wallet: null, sponsor: null, blocked: false } }));
return r.end(JSON.stringify({ person: hubPerson(w) })); }
HUB.got.push({ route: q.url, body: JSON.parse(b) }); r.end(JSON.stringify({ id: 'p' + HUB.got.length })); }).listen(HUB_PORT, '127.0.0.1').unref();
// stand-in LinkSpin partner API (/api/partner/bl/spins, the Banner Spins call): checks the NETWORK_SSO_SECRET signature and
// site 'vbb', answers like LinkSpin (account by wallet, else by network username; 125x125 + 250x250 spins only). LSA: wallet ->
// { username, spins: [{ id, name, code, size, paused, banners }] }; LS.tamper(use) may change a "use" answer (bad size, bad host).
const LS = { calls: [], badSig: 0, tamper: null }; const LSA = new Map(); const LS_PORT = PORT + 4, LS_HOST = 'rubav-standin.com';
require('node:http').createServer(async (q, r) => { let b = ''; for await (const c of q) b += c;
r.setHeader('Content-Type', 'application/json');
const ts = String(q.headers['x-net-ts'] || ''), want = crypto.createHmac('sha256', SSO_SECRET).update('net.v1.' + ts + '\n' + b).digest('hex');
if (q.url !== '/api/partner/bl/spins' || q.headers['x-net-sig'] !== want || Math.abs(Date.now() - Number(ts)) > 300000) { LS.badSig++; r.statusCode = 401; return r.end('{"error":"unauthorized"}'); }
const j = JSON.parse(b || '{}'); LS.calls.push(j);
let a = LSA.get(j.wallet); if (a && a.byName) a = null;
if (!a && j.username) a = [...LSA.values()].find(x => x.byName && x.username === j.username);
if (!a) return r.end('{"account":false}');
const sp = a.spins.filter(x => j.site === 'vbb' ? ['125x125', '250x250'].includes(x.size) : x.size === '468x60');
const out = { account: true, username: a.username, host: LS_HOST, spins: sp };
if (j.spinId != null) {
const x = sp.find(y => y.id === j.spinId); if (!x) { r.statusCode = 404; return r.end('{"error":"No such 125x125 (or 250x250) Banner Spin on this LinkSpin account."}'); }
out.use = { spinId: x.id, name: x.name, size: x.size, img: 'https://' + LS_HOST + '/i/' + x.code + '.gif', link: 'https://' + LS_HOST + '/c/' + x.code + '?clickid={clickid}&placement={spot}&s1={type}', otherSource: !!x.otherSource };
if (LS.tamper) LS.tamper(out.use);
}
r.end(JSON.stringify(out)); }).listen(LS_PORT, '127.0.0.1').unref();
const ENV = Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: DATA, ADMIN_TOKEN: ADMIN, NODE_ENV: 'development', DOCSTORE_URL: '',
LOOP_SIZE: '5', VISITORS_PER_SHIFT: '3', VIEWS_PER_CYCLE: '150', VISIT_SECONDS: '2', VISITS_PER_IP_DAY: '2', LINK_PROBE: '0', NETWORK_LOOKUP_URL: 'http://127.0.0.1:' + (PORT + 1) + '/api/network/member',
NETWORK_SSO_SECRET: SSO_SECRET, IAP_URL: 'https://iap.invalid', LS_URL: 'https://ls.invalid',
NETWORK_SSO_SECRET: SSO_SECRET, IAP_URL: 'https://iap.invalid', LS_URL: 'https://ls.invalid', LS_PARTNER_URL: 'http://127.0.0.1:' + LS_PORT, LS_SPINS_FIRST_MS: '300', LS_SPINS_EVERY_MS: '700',
CONTRACT_ADDRESS: SHOP, CHAIN_RPC: 'http://127.0.0.1:' + CHAIN_PORT, KEEPER_KEY: KEEPER_PK, SHOP_START_BLOCK: '1', SHOP_CONFIRMATIONS: '0', SHOP_POLL_MS: '200',
HUB_ENABLED: '1', HUB_URL: 'http://127.0.0.1:' + HUB_PORT, HUB_SECRET, HUB_SITE: 'vbb', HUB_TICK_MS: '300', HUB_DOWN_MS: '400' });
const sleep = ms => new Promise(r => setTimeout(r, ms));
@@ -507,6 +527,96 @@ async function main() {
await browser.close();
} else console.log('13. page renders skipped (SKIP_UI or no Playwright at ' + PW + ')');
// ---- 14. LinkSpin Banner Spins: post one as a banner, and members' spins fill empty space (never loop banners) ----
console.log('14. LinkSpin Banner Spins (stand-in LinkSpin)');
{ // unit: the fill picks (Downline Banners dedupe: one per member, no member already on the page, no image twice)
const lsu = require(path.join(APP, 'lsspins.js'));
lsu.set([{ owner: '0xa', img: 'https://h.com/i/aaa.gif', link: 'https://h.com/c/aaa', owner_name: 'a' }, { owner: '0xb', img: 'https://h.com/i/bbb.gif', link: 'https://h.com/c/bbb' },
{ owner: '0xc', img: 'https://h.com/i/bbb.gif', link: 'https://h.com/c/bbb' }, { owner: '0xd', img: 'https://h.com/i/ddd.gif', link: 'https://h.com/c/ddd' }, { owner: '0xe', img: 'https://h.com/i/eee.gif', link: 'https://h.com/c/eee' }]);
let f = lsu.fill({ openPlaces: 2, queueSlots: 8, pageOwners: ['0xa'], pageImgs: ['https://h.com/i/eee.gif'] }); const all = f.loop.concat(f.queue);
ok(f.loop.length === 2 && all.length === 2 && all.every(t => t.t === 'spin') && !all.some(t => /aaa|eee/.test(t.img)) && new Set(all.map(t => t.img)).size === all.length,
'fill: a member on the page and an image on the page are left out, the same image never twice', all.map(t => t.img));
f = lsu.fill({ openPlaces: 1, queueSlots: 8, pageOwners: [], pageImgs: [] });
ok(f.loop.length === 1 && f.queue.length === 3, 'fill: open places first, the rest into the empty waiting line (4 different images)', [f.loop.length, f.queue.length]);
ok(lsu.fill({ openPlaces: 0, queueSlots: 0, pageOwners: [], pageImgs: [] }).loop.length === 0, 'fill: no gap, no fill');
}
const SP1 = await walletMember(); await SP1.json('/api/my');
LSA.set(SP1.address, { username: 'spinner1', spins: [{ id: 11, name: 'Main spin', code: 'qk7spin1', size: '125x125', paused: false, banners: 2 }, { id: 12, name: 'Sharp spin', code: 'qk7spin2', size: '250x250', paused: false, banners: 1 },
{ id: 13, name: 'Wide spin', code: 'qk7wide1', size: '468x60', paused: false, banners: 3 }, { id: 14, name: 'Resting', code: 'qk7rest1', size: '125x125', paused: true, banners: 1 }] });
let ls = await SP1.json('/api/my/lsspins');
ok(ls._status === 200 && ls.account && ls.spins.length === 3 && ls.spins.every(x => ['125x125', '250x250'].includes(x.size)) && !JSON.stringify(ls).includes('qk7'), 'My Banners lists the 125x125 + 250x250 spins only (no codes sent to the browser)', ls);
ok(LS.badSig === 0 && LS.calls.length > 0 && LS.calls.every(c => c.site === 'vbb'), 'LinkSpin calls are signed with NETWORK_SSO_SECRET and say site vbb', { bad: LS.badSig, n: LS.calls.length });
const anonLs = await anon.json('/api/my/lsspins'); ok(anonLs._status === 401, 'the spin list needs a sign-in');
const NOLS = await walletMember(); await NOLS.json('/api/my'); ls = await NOLS.json('/api/my/lsspins');
ok(ls._status === 200 && ls.account === false, 'no LinkSpin account for this wallet: account false', ls);
const nc = LS.calls.filter(c => c.wallet === NOLS.address).slice(-1)[0] || {}; ok(nc.username && /^net[0-9a-f]{8}$/.test(nc.username), 'a network-verified member is also looked up by network username', nc);
// username fallback: LinkSpin knows this member by network username, not by this wallet
const UN = await walletMember(); await UN.json('/api/my'); LSA.set('0x' + 'f'.repeat(40), { username: 'net' + UN.address.slice(2, 10), byName: true, spins: [{ id: 31, name: 'By name', code: 'qk7name1', size: '125x125', paused: false, banners: 0 }] });
ls = await UN.json('/api/my/lsspins'); ok(ls.account === true && ls.spins.length === 1, 'LinkSpin finds the account by network username when no account holds the wallet', ls);
const STR = await walletMember({ stranger: true }); await STR.json('/api/my'); await STR.json('/api/my/lsspins');
const sc = LS.calls.filter(c => c.wallet === STR.address); ok(sc.length > 0 && sc.every(c => !c.username), 'a member the network does not know is looked up by wallet only', sc.slice(-1));
// posting a spin: one credit, image + link from LinkSpin, straight into the loop / the line like any banner
let cr0 = (await SP1.json('/api/my')).credits;
let ps = await SP1.json('/api/my/banners', { spinId: 13 }); ok(ps._status === 400 && /125x125/.test(ps.error), 'a 468x60 spin cannot be posted', ps);
ps = await SP1.json('/api/my/banners', { spinId: 99 }); ok(ps._status === 400 && /No such/.test(ps.error), 'an unknown spin is refused with LinkSpin\'s reason', ps);
LS.tamper = u => { u.size = '468x60'; }; ps = await SP1.json('/api/my/banners', { spinId: 11 }); ok(ps._status === 400 && /125x125/.test(ps.error), 'a wrong size in LinkSpin\'s answer is refused', ps);
LS.tamper = u => { u.img = 'https://elsewhere-images.com/x.gif'; }; ps = await SP1.json('/api/my/banners', { spinId: 11 }); ok(ps._status === 400, 'an image on another host than the spin link is refused', ps);
LS.tamper = u => { u.link = 'http://' + LS_HOST + '/c/x'; }; ps = await SP1.json('/api/my/banners', { spinId: 11 }); ok(ps._status === 400, 'a plain http spin link is refused', ps);
LS.tamper = null;
ok((await SP1.json('/api/my')).credits === cr0, 'refused spin posts use no credit', cr0);
ps = await SP1.json('/api/my/banners', { spinId: 11, img: 'https://evil-images.com/x.png', link: 'https://evil-target.com/' });
ok(ps.ok && ps.credits === cr0 - 1, 'posting a spin uses one credit', ps);
my = await SP1.json('/api/my'); const sb = my.banners.find(x => x.id === ps.banner.id);
ok(sb && sb.img === 'https://' + LS_HOST + '/i/qk7spin1.gif' && sb.link.startsWith('https://' + LS_HOST + '/c/qk7spin1?') && sb.spin && sb.spin.name === 'Main spin', 'the banner is the spin: its rotating image + click link (never what the browser sent)', sb);
ps = await SP1.json('/api/my/banners', { spinId: 12 }); ok(ps._status === 400 && /no post credits/i.test(ps.error), 'no credits left: a spin post is refused too', ps);
r = await anon.req('/go/' + sb.id); const gl = new URL(r.headers.get('location') || 'https://x/');
ok(r.status === 302 && gl.hostname === LS_HOST && /^[0-9a-f]{16}$/.test(gl.searchParams.get('clickid') || '') && gl.searchParams.get('placement') === String(sb.id) && ['loop', 'waiting'].includes(gl.searchParams.get('s1')),
'a click goes through the spin link with {clickid}, {spot} and {type} filled (counts in LinkSpin Reports)', r.headers.get('location'));
// fill: a bigger loop (restart with 40 places) leaves open places and nobody waiting
const SP2 = await walletMember(), SP3 = await walletMember(), SP4 = await walletMember(), SP5 = await walletMember();
for (const m of [SP2, SP3, SP4, SP5]) await m.json('/api/my');
LSA.set(SP2.address, { username: 'spinner2', spins: [{ id: 21, name: 'Two', code: 'qk7fill2', size: '125x125', paused: false, banners: 1 }] });
LSA.set(SP3.address, { username: 'spinner3', spins: [{ id: 22, name: 'Three', code: 'qk7fill2', size: '125x125', paused: false, banners: 1 }] }); // same image as SP2
LSA.set(SP4.address, { username: 'spinner4', spins: [{ id: 23, name: 'Four', code: 'qk7fill4', size: '250x250', paused: false, banners: 2 }] });
LSA.set(SP5.address, { username: 'spinner5', spins: [{ id: 24, name: 'Paused', code: 'qk7fill5', size: '125x125', paused: true, banners: 1 }] });
const loopBefore = (await anon.json('/api/admin/status', undefined, { 'x-admin-token': ADMIN }));
await sleep(1200); ENV.LOOP_SIZE = '40'; await stop(); await boot(); await sleep(1600);
sp = await anon.json('/api/splash'); const fl = (sp.fill || { loop: [], queue: [] }); const fall = fl.loop.concat(fl.queue);
ok(sp.loop.length < 39 && sp.waiting === 0, 'restart with 40 places: open places, nobody waiting', { loop: sp.loop.length, waiting: sp.waiting });
ok(fall.length === 2 && fall.every(t => t.t === 'spin' && t.img.includes(LS_HOST)) && fall.some(t => t.img.includes('qk7fill4')) && fall.some(t => t.img.includes('qk7fill2')),
'the gaps show members\' spins: one per image (SP2 and SP3 share one), none paused, none for a member with a banner on the page', fall.map(t => t.img + ' ' + t.owner));
ok(!fall.some(t => t.img.includes('qk7spin1')), 'SP1 has a banner in the loop, so no fill tile for SP1');
ok(fl.loop.length === 2 && fl.queue.length === 0, 'open loop places are filled first', [fl.loop.length, fl.queue.length]);
ok(fall.every(t => /\/c\/qk7fill\d\?placement=fill&s1=fill$/.test(t.href)), 'a fill tile clicks straight through the spin link (placement=fill)', fall.map(t => t.href));
ok(!sp.loop.some(t => fall.some(f => f.img === t.img)), 'fill tiles are not in the loop list');
let st0 = await anon.json('/api/admin/status', undefined, { 'x-admin-token': ADMIN });
ok(st0.loop.filled === sp.loop.length && st0.totals.cycles === loopBefore.totals.cycles && st0.lsSpins && st0.lsSpins.fill >= 2, 'fill never changes the loop, its size or the cycles; admin status counts the fill spins', { filled: st0.loop.filled, cyc: [loopBefore.totals.cycles, st0.totals.cycles], ls: st0.lsSpins });
const sp2 = await anon.json('/api/splash'); ok(JSON.stringify(sp2.fill) === JSON.stringify(sp.fill), 'the same fill on the next poll (no reshuffle every 8 seconds)');
if (!process.env.SKIP_UI && fs.existsSync(PW)) {
const { chromium } = require(PW); const browser = await chromium.launch(); const errs = [];
const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 }, userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/130.0 Safari/537.36 SmokeUI-spin' });
await ctx.route('https://' + LS_HOST + '/**', rt => rt.fulfill({ status: 200, contentType: 'image/png', body: png(125, 125, 4) })); // nothing leaves this machine
const pg = await ctx.newPage(); pg.on('pageerror', e => errs.push(e.message));
await pg.goto(BASE + '/', { waitUntil: 'domcontentloaded' }); await pg.waitForSelector('#loop .tile.fill', { timeout: 8000 }).catch(() => {});
const ft = await pg.$$eval('#loop .tile.fill', els => els.map(e => [e.querySelector('.pos') && e.querySelector('.pos').textContent, e.getAttribute('href')]));
ok(ft.length === 2 && ft.every(x => x[0] === 'SPIN' && x[1].includes(LS_HOST)), 'splash: open places show SPIN tiles', ft);
ok(await pg.isVisible('#fillNote') && /never shift it, never cycle and never earn/.test(await pg.textContent('#fillNote')), 'splash: the note says spins are not loop banners');
ok((await pg.$$eval('#loop .tile.open', els => els.length)) >= 1 && (await pg.textContent('#loop .tile.open')).includes('post yours'), 'splash: an open place still says "post yours"');
await pg.screenshot({ path: path.join(OUT, 'splash-spins.png'), fullPage: true });
await ctx.addCookies([{ name: 'vbb.sid', value: SP4.jar['vbb.sid'], url: BASE }]);
await pg.goto(BASE + '/my', { waitUntil: 'domcontentloaded' }); await pg.waitForSelector('#dash:not([hidden])', { timeout: 8000 });
await pg.click('#lsBtn'); await pg.waitForSelector('#lsPick button[data-spin]', { timeout: 8000 }).catch(() => {});
const bts = await pg.$$eval('#lsPick button[data-spin]', els => els.map(e => e.textContent));
ok(bts.length === 1 && /Four \(250x250, 2 images\)/.test(bts[0]), 'My Banners: "Use my LinkSpin Banner Spin" lists the spin', bts);
await pg.screenshot({ path: path.join(OUT, 'my-spins.png'), fullPage: true });
await pg.click('#lsPick button[data-spin]'); await pg.waitForFunction(() => /Posted\. Your Banner Spin/.test(document.body.textContent), null, { timeout: 8000 }).catch(() => {});
ok(/Posted\. Your Banner Spin went straight into the loop/.test(await pg.textContent('body')), 'My Banners: one tap posts the spin into the loop');
await pg.waitForSelector('.pill.spin', { timeout: 8000 }).catch(() => {});
ok(/LinkSpin Banner Spin: Four/.test(await pg.textContent('#mine')), 'My Banners: the banner shows as a Banner Spin');
ok(errs.length === 0, 'no page errors (spins)', errs);
await browser.close();
}
await stop();
console.log('\n' + pass + ' passed, ' + fail + ' failed');
fs.writeFileSync(path.join(OUT, 'smoke.txt'), new Date().toISOString() + ' ' + pass + ' passed, ' + fail + ' failed\n');