Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Policies under `core/`; relocated `oath-net-core` to `oath-adapter-net-api`; and
added `oath-core-api`, `oath-core-kernel`, and the `oath-core`, `oath-strategy-host`,
`oath-cli`, and `oath-supervisor` process crates.
- `MockTimer` relocated from `oath-adapter-net-http-mock` into a new dev-only
`oath-adapter-net-mock` crate beside the `Timer` contract in
`oath-adapter-net-api`, so the HTTP and (forthcoming) WebSocket mock stacks
share one fake clock without cross-depending (ADR-0034 §Amendments.4).
`oath-adapter-net-http-mock` now provides only `MockClient`/`MockBody`.

### Added

Expand Down
17 changes: 12 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ resolver = "3"
members = [
"crates/model",
"crates/adapter/net/api",
"crates/adapter/net/mock",
"crates/adapter/net/http/api",
"crates/adapter/net/http/mock",
"crates/adapter/net/ws/api",
Expand Down Expand Up @@ -44,6 +45,7 @@ categories = ["finance", "asynchronous"]
# does not treat { workspace = true } path deps as wildcard requirements.
oath-model = { path = "crates/model", version = "0.1.0" }
oath-adapter-net-api = { path = "crates/adapter/net/api", version = "0.1.0" }
oath-adapter-net-mock = { path = "crates/adapter/net/mock", version = "0.1.0" }
oath-adapter-net-http-api = { path = "crates/adapter/net/http/api", version = "0.1.0" }
oath-adapter-net-http-mock = { path = "crates/adapter/net/http/mock", version = "0.1.0" }
oath-adapter-net-ws-api = { path = "crates/adapter/net/ws/api", version = "0.1.0" }
Expand Down
1 change: 0 additions & 1 deletion crates/adapter/net/http/mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ license.workspace = true
workspace = true

[dependencies]
oath-adapter-net-api = { workspace = true }
oath-adapter-net-http-api = { workspace = true }
http = { workspace = true }
bytes = { workspace = true }
Expand Down
9 changes: 4 additions & 5 deletions crates/adapter/net/http/mock/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
//! Test harness for the net-http stack: a canned-response `MockClient` leaf, a
//! frame-controllable `MockBody`, and a `MockTimer` virtual clock. Consumed by
//! downstream crates via `[dev-dependencies]` only — it has no production edge.
//! Test harness for the net-http stack: a canned-response `MockClient` leaf and
//! a frame-controllable `MockBody`. Consumed by downstream crates via
//! `[dev-dependencies]` only — it has no production edge. (The `MockTimer`
//! virtual clock now lives in the transport-neutral `oath-adapter-net-mock`.)
#![forbid(unsafe_code)]

pub mod body;
pub mod client;
pub mod timer;

pub use body::MockBody;
pub use client::MockClient;
pub use timer::MockTimer;

use std::sync::{Mutex, MutexGuard, PoisonError};

Expand Down
15 changes: 15 additions & 0 deletions crates/adapter/net/mock/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "oath-adapter-net-mock"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true

[lints]
workspace = true

[dependencies]
oath-adapter-net-api = { workspace = true }

[dev-dependencies]
tokio = { workspace = true }
17 changes: 17 additions & 0 deletions crates/adapter/net/mock/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//! Transport-neutral test doubles for the net adapter stack: a `MockTimer`
//! virtual clock beside the `Timer` contract in `oath-adapter-net-api`. Consumed
//! via `[dev-dependencies]` only — it has no production edge, so the HTTP and WS
//! stacks can fake the same clock without dev-depending on each other's mock.
#![forbid(unsafe_code)]

pub mod timer;

pub use timer::MockTimer;

use std::sync::{Mutex, MutexGuard, PoisonError};

/// Lock `mutex`, recovering the guard if a panic poisoned it — mock state stays
/// usable so a failing test reports its own assertion, not a poison panic.
fn lock<T>(mutex: &Mutex<T>) -> MutexGuard<'_, T> {
mutex.lock().unwrap_or_else(PoisonError::into_inner)
}
Loading