Using immutable data
After implementing and testing the library with real elevators, you find another bug—when someone physically keys into a session, sometimes they get deauthorized while still using the elevator. Sometimes is a terrible word to hear in a bug report.
Fixing the hard-to-reproduce bug
After way too much searching and researching, you find a test case that reliably reproduces the problem:
#[test] fn invalid_deauthorization() { admin::reset_state(); let session = admin::authorize_admin().ok(); assert!(admin::authorize_admin().is_err()); assert!(admin::is_admin()); }
Looking at this test case, the first thing we might ask is, why should this be permitted?
The problem that we encountered during physical testing was characterized by the random deauthorization of valid sessions. What was discovered during investigations was that during physically authorized sessions, sometimes software authorized sessions would be initiated. A physical authorization is when someone uses...