Reward tiers off by default (flat $0.25 at launch); hub-blocked sponsors are skipped (pass-up)

- config: REWARD_TIERS defaults to none (the every-25th $2.50 tier stays available as a setting); the "bigger tiers" sentence only
  shows when a tier is configured.
- hubline: the walk reads the raw hub answer so it continues past a blocked sponsor instead of stopping; entries carry `blocked`.
  /api/my/order skips blocked members like no-wallet ones, so the level passes up.
- e2e: B -> no-wallet -> hub-blocked (with a wallet) -> O -> S: both skipped, O and S each get 10%, the blocked one gets nothing;
  tiers off checked. 63/63. Chatbot QA 108/108.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-17 05:23:56 -06:00
parent 608ec6547b
commit a3f3f10fb8
9 changed files with 30 additions and 18 deletions
+11 -5
View File
@@ -6,7 +6,8 @@
// the family tree sums it up; sign-ups through R2's link: a clean one passes every check (pending reward + keeper voucher),
// a throwaway email is rejected, R2's own device is rejected, someone already in the network is rejected;
// B arrives through R1's link and buys a Boost: the contract pays R1 the resharer cut, the pot, the company, to the wei, and the
// sponsor levels with no Boost needed: B's hub line is B -> X (no wallet, not eligible) -> O -> S, so X is skipped (compression)
// sponsor levels with no Boost needed: B's hub line is B -> X (no wallet) -> BL (hub-blocked, has a wallet) -> O -> S, so X and BL
// are skipped (compression)
// and O gets level 1, S level 2; levels 3..5 have nobody and go to the company;
// rewards relay (payouts ON in this test only): claimReward pays R2 from the pot; a replay is refused by the contract;
// the staging test switch works on a staging host and is refused on the real domain.
@@ -46,7 +47,7 @@ http.createServer(async (q, r) => {
const all = [...people.entries()];
const w = j.wallet ? String(j.wallet).toLowerCase() : j.id ? (all.find(([, p]) => p.id === j.id) || [])[0] : j.ref ? (all.find(([a, p]) => a === String(j.ref).toLowerCase() || p.username === String(j.ref).toLowerCase()) || [])[0] : null;
const p = w && people.get(w); const sp = p && p.sponsor && people.get(p.sponsor);
r.end(JSON.stringify({ person: p ? { id: p.id, username: p.username, wallet: p.noWallet ? null : w, blocked: false, sponsor: sp ? { id: sp.id, username: sp.username } : null } : null }));
r.end(JSON.stringify({ person: p ? { id: p.id, username: p.username, wallet: p.noWallet ? null : w, blocked: !!p.blocked, sponsor: sp ? { id: sp.id, username: sp.username } : null } : null }));
}).listen(HPORT, '127.0.0.1').unref();
// a browser: its own cookie jar and user agent (so its own visitor key)
@@ -82,7 +83,9 @@ async function main() {
people.set(lc(O), { id: 'h_' + '0'.repeat(16), username: 'owner', sponsor: lc(S) });
people.set(lc(R1), { id: 'h_' + '1'.repeat(16), username: 'reshareone', sponsor: lc(S) });
people.set(lc(R2), { id: 'h_' + '2'.repeat(16), username: 'resharetwo', sponsor: lc(R1) });
people.set('x-no-wallet', { id: 'h_' + 'c'.repeat(16), username: 'nowallet', sponsor: lc(O), noWallet: true }); // a hub member with no linked wallet
const BL = ethers.Wallet.createRandom().address.toLowerCase(); // a hub-blocked member WITH a wallet
people.set(BL, { id: 'h_' + 'd'.repeat(16), username: 'blockedone', sponsor: lc(O), blocked: true });
people.set('x-no-wallet', { id: 'h_' + 'c'.repeat(16), username: 'nowallet', sponsor: BL, noWallet: true }); // a hub member with no linked wallet
people.set(lc(B), { id: 'h_' + 'b'.repeat(16), username: 'buyerb', sponsor: 'x-no-wallet' });
const art = n => JSON.parse(fs.readFileSync(path.join(ART, n + '.sol', n + '.json'), 'utf8'));
@@ -166,17 +169,20 @@ async function main() {
const y = (await admin('/api/admin/signups')).signups.find(z => z.email === e); ok(y.status === 'rejected' && y.fail.includes(want), 'rejected: ' + want, y);
}
{ const cfgJ = await (await fetch(BASE + '/api/config')).json(); const tierRows = (await admin('/api/admin/rewards')).rewards.filter(x => x.kind === 'tier');
ok(Array.isArray(cfgJ.reward.tiers) && cfgJ.reward.tiers.length === 0 && tierRows.length === 0, 'reward tiers are off by default (flat $0.25 only)', cfgJ.reward); }
console.log('\n-- Boost through R1\'s branch, to the wei');
await cB.post('/api/my/ad', { headline: 'Buyer ad for testing here', line1: 'A line about it', link: 'https://example.org/b' });
await cB.get('/s/' + s1.j.code); // B came through R1's reshare link
const od = await cB.post('/api/my/order', { qty: 1 }); ok(od.j.to === CA && od.j.resharer === lc(R1) && od.j.line === 2 && od.j.resharerName === 'reshareone', 'signed order names R1 and the 2-wallet line (the no-wallet member is skipped)', od.j);
const od = await cB.post('/api/my/order', { qty: 1 }); ok(od.j.to === CA && od.j.resharer === lc(R1) && od.j.line === 2 && od.j.resharerName === 'reshareone', 'signed order names R1 and the 2-wallet line (the no-wallet and the blocked member are skipped)', od.j);
const rc = await (await B.sendTransaction({ to: od.j.to, data: od.j.data, value: od.j.value })).wait();
const bal = (a, t) => provider.getBalance(a, t == null ? rc.blockNumber : t);
const [c0, r10, o0, s0, b0] = await Promise.all([company, R1.address, O.address, S.address, B.address].map(a => bal(a, rc.blockNumber - 1)));
const price = BigInt(od.j.wei); const res = price * 2000n / 10000n, pot = price * 1000n / 10000n, lvl = price * 1000n / 10000n;
const [c1, r11, o1, s1b, b1] = await Promise.all([company, R1.address, O.address, S.address, B.address].map(a => bal(a)));
ok(r11 - r10 === res, 'R1 got exactly 20% (' + ethers.formatEther(res) + ' POL)', (r11 - r10).toString());
ok(o1 - o0 === lvl && s1b - s0 === lvl, 'O (level 1) and S (level 2) each got exactly 10% without ever buying a Boost (compression over the no-wallet member)', { o: (o1 - o0).toString(), s: (s1b - s0).toString() });
ok(o1 - o0 === lvl && s1b - s0 === lvl, 'O (level 1) and S (level 2) each got exactly 10% without ever buying a Boost (compression over the no-wallet and the blocked member)', { o: (o1 - o0).toString(), s: (s1b - s0).toString() });
ok((await provider.getBalance(BL)) === 0n, 'the blocked member got nothing');
ok((await shopC.boostsBought(O.address)) === 0n && (await shopC.boostsBought(S.address)) === 0n, 'neither sponsor has bought a Boost');
ok(c1 - c0 === price - res - pot - 2n * lvl, 'company got 20% + the 3 empty levels (50% in all)', (c1 - c0).toString());
ok(b0 - b1 === price + rc.gasUsed * rc.gasPrice, 'the 1% overpay came back in the same transaction');