pub struct MockCanisterHttpResponse {
pub subnet_id: Principal,
pub request_id: u64,
pub response: CanisterHttpResponse,
pub additional_responses: Vec<CanisterHttpResponse>,
}Expand description
Mocked responses to a pending canister HTTP outcall made through the
http_request management canister endpoint — whether fully replicated or
non-replicated (see CanisterHttpReplication). A flexible outcall is
answered with MockFlexibleCanisterHttpResponse instead.
This answers for every node of the subnet, which is what an http_request
outcall needs: a fully replicated one is performed by all of them, and a
non-replicated one by a single node that is not exposed. It is therefore also
the only shape that can make the nodes of a fully replicated outcall disagree
(see additional_responses).
An http_request outcall answered this way reports one of:
- the mocked response — as a reply, or as a rejection of the calling canister’s call carrying the mocked code and message;
SysTransientand “No consensus could be reached” if its nodes disagree (seeadditional_responses; a non-replicated outcall has no such outcome, it just delivers its designated node’s response);SysTransientand “Out of cycles” if what the nodes left unspent of their per-replica cycles allowances no longer covers putting a response into a block;SysTransientand “Canister http request timed out” once the outcall is older than its 60 second timeout.
Fields§
§subnet_id: Principal§request_id: u64§response: CanisterHttpResponseThe response every node of the subnet reports, unless
additional_responses is non-empty — in which case this is the response of
one node and additional_responses holds the rest.
With this response alone, all nodes agree, so a fully replicated outcall
delivers it (see CanisterHttpReplication::FullyReplicated).
additional_responses: Vec<CanisterHttpResponse>The responses of the remaining nodes of the subnet. Either empty — then
response is used for every node — or exactly one short of the subnet size,
so that together with response there is one response per node.
This is how a test makes the nodes of a fully replicated outcall disagree:
unless n - f of the n responses are equal, it fails with a “no consensus
could be reached” rejection.
A non-replicated outcall has nothing to disagree about — only its designated node’s response is delivered, and PocketIC does not report which node that is — so differing responses merely make the delivered one unpredictable. Leave this empty unless the disagreement is what is under test.
Trait Implementations§
Source§impl Clone for MockCanisterHttpResponse
impl Clone for MockCanisterHttpResponse
Source§impl Debug for MockCanisterHttpResponse
impl Debug for MockCanisterHttpResponse
Source§impl<'de> Deserialize<'de> for MockCanisterHttpResponse
impl<'de> Deserialize<'de> for MockCanisterHttpResponse
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for MockCanisterHttpResponse
Source§impl From<MockCanisterHttpResponse> for RawMockCanisterHttpResponse
impl From<MockCanisterHttpResponse> for RawMockCanisterHttpResponse
Source§fn from(mock_canister_http_response: MockCanisterHttpResponse) -> Self
fn from(mock_canister_http_response: MockCanisterHttpResponse) -> Self
Source§impl From<RawMockCanisterHttpResponse> for MockCanisterHttpResponse
impl From<RawMockCanisterHttpResponse> for MockCanisterHttpResponse
Source§fn from(raw_mock_canister_http_response: RawMockCanisterHttpResponse) -> Self
fn from(raw_mock_canister_http_response: RawMockCanisterHttpResponse) -> Self
Source§impl Hash for MockCanisterHttpResponse
impl Hash for MockCanisterHttpResponse
Source§impl Ord for MockCanisterHttpResponse
impl Ord for MockCanisterHttpResponse
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for MockCanisterHttpResponse
impl PartialEq for MockCanisterHttpResponse
Source§impl PartialOrd for MockCanisterHttpResponse
impl PartialOrd for MockCanisterHttpResponse
Source§impl Serialize for MockCanisterHttpResponse
impl Serialize for MockCanisterHttpResponse
impl StructuralPartialEq for MockCanisterHttpResponse
Auto Trait Implementations§
impl Freeze for MockCanisterHttpResponse
impl RefUnwindSafe for MockCanisterHttpResponse
impl Send for MockCanisterHttpResponse
impl Sync for MockCanisterHttpResponse
impl Unpin for MockCanisterHttpResponse
impl UnsafeUnpin for MockCanisterHttpResponse
impl UnwindSafe for MockCanisterHttpResponse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.