test: cover the address-poisoning filters in transactions.js (closes #160)
All checks were successful
check / check (push) Successful in 24s

src/shared/transactions.js had zero test coverage despite owning the four
anti-poisoning filters that README.md:730-814 documents as a core security
property: known token symbol verification, the 1,000-holder rule, the fraud
contract blocklist, and the dust threshold. A regression in any of them does
not crash, it just silently stops filtering, so the behaviour needs pinning
down in both directions.

Adds tests/transactions.test.js with fixtures built from the two real attacks
cited in the README: the fake "Ethereum"/"ETH" token at 0xD05339f9 with zero
holders, and the 1 gwei native dust transfer 0x2708ebdd from the look-alike
sender 0xC3c6B3b4. Every filter is proven to work when on and to be bypassed
when off, both thresholds are asserted at, just below, and just above their
boundary, and legitimate traffic (a plain ETH transfer and genuine USDC and
WETH transfers) is proven to survive all four rules.

Also covers the per-address merge and dedup that fetchRecentTransactions owns,
with debugFetch mocked at the module boundary. No test performs a network
request: global.fetch is a throwing stub and is asserted never to have been
called.

Several tests are named as documenting current behaviour where it diverges
from the README; no source file is modified here.
This commit is contained in:
2026-08-09 05:05:15 +00:00
parent e8ad8325c8
commit 8dd056bc08
2 changed files with 1004 additions and 0 deletions

View File

@@ -37,6 +37,8 @@ review.
launch-time canary aborts the suite if worker traffic starts escaping. launch-time canary aborts the suite if worker traffic starts escaping.
- 2026-08-09: Reviewed the repo end to end and filed the 1.0.0 backlog - 2026-08-09: Reviewed the repo end to end and filed the 1.0.0 backlog
(#149-#168). (#149-#168).
- 2026-08-09: Test coverage for the address-poisoning defense in
`src/shared/transactions.js` (#160)
- 2026-07-26: About well in settings with build info, repo link and the version - 2026-07-26: About well in settings with build info, repo link and the version
click easter egg (#145); proper view navigation stack (#146). click easter egg (#145); proper view navigation stack (#146).
- 2026-07-07 Adopted scripts-to-rule-them-all: `script/` entrypoints, Makefile - 2026-07-07 Adopted scripts-to-rule-them-all: `script/` entrypoints, Makefile

1002
tests/transactions.test.js Normal file

File diff suppressed because it is too large Load Diff