docs: code comments name the headings README has now (closes #724)
The README rewrite renamed or merged several headings that comments still cited. Each comment now names the current heading. Line number citations of README become headings too, and one test name drops its line numbers. The e2e workflow's citations of "In CI" are dropped, because no section has what they pointed at. Its comment also corrects what it says about required jobs and open reports. The comment on withLock() no longer states a Firefox private window exception, because the manifest keeps the extension out of those windows. Two comments also take corrections from reviews: the cases with no total in DeleteAddress's warning, and the screens that say a swap's amount could not be decoded. Model: opus-5-5
This commit is contained in:
+16
-13
@@ -1,15 +1,15 @@
|
||||
// Tests for the address-poisoning defense in src/shared/transactions.js.
|
||||
//
|
||||
// README.md:730-814 describes four filters as a core security property of
|
||||
// the wallet: known token symbol verification, the low-holder threshold, the
|
||||
// README, Scam protection, describes four filters as a core security property
|
||||
// of the wallet: known token symbol verification, the low-holder threshold, the
|
||||
// fraud contract blocklist, and the dust threshold. A regression in any of
|
||||
// them does not crash — it silently stops filtering, and poisoned look-alike
|
||||
// addresses reappear in the user's transaction history. These tests pin the
|
||||
// behaviour down in both directions: the documented attacks must be filtered,
|
||||
// behaviour down in both directions: the two attacks below must be filtered,
|
||||
// and legitimate transactions must survive untouched.
|
||||
//
|
||||
// Fixtures are static local objects modelled on the two real attacks cited in
|
||||
// the README. Nothing here touches the network: global.fetch is replaced
|
||||
// Fixtures are static local objects modelled on two real attacks.
|
||||
// Nothing here touches the network: global.fetch is replaced
|
||||
// with a throwing stub and the only fetch path in the module under test
|
||||
// (debugFetch, from src/shared/log) is mocked at the module boundary.
|
||||
|
||||
@@ -46,11 +46,12 @@ const { debugFetch } = require("../src/shared/log");
|
||||
const { state } = require("../src/shared/state");
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Addresses and hashes from the two attacks documented in README.md:730-814.
|
||||
// Addresses and hashes from two real attacks. README, Scam protection, has the
|
||||
// filters that stop them.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// The fake "Ethereum" token with symbol "ETH" and zero holders
|
||||
// (README.md:735-750).
|
||||
// The fake "Ethereum" token with symbol "ETH" and zero holders. See "Known
|
||||
// symbol spoofing" and "Low-holder tokens" in README, Scam protection.
|
||||
const FAKE_ETH_CONTRACT = "0xd05339f9ea5ab9d9f03b9d57f671d2abd1f55c82";
|
||||
// The fraudulent Transfer event it emitted.
|
||||
const FAKE_ETH_TRANSFER_HASH =
|
||||
@@ -62,7 +63,8 @@ const LEGIT_RECIPIENT = "0xc3c693ae04bad5f13c45885c1e85a9557798f37e";
|
||||
// The scam address the fake token transfer pointed at ("0xC3C0" vs "0xC3c6").
|
||||
const TOKEN_SCAM_LOOKALIKE = "0xc3c0aea127c575b9ffd03bf11c6a878e8979c37f";
|
||||
|
||||
// The second wave: a real 1 gwei native transfer (README.md:800-808).
|
||||
// The second wave: a real 1 gwei native transfer. See "Dust transactions" in
|
||||
// README, Scam protection.
|
||||
const DUST_TX_HASH =
|
||||
"0x2708ebddfb9b5fa3f7a89d3ea398ef9fd8771b83ed861ecb7c21cd55d18edc74";
|
||||
const DUST_SENDER_LOOKALIKE = "0xc3c6b3b4402bd78a9582ab6b00e747769344f37e";
|
||||
@@ -79,7 +81,8 @@ const NOVEL_SPAM_SYMBOL = "SPAMTKN";
|
||||
// An ordinary counterparty for legitimate-transaction fixtures.
|
||||
const ORDINARY_PEER = "0x5aa0f9f1e0a1d0e0e5c1e7ce3b7dbbe9c19f0a11";
|
||||
|
||||
// The documented default settings (README.md:810-814, state.js:24-27).
|
||||
// The documented default settings (README, Settings; DEFAULT_STATE in
|
||||
// src/shared/persistedState.js).
|
||||
const DEFAULT_FILTERS = {
|
||||
hideSpoofedSymbols: true,
|
||||
hideLowHolderTokens: true,
|
||||
@@ -220,7 +223,7 @@ describe("token list assumptions the fixtures rely on", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("the real attacks documented in README.md:730-814", () => {
|
||||
describe("the real attacks", () => {
|
||||
test('the fake "Ethereum"/"ETH" token transfer is filtered by default', () => {
|
||||
const attack = fakeEthTokenTransfer();
|
||||
const result = filterTransactions([attack], filters());
|
||||
@@ -399,8 +402,8 @@ describe("known-symbol spoof verification", () => {
|
||||
});
|
||||
|
||||
// Turning the other three filters off must not turn this one off: each
|
||||
// filter is independent, and this is the one the README calls out as the
|
||||
// defense against the fake "ETH" attack.
|
||||
// filter is independent, and this is the one that stops the fake "ETH"
|
||||
// attack.
|
||||
test("the check still runs when the other three filters are off", () => {
|
||||
const result = filterTransactions(
|
||||
[fakeEthTokenTransfer()],
|
||||
|
||||
Reference in New Issue
Block a user