test: cover the address-poisoning filters in transactions.js (closes #160)
All checks were successful
check / check (push) Successful in 24s
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:
1002
tests/transactions.test.js
Normal file
1002
tests/transactions.test.js
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user