1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! Narrow trait over the [`NetworkClient`] surface that the sync
//! subsystem actually uses.
//!
//! Sync only needs two methods (`mesh_peers`, `open_stream`); the real
//! `NetworkClient` has ~15. Defining a sync-specific trait here lets
//! tests substitute a mock without spinning up an Actix runtime + the
//! whole libp2p stack, and lets the post-extraction sync crate
//! (#2302) declare its network dependency in one place.
//!
//! The mock lives in the sibling `mock` submodule under `#[cfg(test)]`
//! so its types are never compiled into production binaries. See the
//! `manager/mod.rs` + `manager/tests.rs` precedent for the same
//! mod-dir layout.
//!
//! **`open_stream` mockability**: `Stream` wraps a real `libp2p::Stream`
//! in production, but `Stream::test_pair()` (behind the network-primitives
//! `test-utils` feature, which the node enables on its dev-dependency
//! edge) backs it with an in-memory duplex pipe. Mocks can therefore
//! script `Err(_)`/hang *and* a synthetic `Ok(Stream)`, covering both
//! the retry/timeout/error paths and the success/recovery paths of the
//! namespace-join discovery loop, snapshot/delta-request opens, etc.
//!
//! See #2406 + #2302 (sync extraction epic).
//!
//! [`NetworkClient`]: calimero_network_primitives::client::NetworkClient
use async_trait;
use NetworkClient;
use Stream;
use TopicHash;
use PeerId;
pub
/// The network surface the sync subsystem uses.
///
/// The blanket impl on `NetworkClient` is the production wiring; the
/// `#[cfg(test)]` mock in the sibling [`mock`] module is the unit-test
/// wiring.