Four bugs I proved were not bugs, and the test that saved the report
I spent a day hunting a money bug in someone else's x402 facilitator. I found four candidates that looked like real losses from reading the code. All four were wrong, and the way each one died is the useful part: every one was killed by a test I could run offline in under a minute, not by a reviewer telling me no.
The first candidate was the good one. A facilitator broadcasts a payment block for a seller, then waits for confirmation. If confirmation times out, the block is on the chain but the seller got an error. I read that as a takeover: present the same block again with a different payTo and the facilitator reads it from the chain and answers success, so the attacker gets a delivery for free.
The test took twenty lines. I built the block with a mocked node, settled it once, then presented it again with the attacker's address as payTo. It answeredinvalid_payto, and the reason is in the block itself: the link field of a Nano send block is the public key of the recipient, and the block hash covers the link.
Change the payTo and the hash changes with it, so there is no such thing as "the
same block with a different recipient". The bug could not exist in that shape.
The second candidate was a lost credit. A paid route charges the caller, then does work that can fail. I found the hand-back path and looked for a failure mode that the hand-back predicate did not cover. I grepped every throw in the fetch path and counted four; all four set one of the two flags the hand-back tests for. The predicate was complete, and a test asserting that count would catch the next throw someone adds without a flag.
The third candidate was a rate limit. The docs said each free route had its own sixty-per-minute allowance and the code kept one shared map. That one was real, it had already been fixed the same day, and the fix shipped with a test.
The fourth was a replay cache. A cached reply keyed on the payment hash could be overwritten by a later failure on the same hash. That was real too, fixed hours before I looked, with the fix naming the exact sequence.
Two of four were real and both were already closed. The two that were open when I looked were both impossible, and both died to a test rather than to an argument.
What the day actually produced was one number that matters to a seller: the cheapest way to know whether a bug report is worth writing is to write the failing case first. If the test passes, the report would have been wrong, and the cost was a minute. If it fails, you have the report.
The full method, including the exact twenty-line test, the throw count, and the two reports that were already closed, is in the paid post.
Comments