@@ -1512,10 +1512,7 @@ mod test {
15121512 use core:: str:: FromStr ;
15131513
15141514 #[ cfg( any( feature = "alloc" , feature = "std" ) ) ]
1515- use rand:: { Error , ErrorKind , RngCore , thread_rng} ;
1516-
1517- #[ cfg( any( feature = "alloc" , feature = "std" ) ) ]
1518- use rand_core:: impls;
1515+ use rand:: { Error , RngCore , thread_rng, rngs:: mock:: StepRng } ;
15191516
15201517 #[ cfg( target_arch = "wasm32" ) ]
15211518 use wasm_bindgen_test:: wasm_bindgen_test as test;
@@ -1594,7 +1591,6 @@ mod test {
15941591 #[ test]
15951592 #[ cfg( any( feature = "alloc" , feature = "std" ) ) ]
15961593 fn test_out_of_range ( ) {
1597-
15981594 struct BadRng ( u8 ) ;
15991595 impl RngCore for BadRng {
16001596 fn next_u32 ( & mut self ) -> u32 { unimplemented ! ( ) }
@@ -1687,28 +1683,9 @@ mod test {
16871683 #[ test]
16881684 #[ cfg( all( feature = "rand" , any( feature = "alloc" , feature = "std" ) ) ) ]
16891685 fn test_debug_output ( ) {
1690- use to_hex;
1691-
1692- struct DumbRng ( u32 ) ;
1693- impl RngCore for DumbRng {
1694- fn next_u32 ( & mut self ) -> u32 {
1695- self . 0 = self . 0 . wrapping_add ( 1 ) ;
1696- self . 0
1697- }
1698- fn next_u64 ( & mut self ) -> u64 {
1699- self . next_u32 ( ) as u64
1700- }
1701- fn fill_bytes ( & mut self , dest : & mut [ u8 ] ) {
1702- impls:: fill_bytes_via_next ( self , dest) ;
1703- }
1704-
1705- fn try_fill_bytes ( & mut self , _dest : & mut [ u8 ] ) -> Result < ( ) , Error > {
1706- Err ( Error :: new ( ErrorKind :: Unavailable , "not implemented" ) )
1707- }
1708- }
17091686
17101687 let s = Secp256k1 :: new ( ) ;
1711- let ( sk, _) = s. generate_keypair ( & mut DumbRng ( 0 ) ) ;
1688+ let ( sk, _) = s. generate_keypair ( & mut StepRng :: new ( 1 , 1 ) ) ;
17121689
17131690 assert_eq ! ( & format!( "{:?}" , sk) ,
17141691 "SecretKey(#d3e0c51a23169bb5)" ) ;
@@ -1785,26 +1762,9 @@ mod test {
17851762 #[ cfg( not( fuzzing) ) ]
17861763 #[ cfg( any( feature = "alloc" , feature = "std" ) ) ]
17871764 fn test_pubkey_serialize ( ) {
1788- struct DumbRng ( u32 ) ;
1789- impl RngCore for DumbRng {
1790- fn next_u32 ( & mut self ) -> u32 {
1791- self . 0 = self . 0 . wrapping_add ( 1 ) ;
1792- self . 0
1793- }
1794- fn next_u64 ( & mut self ) -> u64 {
1795- self . next_u32 ( ) as u64
1796- }
1797- fn try_fill_bytes ( & mut self , _dest : & mut [ u8 ] ) -> Result < ( ) , Error > {
1798- Err ( Error :: new ( ErrorKind :: Unavailable , "not implemented" ) )
1799- }
1800-
1801- fn fill_bytes ( & mut self , dest : & mut [ u8 ] ) {
1802- impls:: fill_bytes_via_next ( self , dest) ;
1803- }
1804- }
18051765
18061766 let s = Secp256k1 :: new ( ) ;
1807- let ( _, pk1) = s. generate_keypair ( & mut DumbRng ( 0 ) ) ;
1767+ let ( _, pk1) = s. generate_keypair ( & mut StepRng :: new ( 1 , 1 ) ) ;
18081768 assert_eq ! ( & pk1. serialize_uncompressed( ) [ ..] ,
18091769 & [ 4 , 124 , 121 , 49 , 14 , 253 , 63 , 197 , 50 , 39 , 194 , 107 , 17 , 193 , 219 , 108 , 154 , 126 , 9 , 181 , 248 , 2 , 12 , 149 , 233 , 198 , 71 , 149 , 134 , 250 , 184 , 154 , 229 , 185 , 28 , 165 , 110 , 27 , 3 , 162 , 126 , 238 , 167 , 157 , 242 , 221 , 76 , 251 , 237 , 34 , 231 , 72 , 39 , 245 , 3 , 191 , 64 , 111 , 170 , 117 , 103 , 82 , 28 , 102 , 163 ] [ ..] ) ;
18101770 assert_eq ! ( & pk1. serialize( ) [ ..] ,
0 commit comments