fe3e3c17
Make ambiguous lease prefix coverage deterministic
a73x 2026-09-06 09:46
Commit message
tests/lease_server_test.rs
| Old | New | ||
|---|---|---|---|
| @@ -376,26 +376,23 @@ fn an_ambiguous_prefix_is_refused() { | |||
| 376 | harness.push_head(); | 376 | harness.push_head(); |
| 377 | let repo = harness.work_repo_git2(); | 377 | let repo = harness.work_repo_git2(); |
| 378 | 378 | ||
| 379 | // Issue ids are content-derived, so collide them in the lease table | 379 | // Issue ids are content-derived, so create enough real issues that two |
| 380 | // directly by claiming two whole ids that share a prefix is not possible; | 380 | // must share their first hex character. |
| 381 | // instead claim two real issues and use a prefix short enough to match | ||
| 382 | // both only if they happen to share one. Find such a pair, or skip. | ||
| 383 | let mut ids = Vec::new(); | 381 | let mut ids = Vec::new(); |
| 384 | for n in 0..12 { | 382 | for n in 0..17 { |
| 385 | let (_r, id) = common::open_issue(&repo, &common::alice(), &format!("Issue {n}")); | 383 | let (_r, id) = common::open_issue(&repo, &common::alice(), &format!("Issue {n}")); |
| 386 | ids.push(id); | 384 | ids.push(id); |
| 387 | } | 385 | } |
| 388 | harness.push_collab_refs(); | 386 | harness.push_collab_refs(); |
| 389 | 387 | ||
| 390 | let shared = ids.iter().find_map(|a| { | 388 | let (a, b) = ids |
| 391 | ids.iter() | 389 | .iter() |
| 392 | .find(|b| *b != a && b.as_bytes()[0] == a.as_bytes()[0]) | 390 | .find_map(|a| { |
| 393 | .map(|b| (a.clone(), b.clone())) | 391 | ids.iter() |
| 394 | }); | 392 | .find(|b| *b != a && b.as_bytes()[0] == a.as_bytes()[0]) |
| 395 | let Some((a, b)) = shared else { | 393 | .map(|b| (a.clone(), b.clone())) |
| 396 | eprintln!("no two of 12 issue ids shared a first hex character; nothing to assert"); | 394 | }) |
| 397 | return; | 395 | .expect("17 ids over 16 first hex characters must share one"); |
| 398 | }; | ||
| 399 | 396 | ||
| 400 | for id in [&a, &b] { | 397 | for id in [&a, &b] { |
| 401 | let out = harness.ssh_exec(&format!( | 398 | let out = harness.ssh_exec(&format!( |