@@ -4,12 +4,13 @@ use committable::Committable;
4
4
use multisig:: {
5
5
Certificate , Committee , Envelope , Keypair , PublicKey , Signed , Validated , VoteAccumulator ,
6
6
} ;
7
+ use rand:: SeedableRng ;
8
+ use rand:: rngs:: StdRng ;
7
9
use sailfish:: consensus:: ConsensusMetrics ;
8
10
use sailfish:: types:: CommitteeVec ;
9
11
use sailfish:: types:: {
10
12
Evidence , Round , RoundNumber , Timeout , TimeoutMessage , UNKNOWN_COMMITTEE_ID ,
11
13
} ;
12
- use timeboost_utils:: unsafe_zero_keypair;
13
14
14
15
use super :: node_instrument:: TestNodeInstrument ;
15
16
use crate :: prelude:: * ;
@@ -24,14 +25,21 @@ pub struct KeyManager {
24
25
/// Helper for all the keys in a committeee for testing purposes.
25
26
impl KeyManager {
26
27
pub ( crate ) fn new ( num_nodes : u8 ) -> Self {
27
- let key_pairs = ( 0 ..num_nodes) . map ( |i| ( i, unsafe_zero_keypair ( i as u64 ) ) ) ;
28
+ let key_pairs = ( 0 ..num_nodes)
29
+ . map ( |i| {
30
+ ( i, {
31
+ let mut g = StdRng :: seed_from_u64 ( i. into ( ) ) ;
32
+ Keypair :: generate_with_rng ( & mut g)
33
+ } )
34
+ } )
35
+ . collect :: < BTreeMap < _ , _ > > ( ) ;
28
36
let committee = Committee :: new (
29
37
UNKNOWN_COMMITTEE_ID ,
30
- key_pairs. clone ( ) . map ( |( i, k) | ( i, k. public_key ( ) ) ) ,
38
+ key_pairs. iter ( ) . map ( |( i, k) | ( * i, k. public_key ( ) ) ) ,
31
39
) ;
32
40
let cv = CommitteeVec :: new ( committee. clone ( ) ) ;
33
41
Self {
34
- keys : key_pairs. collect ( ) ,
42
+ keys : key_pairs,
35
43
committee,
36
44
committees : cv,
37
45
}
0 commit comments