MCPcopy Create free account
hub / github.com/AI45Lab/Code / test_multiple_confirmations

Function test_multiple_confirmations

core/src/hitl.rs:822–857  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

820
821 #[tokio::test]
822 async fn test_multiple_confirmations() {
823 let (event_tx, _) = broadcast::channel(100);
824 let manager = ConfirmationManager::new(ConfirmationPolicy::enabled(), event_tx);
825
826 // Request multiple confirmations
827 let rx1 = manager
828 .request_confirmation("tool-1", "bash", &serde_json::json!({"cmd": "1"}))
829 .await;
830 let rx2 = manager
831 .request_confirmation("tool-2", "write", &serde_json::json!({"cmd": "2"}))
832 .await;
833 let rx3 = manager
834 .request_confirmation("tool-3", "edit", &serde_json::json!({"cmd": "3"}))
835 .await;
836
837 // Check pending count
838 assert_eq!(manager.pending_count().await, 3);
839
840 // Approve tool-1
841 manager.confirm("tool-1", true, None).await.unwrap();
842 let response1 = rx1.await.unwrap();
843 assert!(response1.approved);
844
845 // Reject tool-2
846 manager.confirm("tool-2", false, None).await.unwrap();
847 let response2 = rx2.await.unwrap();
848 assert!(!response2.approved);
849
850 // Approve tool-3
851 manager.confirm("tool-3", true, None).await.unwrap();
852 let response3 = rx3.await.unwrap();
853 assert!(response3.approved);
854
855 // All confirmations processed
856 assert_eq!(manager.pending_count().await, 0);
857 }
858
859 #[tokio::test]
860 async fn test_pending_confirmations_info() {

Callers

nothing calls this directly

Calls 2

request_confirmationMethod · 0.45
confirmMethod · 0.45

Tested by

no test coverage detected