diff --git a/rs/pocket_ic_server/CHANGELOG.md b/rs/pocket_ic_server/CHANGELOG.md index ab99557c7a6..c814a0a9a4f 100644 --- a/rs/pocket_ic_server/CHANGELOG.md +++ b/rs/pocket_ic_server/CHANGELOG.md @@ -20,6 +20,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Canisters created via `provisional_create_canister_with_cycles` with the management canister ID as the effective canister ID are created on an arbitrary subnet. +### Removed +- The endpoint `/instances//update/execute_ingress_message`: + use the two endpoints `/instances//update/submit_ingress_message` and `/instances//update/await_ingress_message` + to submit and then await an ingress message instead. + ## 7.0.0 - 2024-11-13 diff --git a/rs/pocket_ic_server/src/pocket_ic.rs b/rs/pocket_ic_server/src/pocket_ic.rs index f0f98d27ff5..220099396b0 100644 --- a/rs/pocket_ic_server/src/pocket_ic.rs +++ b/rs/pocket_ic_server/src/pocket_ic.rs @@ -1645,71 +1645,6 @@ impl Operation for AwaitIngressMessage { } } -#[derive(Clone, Debug)] -pub struct ExecuteIngressMessage(pub CanisterCall); - -impl Operation for ExecuteIngressMessage { - fn compute(&self, pic: &mut PocketIc) -> OpOut { - let canister_call = self.0.clone(); - let subnet = route_call(pic, canister_call); - match subnet { - Ok(subnet) => { - match subnet.submit_ingress_as( - self.0.sender, - self.0.canister_id, - self.0.method.clone(), - self.0.payload.clone(), - ) { - Err(SubmitIngressError::HttpError(e)) => { - eprintln!("Failed to submit ingress message: {}", e); - OpOut::Error(PocketIcError::BadIngressMessage(e)) - } - Err(SubmitIngressError::UserError(e)) => { - eprintln!("Failed to submit ingress message: {:?}", e); - Err::(e).into() - } - Ok(msg_id) => { - // Now, we execute on all subnets until we have the result - let max_rounds = 100; - for _i in 0..max_rounds { - for subnet_ in pic.subnets.get_all() { - subnet_.state_machine.execute_round(); - } - match subnet.ingress_status(&msg_id) { - IngressStatus::Known { - state: IngressState::Completed(result), - .. - } => return Ok(result).into(), - IngressStatus::Known { - state: IngressState::Failed(error), - .. - } => { - return Err::< - ic_state_machine_tests::WasmResult, - ic_state_machine_tests::UserError, - >(error) - .into() - } - _ => {} - } - } - OpOut::Error(PocketIcError::BadIngressMessage(format!( - "Failed to answer to ingress {} after {} rounds.", - msg_id, max_rounds - ))) - } - } - } - Err(e) => OpOut::Error(PocketIcError::BadIngressMessage(e)), - } - } - - fn id(&self) -> OpId { - let call_id = self.0.id(); - OpId(format!("canister_update_{}", call_id.0)) - } -} - #[derive(Clone, Debug)] pub struct IngressMessageStatus { pub message_id: MessageId, diff --git a/rs/pocket_ic_server/src/state_api/routes.rs b/rs/pocket_ic_server/src/state_api/routes.rs index add5a1e0d39..327a5ae7621 100644 --- a/rs/pocket_ic_server/src/state_api/routes.rs +++ b/rs/pocket_ic_server/src/state_api/routes.rs @@ -8,9 +8,9 @@ use super::state::{ApiState, OpOut, PocketIcError, StateLabel, UpdateReply}; use crate::pocket_ic::{ AddCycles, AwaitIngressMessage, CallRequest, CallRequestVersion, CanisterReadStateRequest, - DashboardRequest, ExecuteIngressMessage, GetCanisterHttp, GetControllers, GetCyclesBalance, - GetStableMemory, GetSubnet, GetTime, GetTopology, IngressMessageStatus, MockCanisterHttp, - PubKey, Query, QueryRequest, SetStableMemory, SetTime, StatusRequest, SubmitIngressMessage, + DashboardRequest, GetCanisterHttp, GetControllers, GetCyclesBalance, GetStableMemory, + GetSubnet, GetTime, GetTopology, IngressMessageStatus, MockCanisterHttp, PubKey, Query, + QueryRequest, SetStableMemory, SetTime, StatusRequest, SubmitIngressMessage, SubnetReadStateRequest, Tick, }; use crate::{async_trait, pocket_ic::PocketIc, BlobStore, InstanceId, OpId, Operation}; @@ -98,10 +98,6 @@ where "/await_ingress_message", post(handler_await_ingress_message), ) - .directory_route( - "/execute_ingress_message", - post(handler_execute_ingress_message), - ) .directory_route("/set_time", post(handler_set_time)) .directory_route("/add_cycles", post(handler_add_cycles)) .directory_route("/set_stable_memory", post(handler_set_stable_memory)) @@ -1019,28 +1015,6 @@ pub async fn handler_await_ingress_message( } } -pub async fn handler_execute_ingress_message( - State(AppState { api_state, .. }): State, - Path(instance_id): Path, - headers: HeaderMap, - extract::Json(raw_canister_call): extract::Json, -) -> (StatusCode, Json>) { - let timeout = timeout_or_default(headers); - match crate::pocket_ic::CanisterCall::try_from(raw_canister_call) { - Ok(canister_call) => { - let ingress_op = ExecuteIngressMessage(canister_call); - let (code, response) = run_operation(api_state, instance_id, timeout, ingress_op).await; - (code, Json(response)) - } - Err(e) => ( - StatusCode::BAD_REQUEST, - Json(ApiResponse::Error { - message: format!("{:?}", e), - }), - ), - } -} - pub async fn handler_ingress_status( State(AppState { api_state, .. }): State, Path(instance_id): Path,