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

Function test_timeout_reject

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

Source from the content-addressed store, hash-verified

951
952 #[tokio::test]
953 async fn test_timeout_reject() {
954 let (event_tx, mut event_rx) = broadcast::channel(100);
955 let policy = ConfirmationPolicy {
956 enabled: true,
957 default_timeout_ms: 50, // Very short timeout for testing
958 timeout_action: TimeoutAction::Reject,
959 ..Default::default()
960 };
961 let manager = ConfirmationManager::new(policy, event_tx);
962
963 // Request confirmation
964 let rx = manager
965 .request_confirmation("tool-1", "bash", &serde_json::json!({}))
966 .await;
967
968 // Skip ConfirmationRequired event
969 let _ = event_rx.recv().await.unwrap();
970
971 // Wait for timeout
972 tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
973
974 // Check timeouts
975 let timed_out = manager.check_timeouts().await;
976 assert_eq!(timed_out, 1);
977
978 // Check timeout event
979 let event = event_rx.recv().await.unwrap();
980 match event {
981 AgentEvent::ConfirmationTimeout {
982 tool_id,
983 action_taken,
984 } => {
985 assert_eq!(tool_id, "tool-1");
986 assert_eq!(action_taken, "rejected");
987 }
988 _ => panic!("Expected ConfirmationTimeout event"),
989 }
990
991 // Check response indicates timeout rejection
992 let response = rx.await.unwrap();
993 assert!(!response.approved);
994 assert!(response.reason.as_ref().unwrap().contains("timed out"));
995 }
996
997 #[tokio::test]
998 async fn test_timeout_auto_approve() {

Callers

nothing calls this directly

Calls 2

request_confirmationMethod · 0.45
check_timeoutsMethod · 0.45

Tested by

no test coverage detected