summaryrefslogtreecommitdiffstats
path: root/tests/hash.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-19 17:09:59 +0000
committeraur-build <aur-build@localhost>2026-11-19 17:09:59 +0000
commite757979f1a2afdbe7146066345bb9acd19d3b151 (patch)
tree30d5f5fbccd25ea7bf01c5202684af463b74e7d3 /tests/hash.rs
parent94c318f13264bb3c00a9f3057ba2e1aafb57c9e4 (diff)
downloadaur-build-e757979f1a2afdbe7146066345bb9acd19d3b151.tar.gz
aur-build-e757979f1a2afdbe7146066345bb9acd19d3b151.zip
comments: say why, not what
Every module-level `//!` header is gone, and the comments that remained either re-explained the line below them or had grown into paragraphs. Density went from one comment line per 6.7 lines of code to one per 10. 827 insertions against 2194 deletions across 86 files. What survived: the invariants (I1-I12), the design cross-references into DESIGN.md, and the notes recording a bug that was found and fixed — those are the comments that carry weight, because they answer a question the code cannot answer about itself. What did not: restating a function signature in prose, and narration of the statement underneath.
Diffstat (limited to 'tests/hash.rs')
-rw-r--r--tests/hash.rs22
1 files changed, 6 insertions, 16 deletions
diff --git a/tests/hash.rs b/tests/hash.rs
index 427f8ae..46ecdb4 100644
--- a/tests/hash.rs
+++ b/tests/hash.rs
@@ -1,19 +1,10 @@
-//! The digest helpers (§3, §5.1a).
-//!
-//! `sha256` hex is the currency of identity and provenance here, and one of
-//! those digests — `Identity::hash` — is the value a reviewer's approval echoes
-//! back. Everything that guards "we published what we reviewed" rests on that
-//! digest being a function of the identity and of nothing else: not of the
-//! order fields were declared in, and never of whether serialization happened
-//! to fail.
-
use std::collections::HashMap;
use aur_build::db::model::Identity;
use aur_build::hash;
-/// A value that refuses to be serialized, which is the input the old
-/// implementation answered with `"{}"` — a digest every failed value shared.
+/// A value that refuses to be serialized — the input the old implementation
+/// answered with `"{}"`, a digest every failed value shared.
struct Unserializable;
impl serde::Serialize for Unserializable {
@@ -26,16 +17,15 @@ impl serde::Serialize for Unserializable {
fn a_value_that_cannot_be_serialized_is_an_error_not_an_empty_object() {
let err = hash::canonical_json(&Unserializable).unwrap_err();
assert!(err.to_string().contains("cannot be serialized"), "the failure was swallowed: {err}");
- // The point of propagating: two different unserializable values now fail
- // loudly instead of hashing to the same digest as each other.
+ // Two different unserializable values now fail loudly instead of hashing to
+ // the same digest.
assert!(hash::canonical_json(&Unserializable).is_err());
}
#[test]
fn the_rendering_is_canonical_in_fact_not_in_name() {
- // Same fields, different declaration order: routed through `Value`, both
- // come out with the keys sorted, so the bytes — and any digest of them —
- // are the same.
+ // Same fields, different declaration order: routed through `Value`, both come
+ // out with the keys sorted.
#[derive(serde::Serialize)]
struct Ab {
alpha: String,