Updates tests

This commit is contained in:
Robert Kornacki 2019-07-22 15:45:30 -04:00
parent e1d0a2d6d2
commit f85cc9388f
2 changed files with 5 additions and 1 deletions

View file

@ -10,7 +10,7 @@ keywords = ["PoW", "sha256", "proof-of-work"]
readme = "readme.md" readme = "readme.md"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
repository = "https://github.com/robkorn/pow" repository = "https://github.com/robkorn/pow"
categories = [] # pr me! categories = ["pow", "sha256"]
[dependencies] [dependencies]
sha2 = "0.8.0" sha2 = "0.8.0"
serde = { version = "1.0.97", features = ["derive"] } serde = { version = "1.0.97", features = ["derive"] }

View file

@ -102,6 +102,7 @@ mod test {
let phrase = b"Ex nihilo nihil fit.".to_vec(); let phrase = b"Ex nihilo nihil fit.".to_vec();
let pw = PoW::prove_work(&phrase, DIFFICULTY).unwrap(); let pw = PoW::prove_work(&phrase, DIFFICULTY).unwrap();
assert!(pw.calculate(&phrase).unwrap() >= DIFFICULTY); assert!(pw.calculate(&phrase).unwrap() >= DIFFICULTY);
assert!(pw.result >= DIFFICULTY);
assert!(pw.is_valid_proof(&phrase)); assert!(pw.is_valid_proof(&phrase));
} }
@ -112,6 +113,9 @@ mod test {
let pwpw: PoW<PoW<String>> = PoW::prove_work(&pw, DIFFICULTY).unwrap(); let pwpw: PoW<PoW<String>> = PoW::prove_work(&pw, DIFFICULTY).unwrap();
assert!(pw.calculate(&phrase).unwrap() >= DIFFICULTY); assert!(pw.calculate(&phrase).unwrap() >= DIFFICULTY);
assert!(pwpw.calculate(&pw).unwrap() >= DIFFICULTY); assert!(pwpw.calculate(&pw).unwrap() >= DIFFICULTY);
assert!(pw.result >= DIFFICULTY);
assert!(pwpw.result >= DIFFICULTY);
assert!(pw.is_valid_proof(&phrase));
assert!(pwpw.is_valid_proof(&pw)); assert!(pwpw.is_valid_proof(&pw));
} }