Skip to content

Commit c36dfd1

Browse files
committed
Make cargo test --doc happy
1 parent c696bbf commit c36dfd1

File tree

12 files changed

+109
-34
lines changed

12 files changed

+109
-34
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/src/commands/node/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,17 @@ pub struct Node {
122122
/// Multiaddresses follow the format: `/protocol/address/protocol/port/protocol/peer_id`
123123
///
124124
/// **IPv4 Example:**
125-
/// ```
125+
/// ```ignore
126126
/// /ip4/192.168.1.100/tcp/8302/p2p/12D3KooWABCDEF1234567890abcdef...
127127
/// ```
128128
///
129129
/// **IPv6 Example:**
130-
/// ```
130+
/// ```ignore
131131
/// /ip6/2001:db8::1/tcp/8302/p2p/12D3KooWABCDEF1234567890abcdef...
132132
/// ```
133133
///
134134
/// **DNS Example:**
135-
/// ```
135+
/// ```ignore
136136
/// /dns4/node.example.com/tcp/8302/p2p/12D3KooWABCDEF1234567890abcdef...
137137
/// ```
138138
///
@@ -149,7 +149,7 @@ pub struct Node {
149149
/// Each line should contain a peer's multiaddr following the format described above.
150150
///
151151
/// **Example file content:**
152-
/// ```
152+
/// ```ignore
153153
/// /ip4/192.168.1.100/tcp/8302/p2p/12D3KooWABCDEF1234567890abcdef...
154154
/// /ip4/10.0.0.50/tcp/8302/p2p/12D3KooWXYZ9876543210fedcba...
155155
/// /dns4/bootstrap.example.com/tcp/8302/p2p/12D3KooW123ABC...
@@ -166,7 +166,7 @@ pub struct Node {
166166
/// Useful for dynamic peer discovery from a central bootstrap service.
167167
///
168168
/// **Example URL response:**
169-
/// ```
169+
/// ```ignore
170170
/// /ip4/bootstrap1.example.com/tcp/8302/p2p/12D3KooW...
171171
/// /ip4/bootstrap2.example.com/tcp/8302/p2p/12D3KooX...
172172
/// ```

macros/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ syn = { workspace = true }
1515

1616
[dev-dependencies]
1717
mina-core = { path = "../core" }
18+
redux = { workspace = true }
1819
tracing = { workspace = true }
1920
rust-format = { workspace = true, features = ["token_stream"] }
2021
anyhow = { workspace = true }

macros/src/action_event.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ For action containers, it simply delegates to inner actions.
66

77
```rust
88
# use mina_core::ActionEvent;
9+
# extern crate redux;
10+
# struct DummyContext {
11+
# time: String,
12+
# node_id: String,
13+
# }
14+
# impl mina_core::log::EventContext for DummyContext {
15+
# fn timestamp(&self) -> redux::Timestamp { mina_core::log::system_time() }
16+
# fn time(&self) -> &dyn tracing::Value { &self.time }
17+
# fn node_id(&self) -> &dyn tracing::Value { &self.node_id }
18+
# fn log_node_id(&self) -> bool { false }
19+
# }
20+
# let context = DummyContext {
21+
# time: "0".to_string(),
22+
# node_id: "test".to_string(),
23+
# };
924
#
1025
#[derive(ActionEvent)]
1126
enum ActionContainer {
@@ -17,10 +32,10 @@ enum Action1 {
1732
Done,
1833
}
1934

20-
ActionContainer::SubAction1(Action1::Init).action_event(context);
35+
ActionContainer::SubAction1(Action1::Init).action_event(&context);
2136
```
2237

23-
```rust
38+
```rust,ignore
2439
impl ActionEvent for ActionContainer {
2540
fn action_event<T>(&self, context: &T)
2641
where T: ActionContext
@@ -61,7 +76,7 @@ pub enum Action {
6176
}
6277
```
6378

64-
```rust
79+
```rust,ignore
6580
impl mina_core::ActionEvent for Action {
6681
fn action_event<T>(&self, context: &T)
6782
where
@@ -97,7 +112,7 @@ pub enum Action {
97112
}
98113
```
99114

100-
```rust
115+
```rust,ignore
101116
impl mina_core::ActionEvent for Action {
102117
fn action_event<T>(&self, context: &T)
103118
where
@@ -132,7 +147,7 @@ pub enum Action {
132147
}
133148
```
134149

135-
```rust
150+
```rust,ignore
136151
impl mina_core::ActionEvent for Action {
137152
fn action_event<T>(&self, context: &T)
138153
where
@@ -156,6 +171,8 @@ a field's enum variant), logging can be delegated to a function implementing
156171
that logic.
157172

158173
```rust
174+
# fn foo<T: mina_core::log::EventContext>(_context: &T) {}
175+
# fn bar<T: mina_core::log::EventContext>(_context: &T, _f1: &bool) {}
159176
#[derive(mina_core::ActionEvent)]
160177
pub enum Action {
161178
#[action_event(expr(foo(context)))]
@@ -165,7 +182,7 @@ pub enum Action {
165182
}
166183
```
167184

168-
```rust
185+
```rust,ignore
169186
impl mina_core::ActionEvent for Action {
170187
fn action_event<T>(&self, context: &T)
171188
where

node/testing/src/cluster/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@
2121
//! # Example
2222
//!
2323
//! ```rust,no_run
24-
//! let mut cluster = Cluster::new(ClusterConfig::default());
24+
//! # use mina_node_testing::cluster::{Cluster, ClusterConfig};
25+
//! # use mina_node_testing::node::{RustNodeTestingConfig, OcamlNodeTestingConfig};
26+
//! let cluster_config = ClusterConfig::new(None).unwrap();
27+
//! let mut cluster = Cluster::new(cluster_config);
2528
//!
2629
//! // Add Rust node with custom configuration
27-
//! let rust_node = cluster.add_rust_node(RustNodeTestingConfig::default());
30+
//! let rust_node = cluster.add_rust_node(RustNodeTestingConfig::devnet_default());
2831
//!
2932
//! // Add OCaml node for cross-implementation testing
3033
//! let ocaml_node = cluster.add_ocaml_node(OcamlNodeTestingConfig::default());

node/testing/src/node/ocaml/config.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@ pub enum OcamlNodeExecutable {
9898
/// * `String` - Path to the mina executable
9999
///
100100
/// # Example
101-
/// ```
101+
/// ```no_run
102+
/// # use mina_node_testing::node::OcamlNodeExecutable;
103+
/// # let _ =
102104
/// OcamlNodeExecutable::Installed("/usr/local/bin/mina".to_string())
105+
/// # ;
103106
/// ```
104107
Installed(String),
105108

@@ -109,8 +112,11 @@ pub enum OcamlNodeExecutable {
109112
/// * `String` - Docker image tag
110113
///
111114
/// # Example
112-
/// ```
115+
/// ```no_run
116+
/// # use mina_node_testing::node::OcamlNodeExecutable;
117+
/// # let _ =
113118
/// OcamlNodeExecutable::Docker("minaprotocol/mina-daemon:3.0.0".to_string())
119+
/// # ;
114120
/// ```
115121
Docker(String),
116122

node/testing/src/scenarios/driver.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,15 @@ impl<'cluster> Driver<'cluster> {
206206
/// # Example
207207
///
208208
/// ```no_run
209+
/// # use std::time::Duration;
210+
/// # use mina_node_testing::scenarios::Driver;
211+
/// # use node::event_source::Event;
212+
/// # async fn example(driver: &mut Driver<'_>) -> anyhow::Result<()> {
209213
/// driver.wait_for(Duration::from_secs(5), |node_id, event, state| {
210-
/// matches!(event, Event::BlockReceived { .. })
214+
/// matches!(event, Event::P2p(_))
211215
/// }).await?;
216+
/// # Ok(())
217+
/// # }
212218
/// ```
213219
pub async fn wait_for(
214220
&mut self,

p2p/src/webrtc/connection_auth.rs

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,17 @@ use super::{Answer, Offer};
8888
/// ## Usage
8989
///
9090
/// ```rust
91-
/// use mina_p2p::webrtc::{ConnectionAuth, Offer, Answer};
92-
///
91+
/// # use p2p::webrtc::{ConnectionAuth, Offer, Answer};
92+
/// # use p2p::identity::{SecretKey, PublicKey};
93+
/// # use rand::thread_rng;
94+
/// # fn example(offer: &Offer, answer: &Answer,
95+
/// # my_secret_key: &SecretKey, peer_public_key: &PublicKey)
96+
/// # -> Option<()> {
97+
/// # let mut rng = thread_rng();
9398
/// let connection_auth = ConnectionAuth::new(&offer, &answer);
94-
/// let encrypted_auth = connection_auth.encrypt(&my_secret_key, &peer_public_key, rng)?;
99+
/// let encrypted_auth = connection_auth.encrypt(&my_secret_key, &peer_public_key, &mut rng)?;
100+
/// # Some(())
101+
/// # }
95102
/// ```
96103
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)]
97104
pub struct ConnectionAuth(Vec<u8>);
@@ -124,9 +131,16 @@ pub struct ConnectionAuth(Vec<u8>);
124131
/// ## Example
125132
///
126133
/// ```rust
134+
/// # use p2p::webrtc::ConnectionAuthEncrypted;
135+
/// # use p2p::identity::{SecretKey, PublicKey};
136+
/// # fn example(encrypted_auth: &ConnectionAuthEncrypted,
137+
/// # my_secret_key: &SecretKey, peer_public_key: &PublicKey)
138+
/// # -> Option<()> {
127139
/// // After receiving encrypted authentication data
128140
/// let decrypted_auth = encrypted_auth.decrypt(&my_secret_key, &peer_public_key)?;
129141
/// // Verify that the decrypted data matches expected values
142+
/// # Some(())
143+
/// # }
130144
/// ```
131145
#[derive(Debug, Clone)]
132146
pub struct ConnectionAuthEncrypted(Box<[u8; 92]>);
@@ -158,10 +172,11 @@ impl ConnectionAuth {
158172
/// # Example
159173
///
160174
/// ```rust
161-
/// use mina_p2p::webrtc::ConnectionAuth;
162-
///
175+
/// # use p2p::webrtc::{ConnectionAuth, Offer, Answer};
176+
/// # fn example(offer: &Offer, answer: &Answer) {
163177
/// let auth = ConnectionAuth::new(&offer, &answer);
164178
/// // Use auth for connection verification
179+
/// # }
165180
/// ```
166181
pub fn new(offer: &Offer, answer: &Answer) -> Self {
167182
Self([offer.sdp_hash(), answer.sdp_hash()].concat())
@@ -196,14 +211,18 @@ impl ConnectionAuth {
196211
/// # Example
197212
///
198213
/// ```rust
199-
/// use rand::thread_rng;
200-
///
214+
/// # use p2p::webrtc::ConnectionAuth;
215+
/// # use p2p::identity::{SecretKey, PublicKey};
216+
/// # use rand::thread_rng;
217+
/// # fn example(connection_auth: &ConnectionAuth,
218+
/// # my_secret_key: &SecretKey, peer_public_key: &PublicKey) {
201219
/// let mut rng = thread_rng();
202220
/// let encrypted_auth = connection_auth.encrypt(&my_secret_key, &peer_public_key, &mut rng);
203221
///
204222
/// if let Some(encrypted) = encrypted_auth {
205223
/// // Send encrypted authentication data to peer
206224
/// }
225+
/// # }
207226
/// ```
208227
pub fn encrypt(
209228
&self,
@@ -254,6 +273,10 @@ impl ConnectionAuthEncrypted {
254273
/// # Example
255274
///
256275
/// ```rust
276+
/// # use p2p::webrtc::ConnectionAuthEncrypted;
277+
/// # use p2p::identity::{SecretKey, PublicKey};
278+
/// # fn example(encrypted_auth: &ConnectionAuthEncrypted,
279+
/// # my_secret_key: &SecretKey, peer_public_key: &PublicKey) {
257280
/// // After receiving encrypted authentication data from peer
258281
/// if let Some(decrypted_auth) = encrypted_auth.decrypt(&my_secret_key, &peer_public_key) {
259282
/// // Authentication successful, proceed with connection
@@ -262,6 +285,7 @@ impl ConnectionAuthEncrypted {
262285
/// // Authentication failed, reject connection
263286
/// println!("Peer authentication failed");
264287
/// }
288+
/// # }
265289
/// ```
266290
pub fn decrypt(&self, sec_key: &SecretKey, other_pk: &PublicKey) -> Option<ConnectionAuth> {
267291
sec_key

p2p/src/webrtc/signaling_method/http.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ use super::SignalingMethodParseError;
5959
/// # Examples
6060
///
6161
/// ```
62-
/// use mina::webrtc::Host;
63-
/// use mina::signaling_method::HttpSignalingInfo;
64-
///
62+
/// # use p2p::webrtc::{Host, HttpSignalingInfo};
63+
/// # fn example() -> Result<(), Box<dyn std::error::Error>> {
6564
/// // IPv4 signaling server
6665
/// let info = HttpSignalingInfo {
6766
/// host: Host::Ipv4("192.168.1.100".parse()?),
@@ -73,6 +72,8 @@ use super::SignalingMethodParseError;
7372
/// host: Host::Domain("signal.example.com".into()),
7473
/// port: 443,
7574
/// };
75+
/// # Ok(())
76+
/// # }
7677
/// ```
7778
#[derive(BinProtWrite, BinProtRead, Eq, PartialEq, Ord, PartialOrd, Debug, Clone)]
7879
pub struct HttpSignalingInfo {
@@ -119,6 +120,7 @@ impl From<([u8; 4], u16)> for HttpSignalingInfo {
119120
/// # Example
120121
///
121122
/// ```
123+
/// # use p2p::webrtc::HttpSignalingInfo;
122124
/// let info = HttpSignalingInfo::from(([192, 168, 1, 100], 8080));
123125
/// assert_eq!(info.port, 8080);
124126
/// ```
@@ -148,8 +150,8 @@ impl FromStr for HttpSignalingInfo {
148150
/// # Examples
149151
///
150152
/// ```
151-
/// use mina::signaling_method::HttpSignalingInfo;
152-
///
153+
/// # use p2p::webrtc::HttpSignalingInfo;
154+
/// # fn example() -> Result<(), Box<dyn std::error::Error>> {
153155
/// // Domain and port
154156
/// let info: HttpSignalingInfo = "signal.example.com/443".parse()?;
155157
///
@@ -158,6 +160,8 @@ impl FromStr for HttpSignalingInfo {
158160
///
159161
/// // With leading slash
160162
/// let info: HttpSignalingInfo = "/localhost/8080".parse()?;
163+
/// # Ok(())
164+
/// # }
161165
/// ```
162166
///
163167
/// # Errors

p2p/src/webrtc/signaling_method/mod.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,16 @@ use crate::PeerId;
8080
/// # Example
8181
///
8282
/// ```
83+
/// # use p2p::webrtc::SignalingMethod;
84+
/// # use p2p::PeerId;
85+
/// # fn example(peer_id: PeerId) -> Result<(), Box<dyn std::error::Error>> {
8386
/// // Direct HTTPS signaling
8487
/// let method = "/https/signal.example.com/443".parse::<SignalingMethod>()?;
8588
///
8689
/// // P2P relay through an existing peer
8790
/// let method = SignalingMethod::P2p { relay_peer_id: peer_id };
91+
/// # Ok(())
92+
/// # }
8893
/// ```
8994
#[derive(BinProtWrite, BinProtRead, Eq, PartialEq, Ord, PartialOrd, Debug, Clone)]
9095
pub enum SignalingMethod {
@@ -158,8 +163,15 @@ impl SignalingMethod {
158163
/// # Example
159164
///
160165
/// ```
166+
/// # use p2p::webrtc::{SignalingMethod, HttpSignalingInfo, Host};
167+
/// # fn example() {
168+
/// # let info = HttpSignalingInfo {
169+
/// # host: Host::Domain("signal.example.com".into()),
170+
/// # port: 443,
171+
/// # };
161172
/// let method = SignalingMethod::Https(info);
162173
/// let url = method.http_url(); // Some("https://signal.example.com:443/mina/webrtc/signal")
174+
/// # }
163175
/// ```
164176
pub fn http_url(&self) -> Option<String> {
165177
let (http, info) = match self {
@@ -305,8 +317,8 @@ impl FromStr for SignalingMethod {
305317
/// # Examples
306318
///
307319
/// ```
308-
/// use mina::signaling_method::SignalingMethod;
309-
///
320+
/// # use p2p::webrtc::SignalingMethod;
321+
/// # fn example() -> Result<(), Box<dyn std::error::Error>> {
310322
/// // HTTP signaling
311323
/// let method: SignalingMethod = "/http/localhost/8080".parse()?;
312324
///
@@ -315,6 +327,8 @@ impl FromStr for SignalingMethod {
315327
///
316328
/// // HTTPS proxy with cluster ID
317329
/// let method: SignalingMethod = "/https_proxy/123/proxy.example.com/443".parse()?;
330+
/// # Ok(())
331+
/// # }
318332
/// ```
319333
///
320334
/// # Errors

0 commit comments

Comments
 (0)