@@ -60,21 +60,21 @@ impl WorkerApiClient {
6060 Self :: new ( & base_url)
6161 }
6262
63- /// Sends an exit cause for a post-compute operation to the Worker API.
63+ /// Sends exit causes for a post-compute operation to the Worker API.
6464 ///
65- /// This method reports the exit cause of a post-compute operation to the Worker API,
65+ /// This method reports the exit causes of a post-compute operation to the Worker API,
6666 /// which can be used for tracking and debugging purposes.
6767 ///
6868 /// # Arguments
6969 ///
7070 /// * `authorization` - The authorization token to use for the API request
71- /// * `chain_task_id` - The chain task ID for which to report the exit cause
72- /// * `exit_cause ` - The exit cause to report
71+ /// * `chain_task_id` - The chain task ID for which to report the exit causes
72+ /// * `exit_causes ` - The exit causes to report
7373 ///
7474 /// # Returns
7575 ///
76- /// * `Ok(())` - If the exit cause was successfully reported
77- /// * `Err(ReplicateStatusCause)` - If the exit cause could not be reported due to an HTTP error
76+ /// * `Ok(())` - If the exit causes were successfully reported
77+ /// * `Err(ReplicateStatusCause)` - If the exit causes could not be reported due to an HTTP error
7878 ///
7979 /// # Errors
8080 ///
@@ -92,22 +92,22 @@ impl WorkerApiClient {
9292 /// let client = WorkerApiClient::new("http://worker:13100");
9393 /// let exit_causes = vec![ReplicateStatusCause::PostComputeInvalidTeeSignature];
9494 ///
95- /// match client.send_exit_cause_for_post_compute_stage (
95+ /// match client.send_exit_causes_for_post_compute_stage (
9696 /// "authorization_token",
9797 /// "0x123456789abcdef",
9898 /// &exit_causes,
9999 /// ) {
100- /// Ok(()) => println!("Exit cause reported successfully"),
101- /// Err(error) => eprintln!("Failed to report exit cause : {}", error),
100+ /// Ok(()) => println!("Exit causes reported successfully"),
101+ /// Err(error) => eprintln!("Failed to report exit causes : {}", error),
102102 /// }
103103 /// ```
104- pub fn send_exit_cause_for_post_compute_stage (
104+ pub fn send_exit_causes_for_post_compute_stage (
105105 & self ,
106106 authorization : & str ,
107107 chain_task_id : & str ,
108108 exit_causes : & [ ReplicateStatusCause ] ,
109109 ) -> Result < ( ) , ReplicateStatusCause > {
110- let url = format ! ( "{}/compute/post/{chain_task_id}/exit" , self . base_url) ;
110+ let url = format ! ( "{}/compute/post/{chain_task_id}/exit-causes " , self . base_url) ;
111111 match self
112112 . client
113113 . post ( & url)
@@ -122,13 +122,13 @@ impl WorkerApiClient {
122122 let status = response. status ( ) ;
123123 let body = response. text ( ) . unwrap_or_default ( ) ;
124124 error ! (
125- "Failed to send exit cause to worker: [status:{status:?}, body:{body:#?}]"
125+ "Failed to send exit causes to worker: [status:{status:?}, body:{body:#?}]"
126126 ) ;
127127 Err ( ReplicateStatusCause :: PostComputeFailedUnknownIssue )
128128 }
129129 }
130130 Err ( e) => {
131- error ! ( "An error occured while sending exit cause to worker: {e}" ) ;
131+ error ! ( "An error occured while sending exit causes to worker: {e}" ) ;
132132 Err ( ReplicateStatusCause :: PostComputeFailedUnknownIssue )
133133 }
134134 }
@@ -232,7 +232,7 @@ mod tests {
232232
233233 // region serialize List of ReplicateStatusCause
234234 #[ test]
235- fn should_serialize_list_of_exit_causes ( ) {
235+ fn replicate_status_cause_serializes_as_json_array_when_multiple_causes ( ) {
236236 let causes = vec ! [
237237 ReplicateStatusCause :: PostComputeInvalidTeeSignature ,
238238 ReplicateStatusCause :: PostComputeWorkerAddressMissing ,
@@ -243,7 +243,7 @@ mod tests {
243243 }
244244
245245 #[ test]
246- fn should_serialize_single_exit_cause ( ) {
246+ fn replicate_status_cause_serializes_as_json_array_when_single_cause ( ) {
247247 let causes = vec ! [ ReplicateStatusCause :: PostComputeFailedUnknownIssue ] ;
248248 let serialized = to_string ( & causes) . expect ( "Failed to serialize" ) ;
249249 let expected = r#"[{"cause":"POST_COMPUTE_FAILED_UNKNOWN_ISSUE","message":"Unexpected error occurred"}]"# ;
@@ -253,7 +253,7 @@ mod tests {
253253
254254 // region get_worker_api_client
255255 #[ test]
256- fn should_get_worker_api_client_with_env_var ( ) {
256+ fn from_env_creates_client_with_custom_url_when_env_var_set ( ) {
257257 with_vars (
258258 vec ! [ ( WorkerHostEnvVar . name( ) , Some ( "custom-worker-host:9999" ) ) ] ,
259259 || {
@@ -264,24 +264,24 @@ mod tests {
264264 }
265265
266266 #[ test]
267- fn should_get_worker_api_client_without_env_var ( ) {
267+ fn from_env_creates_client_with_default_url_when_env_var_missing ( ) {
268268 with_vars ( vec ! [ ( WorkerHostEnvVar . name( ) , None :: <& str >) ] , || {
269269 let client = WorkerApiClient :: from_env ( ) ;
270270 assert_eq ! ( client. base_url, format!( "http://{DEFAULT_WORKER_HOST}" ) ) ;
271271 } ) ;
272272 }
273273 // endregion
274274
275- // region send_exit_cause_for_post_compute_stage ()
275+ // region send_exit_causes_for_post_compute_stage ()
276276 #[ tokio:: test]
277- async fn should_send_exit_cause ( ) {
277+ async fn send_exit_causes_for_post_compute_stage_succeeds_when_server_responds_ok ( ) {
278278 let mock_server = MockServer :: start ( ) . await ;
279279 let server_url = mock_server. uri ( ) ;
280280
281281 let expected_body = json ! ( [ ReplicateStatusCause :: PostComputeInvalidTeeSignature , ] ) ;
282282
283283 Mock :: given ( method ( "POST" ) )
284- . and ( path ( format ! ( "/compute/post/{CHAIN_TASK_ID}/exit" ) ) )
284+ . and ( path ( format ! ( "/compute/post/{CHAIN_TASK_ID}/exit-causes " ) ) )
285285 . and ( header ( "Authorization" , CHALLENGE ) )
286286 . and ( body_json ( & expected_body) )
287287 . respond_with ( ResponseTemplate :: new ( 200 ) )
@@ -292,7 +292,7 @@ mod tests {
292292 let result = tokio:: task:: spawn_blocking ( move || {
293293 let exit_causes = vec ! [ ReplicateStatusCause :: PostComputeInvalidTeeSignature ] ;
294294 let worker_api_client = WorkerApiClient :: new ( & server_url) ;
295- worker_api_client. send_exit_cause_for_post_compute_stage (
295+ worker_api_client. send_exit_causes_for_post_compute_stage (
296296 CHALLENGE ,
297297 CHAIN_TASK_ID ,
298298 & exit_causes,
@@ -306,7 +306,7 @@ mod tests {
306306
307307 #[ tokio:: test]
308308 #[ serial]
309- async fn should_not_send_exit_cause ( ) {
309+ async fn send_exit_causes_for_post_compute_stage_fails_when_server_returns_404 ( ) {
310310 {
311311 let mut logger = TEST_LOGGER . lock ( ) . unwrap ( ) ;
312312 while logger. pop ( ) . is_some ( ) { }
@@ -315,7 +315,7 @@ mod tests {
315315 let server_url = mock_server. uri ( ) ;
316316
317317 Mock :: given ( method ( "POST" ) )
318- . and ( path ( format ! ( "/compute/post/{CHAIN_TASK_ID}/exit" ) ) )
318+ . and ( path ( format ! ( "/compute/post/{CHAIN_TASK_ID}/exit-causes " ) ) )
319319 . respond_with ( ResponseTemplate :: new ( 404 ) )
320320 . expect ( 1 )
321321 . mount ( & mock_server)
@@ -324,7 +324,7 @@ mod tests {
324324 let result = tokio:: task:: spawn_blocking ( move || {
325325 let exit_causes = vec ! [ ReplicateStatusCause :: PostComputeFailedUnknownIssue ] ;
326326 let worker_api_client = WorkerApiClient :: new ( & server_url) ;
327- worker_api_client. send_exit_cause_for_post_compute_stage (
327+ worker_api_client. send_exit_causes_for_post_compute_stage (
328328 CHALLENGE ,
329329 CHAIN_TASK_ID ,
330330 & exit_causes,
@@ -356,7 +356,7 @@ mod tests {
356356
357357 // region send_computed_file_to_host()
358358 #[ tokio:: test]
359- async fn should_send_computed_file_successfully ( ) {
359+ async fn send_computed_file_to_host_succeeds_when_server_responds_ok ( ) {
360360 let mock_server = MockServer :: start ( ) . await ;
361361 let server_uri = mock_server. uri ( ) ;
362362
@@ -391,7 +391,7 @@ mod tests {
391391
392392 #[ tokio:: test]
393393 #[ serial]
394- async fn should_fail_send_computed_file_on_server_error ( ) {
394+ async fn send_computed_file_to_host_fails_when_server_returns_500 ( ) {
395395 {
396396 let mut logger = TEST_LOGGER . lock ( ) . unwrap ( ) ;
397397 while logger. pop ( ) . is_some ( ) { }
@@ -445,7 +445,7 @@ mod tests {
445445
446446 #[ tokio:: test]
447447 #[ serial]
448- async fn should_handle_invalid_chain_task_id_in_url ( ) {
448+ async fn send_computed_file_to_host_fails_when_chain_task_id_invalid ( ) {
449449 {
450450 let mut logger = TEST_LOGGER . lock ( ) . unwrap ( ) ;
451451 while logger. pop ( ) . is_some ( ) { }
@@ -486,7 +486,7 @@ mod tests {
486486 }
487487
488488 #[ tokio:: test]
489- async fn should_send_computed_file_with_minimal_data ( ) {
489+ async fn send_computed_file_to_host_succeeds_when_minimal_data_provided ( ) {
490490 let mock_server = MockServer :: start ( ) . await ;
491491 let server_uri = mock_server. uri ( ) ;
492492
0 commit comments