Struct TestNode

Source
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>

Source

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

Source

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 network
  • instance_id - The instance ID of the node
  • allowed_keys - The allowed keys for the node
  • bootstrap_peers - The bootstrap peers for the node
  • instance_key_pair - The instance key pair for the node
  • local_key - The local key for the node
  • using_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

Source

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

Source

pub fn get_listen_addr(&self) -> Option<Multiaddr>

Get the actual listening address

Source

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>
where <K as KeyType>::Secret: Unpin, <K as KeyType>::Signature: Unpin, <K as KeyType>::Public: Unpin,

§

impl<K> !UnwindSafe for TestNode<K>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,