File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
crates/isolate/src/ops/crypto Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -519,10 +519,7 @@ impl CryptoOps {
519519 pub fn random_uuid ( mut rng : impl Rng ) -> anyhow:: Result < Uuid > {
520520 let mut bytes = [ 0u8 ; 16 ] ;
521521 rng. fill ( & mut bytes) ;
522- let uuid = uuid:: Builder :: from_bytes ( bytes)
523- . with_version ( uuid:: Version :: Random )
524- . into_uuid ( ) ;
525- Ok ( uuid)
522+ Ok ( uuid:: Builder :: from_random_bytes ( bytes) . into_uuid ( ) )
526523 }
527524
528525 pub fn get_random_values ( mut rng : impl Rng , byte_length : u32 ) -> anyhow:: Result < Vec < u8 > > {
@@ -844,3 +841,16 @@ impl CryptoOps {
844841 }
845842 }
846843}
844+
845+ #[ cfg( test) ]
846+ mod tests {
847+ use super :: CryptoOps ;
848+
849+ #[ test]
850+ fn test_random_uuid ( ) -> anyhow:: Result < ( ) > {
851+ let uuid = CryptoOps :: random_uuid ( rand:: rng ( ) ) ?;
852+ assert_eq ! ( uuid. get_version( ) , Some ( uuid:: Version :: Random ) ) ;
853+ assert_eq ! ( uuid. get_variant( ) , uuid:: Variant :: RFC4122 ) ;
854+ Ok ( ( ) )
855+ }
856+ }
You can’t perform that action at this time.
0 commit comments