Skip to content

Commit 3ec8b7b

Browse files
nipunn1313Convex, Inc.
authored andcommitted
Fix the crypto UUID functionality (#43653)
See #269 GitOrigin-RevId: edad8235c7bb0f30450d728ebfd60086f4b15f06
1 parent 0508c11 commit 3ec8b7b

File tree

1 file changed

+14
-4
lines changed
  • crates/isolate/src/ops/crypto

1 file changed

+14
-4
lines changed

crates/isolate/src/ops/crypto/mod.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff 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+
}

0 commit comments

Comments
 (0)