Curriculum·G304 Testing and the Toolchain·about 34 min

Test the unhappy path you did not imagine

By the end of this lesson you can

  • Explain that testing means exercising the unhappy paths and edge cases, not just the intended flow
  • Describe how Yam's untested rebase logic minted too much of its governance token and bricked its own fix
  • Reason that code untested against its own edge cases is not ready to hold value, however high the demand
  • Treat a passing happy-path demo as the start of testing, not evidence that a contract is safe

Graduate · enrolled learners

This lesson opens with Yam Finance, August 2020.

What happened
Yam launched to enormous demand on a contract that had not been audited, and within days it held hundreds of millions of dollars in value. A bug lived in its rebase logic, the code that periodically adjusts the token supply, and when that logic ran under real conditions it minted far more of the reserve and governance token than intended. Because that token controlled governance, the excess supply broke the very mechanism the community would have used to pass a proposal fixing the bug, so the project could not repair itself and effectively failed within about two days. The founders had been open that the code was unaudited and had asked people to stop depositing, but the money had already arrived. Nothing was stolen and no key was compromised: a piece of logic that worked in the imagined case behaved differently in the real case, its edge was never exercised before it ran with hundreds of millions of dollars behind it, and the failure it caused disabled the tools needed to undo it.
The decision point
Testing a contract means exercising the paths you did not imagine, the edge cases and unhappy conditions where behavior diverges from the intended flow, because a contract that works in the case you pictured can fail in the case you did not, and on-chain that failure runs with real value and often cannot be undone. Yam is the case: its rebase logic behaved as imagined in the simple case and, under real supply conditions it had not been tested against, minted far too much of the governance token, which then disabled the governance needed to fix it, all within two days and on an unaudited contract holding hundreds of millions. This is the testing lesson at the heart of building: a demo that shows the happy path working proves only that the happy path works, and the money leaks through the paths no one exercised, so testing is not confirming the thing does what you meant in the obvious case but hunting for the cases where it does not. So the discipline is to test the unhappy paths deliberately: the extreme inputs, the rare states, the ordering you did not plan for, the conditions that only appear at scale, and to treat any code that has not been exercised against its own edge cases as not ready to hold value, no matter how strong the demand to ship. Yam is what shipping on the strength of demand rather than testing produces: the demand made the failure larger, because the money arrived before the edge case did, and when the edge case ran it took the fix down with it.

What you will be able to answer

  • Why did Yam Finance fail (August 2020)?
  • What does testing a contract mean?
  • What does a passing happy-path demo prove?
  • When is code ready to hold value, under strong demand to ship?

Orientation and Year One are open: anyone can read them without an account. From Year Two onward the lessons are for enrolled learners, because progress through the later years only means anything if it is tracked against a record.

It is free. We do not sell the list and there is nothing to buy at the end of it.

Sources and review

Confidence high·Volatility low·Reviewed 2026-09-17·Owner unassigned

Contested

The loss is recorded as 0 because there was no theft; the harm was that the project's governance was bricked and its momentum and treasury value stranded, on a contract that held hundreds of millions of dollars in value at its peak. The lesson uses the untested-edge-case mechanism, not a headline loss figure.

A later version of Yam was relaunched by the community after review; this lesson concerns only the August 2020 rebase failure and its cause, an untested edge case in code holding real value, not the project's subsequent history.