change context syntax
This commit is contained in:
		| @@ -70,6 +70,6 @@ For each entry in `circles.json`, the launcher will: | ||||
| 1.  Generate a new `secp256k1` keypair. The public key becomes the Circle's unique identifier. | ||||
| 2.  Spawn the `worker` binary as a child OS process, passing it the public key and Redis URL. | ||||
| 3.  Initialize a `server_ws` instance on the specified port. | ||||
| 4.  If a `script_path` is provided, it reads the script and submits it as a task to the worker's Redis queue. The `CALLER_PUBLIC_KEY` for this initial script is set to the Circle's own public key. | ||||
| 4.  If a `script_path` is provided, it reads the script and submits it as a task to the worker's Redis queue. The `CALLER_ID` for this initial script is set to the Circle's own public key. | ||||
|  | ||||
| This makes it an ideal tool for setting up complex, multi-instance development environments or for deploying a full suite of Circle services with strong process isolation. | ||||
| @@ -64,10 +64,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||||
|  | ||||
|     let client = RhaiClient::new(REDIS_URL)?; | ||||
|  | ||||
|     // Test 1: Verify that CIRCLE_PUBLIC_KEY is set correctly. | ||||
|     println!("--- Test 1: Verifying CIRCLE_PUBLIC_KEY ---"); | ||||
|     let script_circle_pk = r#"CIRCLE_PUBLIC_KEY"#; | ||||
|     println!("Submitting script to verify CIRCLE_PUBLIC_KEY..."); | ||||
|     // Test 1: Verify that CONTEXT_ID is set correctly. | ||||
|     println!("--- Test 1: Verifying CONTEXT_ID ---"); | ||||
|     let script_circle_pk = r#"CONTEXT_ID"#; | ||||
|     println!("Submitting script to verify CONTEXT_ID..."); | ||||
|     let task_details_circle_pk = client | ||||
|         .submit_script_and_await_result( | ||||
|             &public_key, | ||||
| @@ -80,13 +80,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||||
|     println!("Received task details: {:?}", task_details_circle_pk); | ||||
|     assert_eq!(task_details_circle_pk.status, "completed"); | ||||
|     assert_eq!(task_details_circle_pk.output, Some(public_key.to_string())); | ||||
|     println!("✅ SUCCESS: Worker correctly reported its CIRCLE_PUBLIC_KEY."); | ||||
|     println!("✅ SUCCESS: Worker correctly reported its CONTEXT_ID."); | ||||
|  | ||||
|     // Test 2: Verify that CALLER_PUBLIC_KEY is set correctly when the launcher calls. | ||||
|     // Test 2: Verify that CALLER_ID is set correctly when the launcher calls. | ||||
|     // We simulate the launcher by passing the circle's own PK as the caller. | ||||
|     println!("\n--- Test 2: Verifying CALLER_PUBLIC_KEY for init scripts ---"); | ||||
|     let script_caller_pk = r#"CALLER_PUBLIC_KEY"#; | ||||
|     println!("Submitting script to verify CALLER_PUBLIC_KEY..."); | ||||
|     println!("\n--- Test 2: Verifying CALLER_ID for init scripts ---"); | ||||
|     let script_caller_pk = r#"CALLER_ID"#; | ||||
|     println!("Submitting script to verify CALLER_ID..."); | ||||
|     let task_details_caller_pk = client | ||||
|         .submit_script_and_await_result( | ||||
|             &public_key, | ||||
| @@ -99,7 +99,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||||
|     println!("Received task details: {:?}", task_details_caller_pk); | ||||
|     assert_eq!(task_details_caller_pk.status, "completed"); | ||||
|     assert_eq!(task_details_caller_pk.output, Some(public_key.to_string())); | ||||
|     println!("✅ SUCCESS: Worker correctly reported CALLER_PUBLIC_KEY for init script."); | ||||
|     println!("✅ SUCCESS: Worker correctly reported CALLER_ID for init script."); | ||||
|  | ||||
|     // Gracefully shut down the launcher | ||||
|     println!("Shutting down launcher process..."); | ||||
|   | ||||
| @@ -197,7 +197,7 @@ async fn test_full_end_to_end_example() -> Result<(), Box<dyn std::error::Error> | ||||
|     //     "print(\"Hello from authenticated client!\"); 42", | ||||
|     //     "let x = 10; let y = 20; x + y", | ||||
|     //     "print(\"Testing authentication...\"); \"success\"", | ||||
|     //     "CALLER_PUBLIC_KEY", | ||||
|     //     "CALLER_ID", | ||||
|     // ]; | ||||
|  | ||||
|     // for (i, script) in test_scripts.iter().enumerate() { | ||||
| @@ -206,9 +206,9 @@ async fn test_full_end_to_end_example() -> Result<(), Box<dyn std::error::Error> | ||||
|     //     match client.play(script.to_string()).await { | ||||
|     //         Ok(result) => { | ||||
|     //             info!("✅ Script {} result: {}", i + 1, result.output); | ||||
|     //             if script == &"CALLER_PUBLIC_KEY" { | ||||
|     //             if script == &"CALLER_ID" { | ||||
|     //                 assert_eq!(result.output, expected_public_key_hex); | ||||
|     //                 info!("✅ CALLER_PUBLIC_KEY verification successful!"); | ||||
|     //                 info!("✅ CALLER_ID verification successful!"); | ||||
|     //             } | ||||
|     //         } | ||||
|     //         Err(e) => { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user