End to end on the workstation (coordinator:run, the API, edge:node, real NNTP): a.b.e-book.french and a.b.cd.image.playstation2.dvdiso ranges. - Prefetcher: every connection takes the next missing chunk (leased ranges first, in order); one connection per range (~26k lines/s) kept the worker waiting - executable rule: releases of bare executables (malware floods named after films and software) are dropped; they were 92% of the catalog rows of the test ranges, 21% of the segments - fragments per file (details once) and gzipped batch bodies; the JSON limit (1 MB by default) raised to 256 MB, empty strings kept (a rule count's key is '') - release_chunks.batch_from is a bigint (boneless article numbers) - tests get their own database; edge:bench --store times BatchStore: 1.3 s for a boneless range (1.24 ms per release chunk) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63 lines
3.6 KiB
TypeScript
63 lines
3.6 KiB
TypeScript
import { test } from '@japa/runner'
|
|
import { DEFAULT_RULES, RuleSet, ownerOf, uploadTool, explored } from '#lib/rules/index'
|
|
import { sevenZipVolume } from '#lib/files/index'
|
|
|
|
const rules = new RuleSet({ ...DEFAULT_RULES, samplePercent: 0, priorities: {}, droppedSignatures: ['nyuu\talt.binaries.misc'] })
|
|
const file = (name: string, totalParts: number, firstMessageId: string, group = 'alt.binaries.ath') => ({ name, totalParts, groups: [group], firstMessageId })
|
|
const NGPOST = 'b94268bc702040f7b811d5318f727e4f@ngPost'
|
|
const NYUU = 'FmFwIaTpGgUiSfYcMwFlMeRo-1790637260478@nyuu'
|
|
|
|
test.group('rules / owner', () => {
|
|
test('a crosspost belongs to the indexed group with the lowest priority, whatever the Xref order', ({ assert }) => {
|
|
const priorities = { 'alt.binaries.boneless': 1, 'alt.binaries.ath': 3, 'alt.binaries.added.later': 1001 }
|
|
assert.equal(ownerOf(['alt.binaries.ath', 'alt.binaries.boneless'], priorities), 'alt.binaries.boneless')
|
|
assert.equal(ownerOf(['alt.binaries.added.later', 'alt.binaries.ath'], priorities), 'alt.binaries.ath')
|
|
assert.equal(ownerOf(['alt.binaries.not.indexed'], priorities), null)
|
|
})
|
|
})
|
|
|
|
test.group('rules / verdicts', () => {
|
|
test('a readable file keeps its whole release', ({ assert }) => {
|
|
assert.deepEqual(rules.judge('k', [file('Hs7dKq2LmZ9xWv3RtYp1Qa.part01.rar', 50, NGPOST), file('Some.Show.S01E01.1080p.nfo', 1, NGPOST)]), { rule: null })
|
|
})
|
|
|
|
test('bare executables are dropped, sidecars aside; an executable among other content is kept', ({ assert }) => {
|
|
assert.include(rules.judge('k', [file('How to Make Love to a Woman 2010.scr', 10, NYUU), file('How to Make Love to a Woman 2010.par2', 1, NYUU)]), { rule: 'executable', key: 'scr' })
|
|
assert.include(rules.judge('k', [file('Adobe Illustrator CS2 + ssg keygen.zip .exe', 3, NYUU)]), { rule: 'executable', key: 'exe' })
|
|
assert.deepEqual(rules.judge('k', [file('Some.App.v1.0.part1.rar', 50, NYUU), file('setup.exe', 2, NYUU)]), { rule: null })
|
|
})
|
|
|
|
test('random names: per-article with few parts, garbage by tool or signature, else kept', ({ assert }) => {
|
|
assert.include(rules.judge('k', [file('Hs7dKq2LmZ9xWv3RtYp1Qa', 2, NYUU)]), { rule: 'per-article', key: 'nyuu' })
|
|
assert.include(rules.judge('k', [file('Hs7dKq2LmZ9xWv3RtYp1Qa.part01.rar', 50, NGPOST)]), { rule: 'garbage', key: 'ngPost alt.binaries.ath' })
|
|
assert.include(rules.judge('k', [file('Hs7dKq2LmZ9xWv3RtYp1Qa.part01.rar', 50, NYUU, 'alt.binaries.misc')]), { rule: 'garbage', key: 'nyuu alt.binaries.misc' })
|
|
assert.deepEqual(rules.judge('k', [file('Hs7dKq2LmZ9xWv3RtYp1Qa.part01.rar', 50, NYUU)]), { rule: null })
|
|
})
|
|
})
|
|
|
|
test.group('rules / upload tools', () => {
|
|
test('posting tools are told apart by their Message-IDs', ({ assert }) => {
|
|
assert.equal(uploadTool(NYUU), 'nyuu')
|
|
assert.equal(uploadTool(NGPOST), 'ngPost')
|
|
assert.equal(uploadTool('part1of69.lOlWzvSHabJCBTVrs0ts@AdultPoster.local'), 'partNofM')
|
|
assert.equal(uploadTool('DLugnv3ZrVBv8Z9I69nU_19o112@JBinUp.local'), 'JBinUp')
|
|
assert.equal(uploadTool('t3Y4mV92YCp0McxDc5@zLZlsw.RYqes'), 'random')
|
|
assert.equal(uploadTool(null), 'other')
|
|
})
|
|
|
|
test('the sampled share is stable per key and about the percentage', ({ assert }) => {
|
|
assert.equal(explored('some-release', 2), explored('some-release', 2))
|
|
const kept = Array.from({ length: 10_000 }, (_, i) => explored(`release-${i}`, 2)).filter(Boolean).length
|
|
assert.isAbove(kept, 150)
|
|
assert.isBelow(kept, 250)
|
|
})
|
|
})
|
|
|
|
test.group('files / volumes', () => {
|
|
test('7z volume numbers', ({ assert }) => {
|
|
assert.equal(sevenZipVolume('x.7z.001'), 1)
|
|
assert.equal(sevenZipVolume('x.7z'), 0)
|
|
assert.isNull(sevenZipVolume('x.rar'))
|
|
})
|
|
})
|