pub struct NetworkConfigBuilder<State> { /* private fields */ }
Expand description

A network configuration builder, used to build a NetworkConfig declaratively with fields validation.

§Example:

use zombienet_configuration::NetworkConfigBuilder;

let network_config = NetworkConfigBuilder::new()
    .with_relaychain(|relaychain| {
        relaychain
            .with_chain("polkadot")
            .with_random_nominators_count(10)
            .with_default_resources(|resources| {
                resources
                    .with_limit_cpu("1000m")
                    .with_request_memory("1Gi")
                    .with_request_cpu(100_000)
            })
            .with_node(|node| {
                node.with_name("node")
                    .with_command("command")
                    .validator(true)
            })
    })
    .with_parachain(|parachain| {
        parachain
            .with_id(1000)
            .with_chain("myparachain1")
            .with_initial_balance(100_000)
            .with_default_image("myimage:version")
            .with_collator(|collator| {
                collator
                    .with_name("collator1")
                    .with_command("command1")
                    .validator(true)
            })
    })
    .with_parachain(|parachain| {
        parachain
            .with_id(2000)
            .with_chain("myparachain2")
            .with_initial_balance(50_0000)
            .with_collator(|collator| {
                collator
                    .with_name("collator2")
                    .with_command("command2")
                    .validator(true)
            })
    })
    .with_hrmp_channel(|hrmp_channel1| {
        hrmp_channel1
            .with_sender(1)
            .with_recipient(2)
            .with_max_capacity(200)
            .with_max_message_size(500)
    })
    .with_hrmp_channel(|hrmp_channel2| {
        hrmp_channel2
            .with_sender(2)
            .with_recipient(1)
            .with_max_capacity(100)
            .with_max_message_size(250)
    })
    .with_global_settings(|global_settings| {
        global_settings
            .with_network_spawn_timeout(1200)
            .with_node_spawn_timeout(240)
    })
    .build();

assert!(network_config.is_ok())

Implementations§

source§

impl NetworkConfigBuilder<Initial>

source

pub fn new() -> NetworkConfigBuilder<Initial>

source

pub fn with_chain_and_nodes( relay_name: &str, node_names: Vec<String>, ) -> NetworkConfigBuilder<WithRelaychain>

uses the default options for both the relay chain and the nodes the only required fields are the name of the nodes, and the name of the relay chain (“rococo-local”, “polkadot”, etc.)

source

pub fn with_relaychain( self, f: impl FnOnce(RelaychainConfigBuilder<Initial>) -> RelaychainConfigBuilder<WithAtLeastOneNode>, ) -> NetworkConfigBuilder<WithRelaychain>

Set the relay chain using a nested RelaychainConfigBuilder.

source§

impl NetworkConfigBuilder<WithRelaychain>

source

pub fn with_global_settings( self, f: impl FnOnce(GlobalSettingsBuilder) -> GlobalSettingsBuilder, ) -> Self

Set the global settings using a nested GlobalSettingsBuilder.

source

pub fn with_parachain( self, f: impl FnOnce(ParachainConfigBuilder<Initial, Bootstrap>) -> ParachainConfigBuilder<WithAtLeastOneCollator, Bootstrap>, ) -> Self

Add a parachain using a nested ParachainConfigBuilder.

source

pub fn with_parachain_id_and_collators( self, id: u32, collator_names: Vec<String>, ) -> Self

uses default settings for setting for:

  • the parachain,
  • the global settings
  • the hrmp channels

the only required parameters are the names of the collators as a vector, and the id of the parachain

source

pub fn with_hrmp_channel( self, f: impl FnOnce(HrmpChannelConfigBuilder<Initial>) -> HrmpChannelConfigBuilder<WithRecipient>, ) -> Self

Add an HRMP channel using a nested HrmpChannelConfigBuilder.

source

pub fn build(self) -> Result<NetworkConfig, Vec<Error>>

Seals the builder and returns a NetworkConfig if there are no validation errors, else returns errors.

Trait Implementations§

source§

impl Default for NetworkConfigBuilder<Initial>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<State> Freeze for NetworkConfigBuilder<State>

§

impl<State> !RefUnwindSafe for NetworkConfigBuilder<State>

§

impl<State> !Send for NetworkConfigBuilder<State>

§

impl<State> !Sync for NetworkConfigBuilder<State>

§

impl<State> Unpin for NetworkConfigBuilder<State>
where State: Unpin,

§

impl<State> !UnwindSafe for NetworkConfigBuilder<State>

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

§

impl<T> Instrument for T

§

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

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

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

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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