From 4d873276455be866adf06448599692acedec50f0 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 18:10:51 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=A7=AA=20Add=20unit=20tests=20for=20r?= =?UTF-8?q?egister=5Fcrypto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> --- stdlib/src/crypto.rs | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/stdlib/src/crypto.rs b/stdlib/src/crypto.rs index b8bc6de0..3a527dac 100644 --- a/stdlib/src/crypto.rs +++ b/stdlib/src/crypto.rs @@ -185,3 +185,59 @@ impl StdlibRegistry { ); } } + +#[cfg(test)] +mod tests { + use super::*; + use techscript_runtime::context::{RuntimeConfig, RuntimeContext}; + + #[test] + fn test_register_crypto() { + let mut registry = StdlibRegistry::new(); + registry.register_crypto(); + + let module = registry.get_module("std.crypto").unwrap(); + + let aes_encrypt_fn = module.exports.get("aes_encrypt").unwrap(); + assert_eq!(aes_encrypt_fn.name(), "aes_encrypt"); + assert_eq!(aes_encrypt_fn.arity(), 2); + + let aes_decrypt_fn = module.exports.get("aes_decrypt").unwrap(); + assert_eq!(aes_decrypt_fn.name(), "aes_decrypt"); + assert_eq!(aes_decrypt_fn.arity(), 2); + + let bcrypt_hash_fn = module.exports.get("bcrypt_hash").unwrap(); + assert_eq!(bcrypt_hash_fn.name(), "bcrypt_hash"); + assert_eq!(bcrypt_hash_fn.arity(), 2); + + let bcrypt_verify_fn = module.exports.get("bcrypt_verify").unwrap(); + assert_eq!(bcrypt_verify_fn.name(), "bcrypt_verify"); + assert_eq!(bcrypt_verify_fn.arity(), 2); + + let mut ctx = RuntimeContext::new(RuntimeConfig::default()); + + let key = RuntimeValue::Str("my_secret_key".to_string()); + let text = RuntimeValue::Str("hello world".to_string()); + + let encrypted = aes_encrypt_fn + .call(&mut ctx, vec![key.clone(), text.clone()]) + .unwrap(); + + let decrypted = aes_decrypt_fn + .call(&mut ctx, vec![key.clone(), encrypted]) + .unwrap(); + assert_eq!(decrypted, text); + + let password = RuntimeValue::Str("password123".to_string()); + let cost = RuntimeValue::Int(4); // low cost for fast test execution + + let hashed = bcrypt_hash_fn + .call(&mut ctx, vec![password.clone(), cost]) + .unwrap(); + + let verified = bcrypt_verify_fn + .call(&mut ctx, vec![password.clone(), hashed]) + .unwrap(); + assert_eq!(verified, RuntimeValue::Bool(true)); + } +} From 14e4404bf55ac07ffaa6e21239000fb8d4004631 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 19:03:57 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=A7=AA=20Add=20unit=20tests=20for=20r?= =?UTF-8?q?egister=5Fcrypto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> From 7e69bf90915cd03f88be174d9ee8e49fa736b1b2 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 28 Oct 2026 00:30:18 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=A7=AA=20Add=20unit=20tests=20for=20r?= =?UTF-8?q?egister=5Fcrypto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com>