pub struct TestNode<K: KeyType> {
pub service: Option<NetworkService<K>>,
pub peer_id: PeerId,
pub listen_addr: Option<Multiaddr>,
pub instance_key_pair: K::Secret,
pub local_key: Keypair,
pub using_evm_address_for_handshake_verification: bool,
}
Available on crate feature
testing
only.Expand description
Test node configuration for network tests
Fields§
§service: Option<NetworkService<K>>
§peer_id: PeerId
§listen_addr: Option<Multiaddr>
§instance_key_pair: K::Secret
§local_key: Keypair
§using_evm_address_for_handshake_verification: bool
Implementations§
Source§impl<K: KeyType> TestNode<K>
impl<K: KeyType> TestNode<K>
Sourcepub fn new(
network_name: &str,
instance_id: &str,
allowed_keys: AllowedKeys<K>,
bootstrap_peers: Vec<Multiaddr>,
using_evm_address_for_handshake_verification: bool,
) -> Self
pub fn new( network_name: &str, instance_id: &str, allowed_keys: AllowedKeys<K>, bootstrap_peers: Vec<Multiaddr>, using_evm_address_for_handshake_verification: bool, ) -> Self
Create a new test node with auto-generated keys
Sourcepub fn new_with_keys(
network_name: &str,
instance_id: &str,
allowed_keys: AllowedKeys<K>,
bootstrap_peers: Vec<Multiaddr>,
instance_key_pair: Option<K::Secret>,
local_key: Option<Keypair>,
using_evm_address_for_handshake_verification: bool,
) -> Self
pub fn new_with_keys( network_name: &str, instance_id: &str, allowed_keys: AllowedKeys<K>, bootstrap_peers: Vec<Multiaddr>, instance_key_pair: Option<K::Secret>, local_key: Option<Keypair>, using_evm_address_for_handshake_verification: bool, ) -> Self
Create a new test node with specified keys
§Arguments
network_name
- The name of the networkinstance_id
- The instance ID of the nodeallowed_keys
- The allowed keys for the nodebootstrap_peers
- The bootstrap peers for the nodeinstance_key_pair
- The instance key pair for the nodelocal_key
- The local key for the nodeusing_evm_address_for_handshake_verification
- Whether to use the EVM address for handshake verification
§Returns
Returns a new test node
§Panics
Panics if the local key is not provided and cannot be generated
Sourcepub async fn start(&mut self) -> Result<NetworkServiceHandle<K>, &'static str>
pub async fn start(&mut self) -> Result<NetworkServiceHandle<K>, &'static str>
Start the node and wait for it to be fully initialized
§Errors
Returns an error if the service is already started
Sourcepub fn get_listen_addr(&self) -> Option<Multiaddr>
pub fn get_listen_addr(&self) -> Option<Multiaddr>
Get the actual listening address
Sourcepub fn insert_allowed_keys(&self, allowed_keys: AllowedKeys<K>)
pub fn insert_allowed_keys(&self, allowed_keys: AllowedKeys<K>)
Insert the allowed keys for this node
Auto Trait Implementations§
impl<K> !Freeze for TestNode<K>
impl<K> !RefUnwindSafe for TestNode<K>
impl<K> Send for TestNode<K>
impl<K> !Sync for TestNode<K>
impl<K> Unpin for TestNode<K>
impl<K> !UnwindSafe for TestNode<K>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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