TestCommitUUIDDistinct ensures distinct SHAs mint distinct UUIDs. SHA-256 has effectively zero collisions for realistic input; a regression that narrowed the hash to 64 bits (or a bug in the version/variant stamping) would surface as a collision here.
(t *testing.T)
| 66 | // regression that narrowed the hash to 64 bits (or a bug in the |
| 67 | // version/variant stamping) would surface as a collision here. |
| 68 | func TestCommitUUIDDistinct(t *testing.T) { |
| 69 | shas := []string{ |
| 70 | "81353411f7b010d5b9ebeb1899066aac18a36701", |
| 71 | "0000000000000000000000000000000000000000", |
| 72 | "ffffffffffffffffffffffffffffffffffffffff", |
| 73 | "0123456789abcdef0123456789abcdef01234567", |
| 74 | "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef", |
| 75 | } |
| 76 | seen := make(map[string]string, len(shas)) |
| 77 | for _, s := range shas { |
| 78 | u := commitUUID(s) |
| 79 | if prev, ok := seen[u]; ok { |
| 80 | t.Fatalf("UUID collision: %q and %q both minted %q", prev, s, u) |
| 81 | } |
| 82 | seen[u] = s |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | // TestCommitUUIDEmpty guards the empty-input branch. The buf client |
| 87 | // never sends an empty commit id, but the proxy might compute one when |
nothing calls this directly
no test coverage detected