Fix flaky messed signature test (#4819)

When messing with the signature, we need to make sure that we acutally
mess-up the signature. As the generated private/public key is random,
the signature is random as well. It can happen that `bytes[0] ==
bytes[2]` which makes the test fail. We fix this problem by just
inverting the bytes at `0` and `2`.
This commit is contained in:
Bastian Köcher
2020-02-04 12:39:56 +01:00
committed by GitHub
parent 78006d0523
commit cd0d2fd791
+2 -1
View File
@@ -735,7 +735,8 @@ mod test {
let public = pair.public();
let message = b"Signed payload";
let Signature(mut bytes) = pair.sign(&message[..]);
bytes[0] = bytes[2];
bytes[0] = !bytes[0];
bytes[2] = !bytes[2];
let signature = Signature(bytes);
assert!(!Pair::verify(&signature, &message[..], &public));
}