feat: Migrate SAL to Cargo workspace
- Migrate individual modules to independent crates - Refactor dependencies for improved modularity - Update build system and testing infrastructure - Update documentation to reflect new structure
This commit is contained in:
		| @@ -1,5 +1,12 @@ | ||||
| use rhai::{Engine, EvalAltResult}; | ||||
| use sal_vault::rhai::*; | ||||
| use std::sync::Mutex; | ||||
|  | ||||
| // NOTE: These tests use global state (SESSION and KEYSPACE_REGISTRY) and are automatically | ||||
| // serialized using a global mutex to prevent test interference during parallel execution. | ||||
|  | ||||
| // Global test mutex to ensure tests run sequentially | ||||
| static TEST_MUTEX: Mutex<()> = Mutex::new(()); | ||||
|  | ||||
| #[cfg(test)] | ||||
| mod rhai_integration_tests { | ||||
| @@ -13,6 +20,7 @@ mod rhai_integration_tests { | ||||
|  | ||||
|     #[test] | ||||
|     fn test_rhai_module_registration() { | ||||
|         let _guard = TEST_MUTEX.lock().unwrap(); | ||||
|         let engine = create_test_engine(); | ||||
|  | ||||
|         // Test that the functions are registered by checking if they exist | ||||
| @@ -32,6 +40,7 @@ mod rhai_integration_tests { | ||||
|  | ||||
|     #[test] | ||||
|     fn test_symmetric_encryption_functions() { | ||||
|         let _guard = TEST_MUTEX.lock().unwrap(); | ||||
|         let engine = create_test_engine(); | ||||
|  | ||||
|         let script = r#" | ||||
| @@ -52,6 +61,7 @@ mod rhai_integration_tests { | ||||
|  | ||||
|     #[test] | ||||
|     fn test_keyspace_functions() { | ||||
|         let _guard = TEST_MUTEX.lock().unwrap(); | ||||
|         let engine = create_test_engine(); | ||||
|  | ||||
|         let script = r#" | ||||
| @@ -78,6 +88,7 @@ mod rhai_integration_tests { | ||||
|  | ||||
|     #[test] | ||||
|     fn test_keypair_functions() { | ||||
|         let _guard = TEST_MUTEX.lock().unwrap(); | ||||
|         let engine = create_test_engine(); | ||||
|  | ||||
|         let script = r#" | ||||
| @@ -116,6 +127,7 @@ mod rhai_integration_tests { | ||||
|  | ||||
|     #[test] | ||||
|     fn test_signing_functions() { | ||||
|         let _guard = TEST_MUTEX.lock().unwrap(); | ||||
|         let engine = create_test_engine(); | ||||
|  | ||||
|         let script = r#" | ||||
| @@ -157,6 +169,7 @@ mod rhai_integration_tests { | ||||
|  | ||||
|     #[test] | ||||
|     fn test_session_management() { | ||||
|         let _guard = TEST_MUTEX.lock().unwrap(); | ||||
|         let engine = create_test_engine(); | ||||
|  | ||||
|         let script = r#" | ||||
| @@ -169,7 +182,8 @@ mod rhai_integration_tests { | ||||
|              | ||||
|             // Test listing keyspaces | ||||
|             let spaces = list_keyspaces(); | ||||
|             if spaces.len() < 2 { | ||||
|             let space_count = count_keyspaces(); | ||||
|             if space_count < 2 { | ||||
|                 throw "Should have at least 2 keyspaces"; | ||||
|             } | ||||
|              | ||||
| @@ -182,7 +196,8 @@ mod rhai_integration_tests { | ||||
|              | ||||
|             // Test listing keypairs in current space | ||||
|             let keypairs = list_keypairs(); | ||||
|             if keypairs.len() != 1 { | ||||
|             let keypair_count = count_keypairs(); | ||||
|             if keypair_count != 1 { | ||||
|                 throw "Should have exactly 1 keypair in space2"; | ||||
|             } | ||||
|              | ||||
| @@ -199,6 +214,7 @@ mod rhai_integration_tests { | ||||
|  | ||||
|     #[test] | ||||
|     fn test_error_handling() { | ||||
|         let _guard = TEST_MUTEX.lock().unwrap(); | ||||
|         let engine = create_test_engine(); | ||||
|  | ||||
|         let script = r#" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user