diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-12-05 12:57:22 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-12-05 12:57:22 +0100 |
commit | 71a3a540bda400f52a841c04b8d33a51959fa8f0 (patch) | |
tree | 6dda9c69ab037007cc8f5bc6b02bf16dbabf77f5 | |
parent | 00ddb6dfcb65d45167c0537590e255f1be7a02e7 (diff) |
openpgp: Make test more robust.
- If the primary key is created just before a second rollover, the
subkeys are created at now+1, which means they won't be alive at
now.
-rw-r--r-- | openpgp/src/cert/builder.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/openpgp/src/cert/builder.rs b/openpgp/src/cert/builder.rs index 393c2e6c..9e2a2899 100644 --- a/openpgp/src/cert/builder.rs +++ b/openpgp/src/cert/builder.rs @@ -647,23 +647,24 @@ mod tests { None) .generate().unwrap(); - let now = cert.primary().creation_time(); + let now = cert.primary().creation_time() + + 5 * s; // The subkeys may be created a tad later. let key = cert.primary(); let sig = cert.primary_key_signature(None).unwrap(); assert!(sig.key_alive(key, now)); - assert!(sig.key_alive(key, now + 599 * s)); - assert!(! sig.key_alive(key, now + 601 * s)); + assert!(sig.key_alive(key, now + 590 * s)); + assert!(! sig.key_alive(key, now + 610 * s)); let (sig, key) = cert.keys_valid().for_signing() .nth(0).map(|(s, _, k)| (s.unwrap(), k)).unwrap(); assert!(sig.key_alive(key, now)); - assert!(sig.key_alive(key, now + 299 * s)); - assert!(! sig.key_alive(key, now + 301 * s)); + assert!(sig.key_alive(key, now + 290 * s)); + assert!(! sig.key_alive(key, now + 310 * s)); let (sig, key) = cert.keys_valid().for_authentication() .nth(0).map(|(s, _, k)| (s.unwrap(), k)).unwrap(); assert!(sig.key_alive(key, now)); - assert!(sig.key_alive(key, now + 599 * s)); - assert!(! sig.key_alive(key, now + 601 * s)); + assert!(sig.key_alive(key, now + 590 * s)); + assert!(! sig.key_alive(key, now + 610 * s)); } } |