Find a Member: public lookup at /lookup (Marty 2026-11-14)
One box: member ID or wallet address -> member ID, wallet (short, full on hover + Copy), level and tier, join date, sponsor ID (clickable), direct referral count, Polygonscan link, public dashboard link. Chain facts only, never names or emails. RM Circle only; nothing from any other site. - chain.lookupPublic: served from the indexed state (zero RPC); only a position or wallet the index has not seen yet falls back to one eth_call (memberId(address) 0x39106821, verified live: 0x7c7D...d3c2 -> 7230) - /api/public/lookup: own 12/min per-IP limiter, 3-minute answer cache (negative answers too), global budget of 60 RPC fallbacks per minute - page lookup.html + lookup.js (no inline script), ?q= deep links, /find alias - "Find a Member" in every site footer; chat.js?v=20261114a - chatbot: canned answer in chat.js + FACT line and Site pages entry in the AI system prompt - tests: qa/lookup-unit.mjs (25), qa/lookup-e2e.mjs (51, desktop + phone, CSP, no-email, rate limit) against qa/harness-server.js LOOKUP_SEED Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
{"v":2,"lastBlock":1,"snapshotAt":1,"updatedAt":"2026-11-14T12:00:00.000Z","payouts":[],"totals":{"count":0,"pol":0},
|
||||
"members":{
|
||||
"1":{"account":"0x95f38dc55efe1c0f9aab6218e7bf42cb18235a45","referrerId":0,"uplineId":1,"tier":2,"level":8,"directCount":2,"joinedAt":1754000000},
|
||||
"21":{"account":"0x1111111111111111111111111111111111111121","referrerId":1,"uplineId":1,"tier":2,"level":5,"directCount":2,"joinedAt":1754500000,"email":"never-shown@example.com"},
|
||||
"7230":{"account":"0x7c7d9f0f11bbc66a700245795c374971bfbed3c2","referrerId":21,"uplineId":21,"tier":2,"level":1,"directCount":1,"joinedAt":1762900000},
|
||||
"7231":{"account":"0x2222222222222222222222222222222222227231","referrerId":7230,"uplineId":7230,"tier":1,"level":1,"directCount":0,"joinedAt":1762990000,"preIndexed":true}
|
||||
}}
|
||||
@@ -38,5 +38,16 @@ chain.getOrgRouting = async function () { return null; };
|
||||
chain.getOrgShare = async function () { return null; };
|
||||
chain.nextOpenPosition = function () { return 21; };
|
||||
|
||||
// LOOKUP_SEED=<file.json>: seed the in-memory index for the /lookup suite, and keep the
|
||||
// lookup offline (a miss reports not-found instead of reaching a real Polygon RPC).
|
||||
if (process.env.LOOKUP_SEED) {
|
||||
chain.__test.setState(JSON.parse(require('fs').readFileSync(process.env.LOOKUP_SEED, 'utf8')));
|
||||
const realLookup = chain.lookupPublic;
|
||||
chain.lookupPublic = async function (raw) {
|
||||
const r = await realLookup(raw, { allowRpc: false });
|
||||
if (r && r.busy) { global.__lookupRpcFallbacks = (global.__lookupRpcFallbacks || 0) + 1; return { found: false, query: r.query }; }
|
||||
return r;
|
||||
};
|
||||
}
|
||||
console.log('harness: addr=' + ADDR + ' id=' + ID + ' coldIndex=' + COLD);
|
||||
require('../server.js');
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
// Find a member (/lookup) end to end: the real server + the real page, index seeded,
|
||||
// no RPC. Start the harness first, in its own throwaway data dir (seed config only,
|
||||
// never the live config):
|
||||
//
|
||||
// L=/d/tmp/rmc-lookup-e2e && rm -rf $L && mkdir -p $L && echo '[]' > $L/sponsors.json
|
||||
// LOOKUP_SEED=qa/fixtures/lookup-index.json PORT=3405 DATA_DIR=$L ADMIN_PASSWORD=localtest node qa/harness-server.js &
|
||||
// LOCAL=http://127.0.0.1:3405 node qa/lookup-e2e.mjs
|
||||
//
|
||||
// The rate-limit check runs last because it uses up this IP's lookups for a minute.
|
||||
import { pathToFileURL } from 'node:url';
|
||||
const PW = 'D:/Projects/MarketingAgent/qa-tester/node_modules/playwright';
|
||||
const { chromium } = (await import(pathToFileURL(PW + '/index.js').href)).default;
|
||||
const B = process.env.LOCAL || 'http://127.0.0.1:3405';
|
||||
const ok = [], bad = [];
|
||||
const t = (n, c, extra) => { (c ? ok : bad).push(n + (c || !extra ? '' : ' -> ' + extra)); };
|
||||
let ipN = Math.floor(Math.random() * 150 + 20);
|
||||
const freshIp = () => ({ 'x-forwarded-for': '203.0.113.' + (ipN++) }); // each context its own IP, so the 12/min limiter only bites in its own test
|
||||
const XFF = freshIp();
|
||||
const api = async (q, h = XFF) => { const r = await fetch(B + '/api/public/lookup?q=' + encodeURIComponent(q), { headers: h }); return { s: r.status, j: await r.json().catch(() => ({})) }; };
|
||||
|
||||
// --- API
|
||||
let r = await api('7230');
|
||||
t('API: #7230 found', r.s === 200 && r.j.found && r.j.id === 7230, JSON.stringify(r));
|
||||
t('API: only chain fields come back', Object.keys(r.j).sort().join(',') === 'account,directCount,found,id,joinedAt,level,levelName,source,sponsorId,tier,tierName', Object.keys(r.j).join(','));
|
||||
r = await api('0x7c7D9F0F11bbc66a700245795c374971BfBed3c2');
|
||||
t('API: wallet resolves to #7230', r.s === 200 && r.j.id === 7230);
|
||||
r = await api('21');
|
||||
t('API: #21 never leaks an email from the index', r.s === 200 && !JSON.stringify(r.j).includes('example.com'));
|
||||
r = await api('banana');
|
||||
t('API: free text is a 400 with a clear message', r.s === 400 && /member ID/.test(r.j.error || ''));
|
||||
r = await api('0x123');
|
||||
t('API: short wallet is a 400', r.s === 400);
|
||||
r = await api('99999');
|
||||
t('API: unknown id is found:false', r.s === 200 && r.j.found === false);
|
||||
|
||||
// --- page
|
||||
const browser = await chromium.launch();
|
||||
for (const mobile of [false, true]) {
|
||||
const tag = mobile ? '[phone] ' : '';
|
||||
const ctx = await browser.newContext(mobile ? { viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true, extraHTTPHeaders: freshIp() } : { viewport: { width: 1280, height: 900 }, extraHTTPHeaders: freshIp() });
|
||||
await ctx.addInitScript(() => {
|
||||
const g = Storage.prototype.getItem;
|
||||
Storage.prototype.getItem = function (k) { if (/^rmc-promo-/.test(k)) return 'seen'; if (/^rmc-announce-/.test(k)) return 'done'; return g.call(this, k); };
|
||||
});
|
||||
const page = await ctx.newPage();
|
||||
const csp = [];
|
||||
page.on('console', m => { if (/Refused to|Content Security Policy/i.test(m.text())) csp.push(m.text()); });
|
||||
page.on('pageerror', e => csp.push('pageerror: ' + e.message));
|
||||
const resp = await page.goto(B + '/lookup', { waitUntil: 'networkidle' });
|
||||
t(tag + '/lookup is 200', resp.status() === 200);
|
||||
await page.fill('#lkQ', '0x7c7D9F0F11bbc66a700245795c374971BfBed3c2');
|
||||
await page.click('#lkGo');
|
||||
await page.waitForSelector('#lkRes:not(.hidden)', { timeout: 8000 });
|
||||
t(tag + 'wallet search shows #7230', (await page.textContent('#rId')) === '#7230');
|
||||
t(tag + 'wallet is shortened', (await page.textContent('#rWallet')) === '0x7c7d...d3c2', await page.textContent('#rWallet'));
|
||||
t(tag + 'full wallet on hover', (await page.getAttribute('#rWallet', 'title')) === '0x7c7d9f0f11bbc66a700245795c374971bfbed3c2');
|
||||
t(tag + 'level + tier', /Scintilla/.test(await page.textContent('#rLevel')) && (await page.textContent('#rTier')) === 'Premium');
|
||||
t(tag + 'join date shown', /2025/.test(await page.textContent('#rJoined')), await page.textContent('#rJoined'));
|
||||
t(tag + 'direct referrals', (await page.textContent('#rDirects')) === '1');
|
||||
t(tag + 'building badge', /1\/2/.test(await page.textContent('#rQual')));
|
||||
t(tag + 'Polygonscan link', (await page.getAttribute('#rScan', 'href')) === 'https://polygonscan.com/address/0x7c7d9f0f11bbc66a700245795c374971bfbed3c2');
|
||||
t(tag + 'URL carries the query', /\/lookup\?q=0x7c7D/i.test(page.url()));
|
||||
await page.click('#rSponsor button');
|
||||
await page.waitForFunction(() => document.getElementById('rId').textContent === '#21', null, { timeout: 8000 });
|
||||
t(tag + 'clicking the sponsor looks up #21', true);
|
||||
t(tag + '#21 shows Qualified', (await page.textContent('#rQual')) === 'Qualified');
|
||||
t(tag + '#21 sponsor is #1', (await page.textContent('#rSponsor')) === '#1');
|
||||
await page.goBack();
|
||||
await page.waitForFunction(() => document.getElementById('rId').textContent === '#7230', null, { timeout: 8000 });
|
||||
t(tag + 'Back returns to #7230', true);
|
||||
await page.fill('#lkQ', 'not a wallet');
|
||||
await page.click('#lkGo');
|
||||
t(tag + 'bad input shows an inline error', /does not look right/.test(await page.textContent('#lkMsg')));
|
||||
await page.fill('#lkQ', '99999');
|
||||
await page.click('#lkGo');
|
||||
await page.waitForFunction(() => /no member #99999/.test(document.getElementById('lkMsg').textContent), null, { timeout: 8000 });
|
||||
t(tag + 'unknown id says so and hides the card', await page.isHidden('#lkRes'));
|
||||
const body = await page.textContent('body');
|
||||
t(tag + 'no email anywhere on the page', !/@example\.com/.test(body));
|
||||
t(tag + 'no InstantAdPay/LinkSpin mention', !/InstantAdPay|LinkSpin|Downline Banners|Viral Banner/i.test(body));
|
||||
const overflow = await page.evaluate(() => document.documentElement.scrollWidth > window.innerWidth + 1);
|
||||
t(tag + 'no horizontal scroll', !overflow);
|
||||
t(tag + 'no CSP refusals or page errors', csp.length === 0, csp.join(' | '));
|
||||
await ctx.close();
|
||||
}
|
||||
// deep link
|
||||
{
|
||||
const ctx = await browser.newContext({ extraHTTPHeaders: freshIp() }); const page = await ctx.newPage();
|
||||
await page.goto(B + '/lookup?q=21', { waitUntil: 'networkidle' });
|
||||
await page.waitForSelector('#lkRes:not(.hidden)', { timeout: 8000 });
|
||||
t('deep link /lookup?q=21 opens #21', (await page.textContent('#rId')) === '#21');
|
||||
const f = await (await fetch(B + '/find')).status;
|
||||
t('/find alias is 200', f === 200);
|
||||
const foot = await (await fetch(B + '/contract')).text();
|
||||
t('footer on other pages links /lookup', foot.includes('href="/lookup"'));
|
||||
await ctx.close();
|
||||
}
|
||||
await browser.close();
|
||||
|
||||
// --- rate limit (last)
|
||||
const H = { 'x-forwarded-for': '198.51.100.77' };
|
||||
let codes = [];
|
||||
for (let i = 0; i < 14; i++) codes.push((await api('21', H)).s);
|
||||
t('rate limit: 12 per minute then 429', codes.slice(0, 12).every(c => c === 200) && codes[12] === 429 && codes[13] === 429, codes.join(','));
|
||||
|
||||
console.log(ok.map(x => 'ok ' + x).join('\n'));
|
||||
if (bad.length) { console.log(bad.map(x => 'FAIL ' + x).join('\n')); process.exit(1); }
|
||||
console.log(`\n${ok.length} passed`);
|
||||
@@ -0,0 +1,62 @@
|
||||
// Find a member (/lookup): chain.lookupPublic against a seeded index, no RPC.
|
||||
// node qa/lookup-unit.mjs
|
||||
import { createRequire } from 'node:module';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
const require = createRequire(import.meta.url);
|
||||
const here = path.dirname(fileURLToPath(import.meta.url));
|
||||
const chain = require('../chain.js');
|
||||
chain.__test.setState(JSON.parse(fs.readFileSync(path.join(here, 'fixtures', 'lookup-index.json'), 'utf8')));
|
||||
|
||||
const ok = [], bad = [];
|
||||
const t = (n, c, extra) => { (c ? ok : bad).push(n + (c || !extra ? '' : ' -> ' + extra)); };
|
||||
const off = { allowRpc: false };
|
||||
|
||||
// input validation
|
||||
const P = chain.parseLookupQuery;
|
||||
t('a plain number is an id', P('21').kind === 'id' && P('21').id === 21);
|
||||
t('a #-prefixed number is an id', P('#7230').id === 7230);
|
||||
t('whitespace is trimmed', P(' 21 ').id === 21);
|
||||
t('zero is refused', !!P('0').error);
|
||||
t('a 16-digit number is refused', !!P('1234567890123456').error);
|
||||
t('a full address is an address, lowercased', P('0x7c7D9F0F11bbc66a700245795c374971BfBed3c2').address === '0x7c7d9f0f11bbc66a700245795c374971bfbed3c2');
|
||||
t('a short address is refused', !!P('0x7c7D9F0F11bbc66a').error);
|
||||
t('non-hex address is refused', !!P('0xZZ7D9F0F11bbc66a700245795c374971BfBed3c2').error);
|
||||
t('free text is refused', !!P('marty').error);
|
||||
t('script text is refused', !!P('<script>alert(1)</script>').error);
|
||||
t('empty is refused', !!P('').error);
|
||||
|
||||
// by id, from the index
|
||||
const a = await chain.lookupPublic('7230', off);
|
||||
t('#7230 is found from the index', a.found && a.source === 'index', JSON.stringify(a));
|
||||
t('#7230 wallet is lowercased', a.account === '0x7c7d9f0f11bbc66a700245795c374971bfbed3c2');
|
||||
t('#7230 sponsor is #21', a.sponsorId === 21);
|
||||
t('#7230 level/tier names', a.levelName === 'Scintilla' && a.tierName === 'Premium' && a.level === 1);
|
||||
t('#7230 direct count', a.directCount === 1);
|
||||
t('#7230 join time', a.joinedAt === 1762900000);
|
||||
|
||||
// by wallet, mixed case, from the index
|
||||
const b = await chain.lookupPublic('0x7C7D9F0F11BBC66A700245795C374971BFBED3C2', off);
|
||||
t('wallet lookup resolves to #7230 with no RPC', b.found && b.id === 7230 && b.source === 'index', JSON.stringify(b));
|
||||
|
||||
const c = await chain.lookupPublic('21', off);
|
||||
t('#21 is Apex, qualified, sponsored by root', c.levelName === 'Apex' && c.directCount === 2 && c.sponsorId === 1);
|
||||
t('never copies unknown index fields (no email)', !('email' in c) && !JSON.stringify(c).includes('example.com'));
|
||||
|
||||
const r = await chain.lookupPublic('1', off);
|
||||
t('the root shows no sponsor', r.found && r.sponsorId === null);
|
||||
|
||||
// misses never call RPC when RPC is not allowed
|
||||
const m1 = await chain.lookupPublic('99999', off);
|
||||
t('an unknown id reports busy (needs a chain read)', m1.busy === true && !m1.found);
|
||||
const m2 = await chain.lookupPublic('0x3333333333333333333333333333333333333333', off);
|
||||
t('an unknown wallet reports busy (needs a chain read)', m2.busy === true && !m2.found);
|
||||
const m3 = await chain.lookupPublic('7231', off);
|
||||
t('a provisional (preIndexed) entry is re-read from the chain, not trusted', m3.busy === true);
|
||||
const e = await chain.lookupPublic('hello', off);
|
||||
t('bad input returns an error, not a lookup', !!e.error);
|
||||
|
||||
console.log(ok.map(x => 'ok ' + x).join('\n'));
|
||||
if (bad.length) { console.log(bad.map(x => 'FAIL ' + x).join('\n')); process.exit(1); }
|
||||
console.log(`\n${ok.length} passed`);
|
||||
Reference in New Issue
Block a user