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.
Using immutable data
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...