diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2022-01-27 14:18:42 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2022-01-27 14:22:55 +0100 |
commit | d5f10bd039bcf7ff3e28423f2bfe399effbb7cc1 (patch) | |
tree | e74dfe8df2943a65bc43df45977de3d987c8be99 | |
parent | 3c7f20a707de67a612d4a671d412e9055babe4b0 (diff) |
openpgp: Make test less timing-sensitive.
- Previously, the test asserted that we can create at least
SIG_BACKDATE_BY signatures, and at most 2 * SIG_BACKDATE_BY
signatures.
- The former may fail, presumably due to a corner case involving
losing the sub-second precision of SystemTime. The latter may
fail depending on CPU resources and scheduling.
- Tame the test by demonstrating that we can override a couple of
signatures. Drop the test for the maximum number of overrides.
- Fixes #777.
-rw-r--r-- | openpgp/src/packet/signature.rs | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/openpgp/src/packet/signature.rs b/openpgp/src/packet/signature.rs index b5adf702..dada9b48 100644 --- a/openpgp/src/packet/signature.rs +++ b/openpgp/src/packet/signature.rs @@ -3596,7 +3596,9 @@ mod test { alice.userids().next().unwrap().self_signatures().next().unwrap() .signature_creation_time().unwrap(); - for i in 0..2 * SIG_BACKDATE_BY { + const TRIES: u64 = 5; + assert!(TRIES * 10 < SIG_BACKDATE_BY); + for i in 0..TRIES { assert_eq!(alice.userids().next().unwrap().self_signatures().count(), 1 + i as usize); @@ -3616,13 +3618,10 @@ mod test { alice.primary_key().component(), &alice.userids().next().unwrap()) { Ok(v) => v, - Err(e) => if i < SIG_BACKDATE_BY { + Err(e) => { + eprintln!("Failed to make {} signatures on top of \ + the original one.", i); return Err(e); // Not cool. - } else { - assert!(e.to_string().contains( - "Cannot create valid signature newer than \ - template")); - return Ok(()); // Cool. }, }; @@ -3634,10 +3633,7 @@ mod test { assert_eq!(sig, &new_sig); } - panic!("We were unexpectedly able to update binding signatures {} \ - times. This is either a very slow build environment, or \ - there is a bug. Please get in contact.", - 2 * SIG_BACKDATE_BY); + Ok(()) } /// Checks that subpackets are marked as authentic on signature |