-
Notifications
You must be signed in to change notification settings - Fork 391
fix: deflake //rs/tests/idx:ii_delegation_test #9305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
cafaee7
32d8398
cec2b32
0d6abf7
9b6948b
7cff199
040c3ef
b4000a7
8f9865e
e88ab19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||||||||||||||||||||||
| use crate::util::{expiry_time, sign_query, sign_update}; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| use super::sign_read_state; | ||||||||||||||||||||||||
| use anyhow::{Context, bail}; | ||||||||||||||||||||||||
| use candid::{CandidType, Deserialize, Principal}; | ||||||||||||||||||||||||
| use canister_test::PrincipalId; | ||||||||||||||||||||||||
| use ic_agent::Agent; | ||||||||||||||||||||||||
|
|
@@ -16,9 +17,11 @@ use ic_universal_canister::{UNIVERSAL_CANISTER_WASM, wasm}; | |||||||||||||||||||||||
| use ic_utils::interfaces::ManagementCanister; | ||||||||||||||||||||||||
| use reqwest::{Client, Response}; | ||||||||||||||||||||||||
| use serde_bytes::ByteBuf; | ||||||||||||||||||||||||
| use std::time::{Duration, Instant}; | ||||||||||||||||||||||||
| use std::time::Duration; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| pub const UPDATE_POLLING_TIMEOUT: Duration = Duration::from_secs(60); | ||||||||||||||||||||||||
| pub const UPDATE_POLLING_BACKOFF: Duration = Duration::from_millis(500); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| pub const UPDATE_POLLING_TIMEOUT: Duration = Duration::from_secs(10); | ||||||||||||||||||||||||
| /// user ids start with 10000 and increase by 1 for each new user | ||||||||||||||||||||||||
| pub const USER_NUMBER_OFFSET: u64 = 10_000; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -122,6 +125,7 @@ pub struct AgentWithDelegation<'a> { | |||||||||||||||||||||||
| pub signed_delegation: SignedDelegation, | ||||||||||||||||||||||||
| pub delegation_identity: &'a BasicIdentity, | ||||||||||||||||||||||||
| pub polling_timeout: Duration, | ||||||||||||||||||||||||
| pub log: slog::Logger, | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| impl AgentWithDelegation<'_> { | ||||||||||||||||||||||||
|
|
@@ -130,7 +134,7 @@ impl AgentWithDelegation<'_> { | |||||||||||||||||||||||
| method: &str, | ||||||||||||||||||||||||
| canister_id: &Principal, | ||||||||||||||||||||||||
| body: Vec<u8>, | ||||||||||||||||||||||||
| ) -> Response { | ||||||||||||||||||||||||
| ) -> anyhow::Result<Response> { | ||||||||||||||||||||||||
| let client = Client::new(); | ||||||||||||||||||||||||
| client | ||||||||||||||||||||||||
| .post(format!( | ||||||||||||||||||||||||
|
|
@@ -143,7 +147,7 @@ impl AgentWithDelegation<'_> { | |||||||||||||||||||||||
| .body(body) | ||||||||||||||||||||||||
| .send() | ||||||||||||||||||||||||
| .await | ||||||||||||||||||||||||
| .unwrap() | ||||||||||||||||||||||||
| .context(format!("failed to send {method} request to {canister_id}")) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| .context(format!("failed to send {method} request to {canister_id}")) | |
| .with_context(|| format!("failed to send {method} request to {canister_id}")) |
Copilot
AI
Mar 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update() ignores the HTTP response status from the call endpoint. If the replica returns a non-success status (e.g., 4xx/5xx), the code will still return a request_id and then update_and_wait may poll until timeout with a misleading error. Consider failing fast by checking the HTTP status (e.g., via error_for_status or an explicit status check) before returning Ok(request_id).
| let _ = self | |
| .send_http_request("call", canister_id, body) | |
| .await | |
| .context("failed to send update call")?; | |
| let response = self | |
| .send_http_request("call", canister_id, body) | |
| .await | |
| .context("failed to send update call")?; | |
| if !response.status().is_success() { | |
| bail!("update call failed with HTTP status: {}", response.status()); | |
| } |
Copilot
AI
Mar 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
query() returns anyhow::Result, but serde_cbor::ser::to_vec(&envelope).unwrap() can still panic and bypass the new error handling path. Prefer returning a contextual error instead of unwrapping.
| let body = serde_cbor::ser::to_vec(&envelope).unwrap(); | |
| let body = serde_cbor::ser::to_vec(&envelope) | |
| .context("failed to serialize query envelope")?; |
Uh oh!
There was an error while loading. Please reload this page.