forked from WikiDeck/wikideck
Upstream WikiDeck/wikideck#12. After a block is accepted the miner prints the card's title, URL, extract, rarity, proof-derived stats and the at-mint Wikipedia scores, instead of only the block number and NFT id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 lines
1.3 KiB
TypeScript
21 lines
1.3 KiB
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { rewardSummary } from '../server/testnet/reward.ts';
|
|
import { rarity, stats } from '../shared/protocol.ts';
|
|
|
|
test('miner reward summary names the earned card, its rarity and stats', () => {
|
|
const powHash = '000eca7498a26d1908613726da6e869d7c9c936f4a461cb439ef24672b9a0008';
|
|
const text = rewardSummary({ height: 42, tokenId: 'abc123', powHash,
|
|
article: { pageId: 1, title: 'Ada Lovelace', extract: 'x'.repeat(300), url: 'https://en.wikipedia.org/wiki/Ada_Lovelace',
|
|
revisionId: 1, source: 'live', category: 'People' },
|
|
statsSnapshot: { capturedAt: '2026-11-16T00:00:00Z', revisionId: 1, pageBytes: 1, languageCount: 1, languagesTruncated: false,
|
|
pageviews: { status: 'unavailable' } as never, stats: { attention: null, depth: 50, reach: 7 } } });
|
|
const s = stats(powHash);
|
|
assert.match(text, new RegExp(`You earned a ${rarity(powHash)} card: Ada Lovelace`));
|
|
assert.match(text, /https:\/\/en\.wikipedia\.org\/wiki\/Ada_Lovelace/);
|
|
assert.match(text, new RegExp(`Power ${s.power} · Defense ${s.defense} · Knowledge ${s.knowledge}`));
|
|
assert.match(text, /attention — · depth 50 · reach 7/);
|
|
assert.match(text, /Block #42 · NFT abc123/);
|
|
assert.ok(text.split('\n')[2].length < 170, 'long extracts are truncated');
|
|
});
|