Skip to main content

Overrides

Struct Overrides 

Source
pub struct Overrides {
Show 22 fields pub degrade_health: bool, pub health_503: bool, pub force_unauthorized: bool, pub force_not_found: bool, pub force_server_error: bool, pub force_empty_evaluation: bool, pub force_empty_regime: bool, pub force_regime_error_envelope: bool, pub force_approaching_not_found: bool, pub force_stale_risk_equity: bool, pub transient_fail_count: u32, pub rate_limit_count: u32, pub rate_limit_retry_after: Option<String>, pub version: Option<String>, pub ws_drop_once: bool, pub operator_label: Option<String>, pub operator_version: u64, pub auto_toggle_echo_state: Option<bool>, pub auto_toggle_reason: Option<String>, pub force_simulated: bool, pub post_transient_fail: bool, pub post_server_error: bool,
}
Expand description

Overrides the test can inject to simulate engine states.

Fields§

§degrade_health: bool

Force /health status to "degraded" with a custom component.

§health_503: bool

Return 503 on /health (simulate overloaded engine).

§force_unauthorized: bool

Return 401 on every typed GET endpoint other than / and /health. Exercises [HttpClient]’s auth-error mapping path (HttpError::Unauthorized). The version probe and health surface stay open because the CLI uses them during doctor runs before auth is wired.

§force_not_found: bool

Return 404 on every typed GET endpoint (same scope as Self::force_unauthorized). Tests [HttpError::NotFound] mapping and the client’s missing-endpoint log behavior.

§force_server_error: bool

Return 500 on every typed GET endpoint. Non-retryable — asserts that the client does not double-call on a server error that isn’t 502/503/504.

§force_empty_evaluation: bool

Return a degenerate-but-valid 200 on /evaluate/{coin} — the JSON decodes, but layers is empty and direction is absent. Exercises the dispatcher’s empty-verdict guard (evaluate_cmd must emit an alert + dismiss stale overlays instead of opening an empty verdict card). Does not affect any other endpoint.

§force_empty_regime: bool

Return {} (HTTP 200) on /regime. Matches a real production failure mode where the engine exposes the endpoint but never populates a payload. The dispatcher must alert the operator instead of rendering a row of em-dashes that looks like data.

§force_regime_error_envelope: bool

Return {"error": "<msg>"} (HTTP 200) on /regime. Matches the engine’s “coin not found” envelope on ?coin=.... The dispatcher must surface the embedded error as an alert.

§force_approaching_not_found: bool

Return 404 on /approaching. Matches older engine builds that predate the endpoint. The dispatcher must detect the NotFound and emit an explanatory alert instead of the raw "not found: /approaching" error-display.

§force_stale_risk_equity: bool

Return a /risk payload where account_value > peak_equity (mathematically impossible by definition — peak is monotonic max of equity). Mirrors a real production drift where the engine kept writing risk.json with a stale equity number that no live code path refreshed while the portfolio snapshot was fresh. The dispatcher must surface the contradiction instead of rendering a confident (but wrong) drawdown percent.

§transient_fail_count: u32

How many further requests should respond with a transient 503 before the real handler runs. Decremented atomically per matched request. Used to verify the retry-once policy (HttpClient::get_json) recovers when the first attempt fails with 503 and the second succeeds. Setting this to >= 2 lets the test observe the retry limit: after one retry, the second failure surfaces as HttpError::Status.

§rate_limit_count: u32

How many further requests should respond with a 429 Too Many Requests before the real handler runs. Sister field to Self::transient_fail_count; separated so a test can pin engine-429 behavior without also exercising the transient-retry code path.

When this fires, the response body is empty and the Retry-After header carries Self::rate_limit_retry_after (or a sensible default when unset). The CLI’s HttpClient parses the header, refunds the local bucket, and surfaces HttpError::RateBudgetExhausted { origin: Engine429, .. }.

§rate_limit_retry_after: Option<String>

Value placed in the Retry-After header on every injected 429. Accepts any string the real engine might emit — plain integer seconds ("30") or an RFC-7231 IMF-fixdate ("Fri, 31 Dec 1999 23:59:59 GMT"). When None (default), the header carries "1" so tests inspecting the client’s parsed duration see an unambiguous 1 s rather than having to reason about a missing header’s fallback.

§version: Option<String>

Custom version string for GET /.

§ws_drop_once: bool

Cause the /ws handler to immediately close the connection after accepting the upgrade, exercising the subscriber’s reconnect path. Resets to false automatically after one drop so a test can: set → wait for drop → unset → verify reconnect succeeds.

§operator_label: Option<String>

Operator-state label the /operator/state endpoint reports. Defaults to "steady" when unset. Valid values match zero_operator_state::Label snake-case: fresh, steady, elevated, tilt, fatigued, recovery.

§operator_version: u64

Monotonic version bumped on each change to operator_label in tests that want to exercise the widget’s version-skip logic. Auto-increments when tests flip the label via with_overrides.

§auto_toggle_echo_state: Option<bool>

Engine-side /auto/toggle state the mock echoes back to the next POST /auto/toggle caller. Tests asserting the “engine refuses the flip” path pre-set this to a value that differs from the request, so the response state reflects the engine’s truth rather than the caller’s wish. None means “mirror the request” (happy path).

§auto_toggle_reason: Option<String>

Optional reason string the mock returns alongside auto_toggle_echo_state — used to pin the refusal path (e.g. "operator state is TILT"). Emitted verbatim.

§force_simulated: bool

When set, every POST /execute and POST /auto/toggle response carries "simulated": true regardless of the X-Zero-Mode header the client sent. Used by tests that want to assert the client surfaces the engine’s truth rather than locally inferring paper from its own --paper flag. In production the engine flips this based on the inbound header; the mock lets tests drive either path.

§post_transient_fail: bool

When set, POST /execute and POST /auto/toggle return a single 503. Verifies that no silent retry fires on the no-retry POST surface — the caller sees exactly one upstream request with a typed HttpError::Status back.

§post_server_error: bool

When set, POST /execute returns 500. Same intent as Self::post_transient_fail but for a non-retryable status; belt-and-suspenders against any future change to is_retryable accidentally catching the 500 family.

Trait Implementations§

Source§

impl Clone for Overrides

Source§

fn clone(&self) -> Overrides

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Overrides

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Overrides

Source§

fn default() -> Overrides

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,