pub struct NodeInfo {
pub label: String,
pub temp_dir_path: PathBuf,
pub ws_port: u16,
pub network_port: Option<u16>,
pub is_gateway: bool,
pub location: f64,
pub ip: Ipv4Addr,
pub origin_contracts: OriginContractMap,
}Expand description
Information about a node in a test
Fields§
§label: StringHuman-readable label (e.g., “gateway”, “peer-1”)
temp_dir_path: PathBufPath to temp directory for this node’s data
ws_port: u16WebSocket API port
network_port: Option<u16>Network port (None for non-gateway nodes)
is_gateway: boolWhether this is a gateway node
location: f64Node’s location in the ring
ip: Ipv4AddrIP address the node binds to (varied loopback for test isolation)
origin_contracts: OriginContractMapShared origin-contracts map for this node’s API server.
Pre-populate entries here to simulate clients authenticated via an HTTP
contract page before connecting over WebSocket (see insert_origin_contract).
Implementations§
Source§impl NodeInfo
impl NodeInfo
Sourcepub fn insert_origin_contract(
&self,
token: AuthToken,
contract_id: ContractInstanceId,
)
pub fn insert_origin_contract( &self, token: AuthToken, contract_id: ContractInstanceId, )
Pre-register an auth token → contract mapping in this node’s origin-contracts map.
Call this before connecting via WebSocket with an Authorization: Bearer <token>
header to simulate a client that authenticated via an HTTP contract page. The
delegate’s process() function will then receive the contract ID bytes in its
origin parameter.
Sourcepub async fn wait_until_ready(&self, timeout: Duration) -> Result<Duration>
pub async fn wait_until_ready(&self, timeout: Duration) -> Result<Duration>
Wait for this node to become ready using a two-phase check.
Phase 1: Verify the WebSocket API accepts connections and responds to a diagnostics query. For gateways, this is sufficient (they are always “joined”).
Phase 2 (non-gateway peers only): Query ConnectedPeers and wait until at
least one connection exists, confirming the peer has completed its network join
handshake (which sets peer_ready=true).
Uses exponential backoff polling. Returns as soon as the node is ready, rather than waiting a fixed duration.
§Arguments
timeout- Maximum time to wait for the node to become ready
§Returns
Ok(Duration)- Time taken for the node to become readyErr- If the node doesn’t become ready within the timeout
§Example
let node = ctx.node("gateway")?;
let ready_time = node.wait_until_ready(Duration::from_secs(30)).await?;
tracing::info!("Node ready in {:?}", ready_time);Trait Implementations§
Auto Trait Implementations§
impl Freeze for NodeInfo
impl !RefUnwindSafe for NodeInfo
impl Send for NodeInfo
impl Sync for NodeInfo
impl Unpin for NodeInfo
impl UnsafeUnpin for NodeInfo
impl !UnwindSafe for NodeInfo
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more