Skip to content

Commit b0a9e8f

Browse files
committed
clarify hash mismatch documentation
1 parent 38e0941 commit b0a9e8f

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

tests/unit/engine.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,18 @@ mod tests {
173173
});
174174
}
175175

176-
const HASH_MISSMATCH_MSG: &str = r#"
177-
Changed in the serialized format detected!
178-
1. Update ADBLOCK_RUST_DAT_VERSION before updating the expectations
179-
2. DON'T rely on an approach: it's backwards compatible with the old one
176+
const HASH_MISMATCH_MSG: &str = r#"
177+
A change has been detected in the serialized format! If the change is intentional:
178+
1. Update ADBLOCK_RUST_DAT_VERSION before updating the expected hashes
179+
2. DON'T rely on backwards compatibility with the old format
180180
Backwards compatibility isn't covered by the tests"#;
181181

182182
#[test]
183183
fn deserialization_generate_simple() {
184184
let mut engine = Engine::from_rules(["ad-banner"], Default::default());
185185
let data = engine.serialize().unwrap();
186-
assert_eq!(hash(&data), 5723845290597955159, "{}", HASH_MISSMATCH_MSG);
186+
const EXPECTED_HASH: u64 = 5723845290597955159;
187+
assert_eq!(hash(&data), EXPECTED_HASH, "{}", HASH_MISMATCH_MSG);
187188
engine.deserialize(&data).unwrap();
188189
}
189190

@@ -192,7 +193,8 @@ mod tests {
192193
let mut engine = Engine::from_rules(["ad-banner$tag=abc"], Default::default());
193194
engine.use_tags(&["abc"]);
194195
let data = engine.serialize().unwrap();
195-
assert_eq!(hash(&data), 9626816743810307798, "{}", HASH_MISSMATCH_MSG);
196+
const EXPECTED_HASH: u64 = 9626816743810307798;
197+
assert_eq!(hash(&data), EXPECTED_HASH, "{}", HASH_MISMATCH_MSG);
196198
engine.deserialize(&data).unwrap();
197199
}
198200

@@ -222,7 +224,7 @@ mod tests {
222224
6839468684492187294
223225
};
224226

225-
assert_eq!(hash(&data), expected_hash, "{}", HASH_MISSMATCH_MSG);
227+
assert_eq!(hash(&data), expected_hash, "{}", HASH_MISMATCH_MSG);
226228

227229
engine.deserialize(&data).unwrap();
228230
}

0 commit comments

Comments
 (0)