-
Notifications
You must be signed in to change notification settings - Fork 742
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deterministic block generation for tests (#5654)
* Deterministic block generation for tests
- Loading branch information
Showing
2 changed files
with
7 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
use super::*; | ||
|
||
impl TestRandom for Signature { | ||
fn random_for_test(rng: &mut impl RngCore) -> Self { | ||
let secret_key = SecretKey::random_for_test(rng); | ||
let mut message = vec![0; 32]; | ||
rng.fill_bytes(&mut message); | ||
|
||
secret_key.sign(Hash256::from_slice(&message)) | ||
fn random_for_test(_rng: &mut impl RngCore) -> Self { | ||
// TODO: `SecretKey::random_for_test` does not return a deterministic signature. Since this | ||
// signature will not pass verification we could just return the generator point or the | ||
// generator point multiplied by a random scalar if we want disctint signatures. | ||
Signature::infinity().expect("infinity signature is valid") | ||
} | ||
} |