async fn new_with_keys(
        first_node_secret_key_with_stake: SecretKeyWithStake,
        other_secret_keys_with_stakes: Vec<SecretKeyWithStake>,
        rng: &mut NodeRng,
    ) -> Self {
        // Load the `local` chainspec.
        let mut chainspec: Chainspec = Chainspec::from_resources("local");

        // Override accounts with those generated from the keys.
        let genesis_accounts = std::iter::once(&first_node_secret_key_with_stake)
            .chain(other_secret_keys_with_stakes.iter())
            .map(|staked_secret_key| {
                let public_key = PublicKey::from(&*staked_secret_key.secret_key);
                let validator_config = ValidatorConfig::new(
                    Motes::new(U512::from(staked_secret_key.stake)),
                    DelegationRate::zero(),
                );
                AccountConfig::new(
                    public_key,
                    Motes::new(U512::from(rng.gen_range(10000..99999999))),
                    Some(validator_config),
                )
            })
            .collect();
        let delegators = vec![];
        chainspec.network_config.accounts_config =
            AccountsConfig::new(genesis_accounts, delegators);

        // Make the genesis timestamp 45 seconds from now, to allow for all validators to start up.
        chainspec.protocol_config.activation_point =
            ActivationPoint::Genesis(Timestamp::now() + 45000.into());

        chainspec.core_config.minimum_era_height = 4;
        chainspec.highway_config.finality_threshold_fraction = Ratio::new(34, 100);
        chainspec.core_config.era_duration = 10.into();
        chainspec.core_config.auction_delay = 1;
        chainspec.core_config.unbonding_delay = 3;

        // Assign a port for the first node (TODO: this has a race condition)
        let first_node_port = testing::unused_port_on_localhost();

        // Create the test network
        let network: Network<MultiStageTestReactor> = Network::new();

        let mut test_chain = TestChain {
            chainspec: Arc::new(chainspec),
            storages: Vec::new(),
            first_node_port,
            network,
        };

        // Add the nodes to the chain
        test_chain
            .add_node(true, first_node_secret_key_with_stake.secret_key, None, rng)
            .await;

        for secret_key_with_stake in other_secret_keys_with_stakes {
            test_chain
                .add_node(false, secret_key_with_stake.secret_key, None, rng)
                .await;
        }

        test_chain
    }
/// Instantiates a new test chain configuration.
///
/// Takes a vector of bonded keys with specified bond amounts.
Instantiates a new test chain configuration.
Takes a vector of bonded keys with specified bond amounts.
Instantiates a new test chain configuration . Takes a vector of bonded keys with specified bond amounts .
async fn new_with_keys(
        first_node_secret_key_with_stake: SecretKeyWithStake,
        other_secret_keys_with_stakes: Vec<SecretKeyWithStake>,
        rng: &mut NodeRng,
    ) -> Self {
        // Load the `local` chainspec.
        let mut chainspec: Chainspec = Chainspec::from_resources("local");
        // Override accounts with those generated from the keys.
        let genesis_accounts = std::iter::once(&first_node_secret_key_with_stake)
            .chain(other_secret_keys_with_stakes.iter())
            .map(|staked_secret_key| {
                let public_key = PublicKey::from(&*staked_secret_key.secret_key);
                let validator_config = ValidatorConfig::new(
                    Motes::new(U512::from(staked_secret_key.stake)),
                    DelegationRate::zero(),
                );
                AccountConfig::new(
                    public_key,
                    Motes::new(U512::from(rng.gen_range(10000..99999999))),
                    Some(validator_config),
                )
            })
            .collect();
        let delegators = vec![];
        chainspec.network_config.accounts_config =
            AccountsConfig::new(genesis_accounts, delegators);
        // Make the genesis timestamp 45 seconds from now, to allow for all validators to start up.
        chainspec.protocol_config.activation_point =
            ActivationPoint::Genesis(Timestamp::now() + 45000.into());
        chainspec.core_config.minimum_era_height = 4;
        chainspec.highway_config.finality_threshold_fraction = Ratio::new(34, 100);
        chainspec.core_config.era_duration = 10.into();
        chainspec.core_config.auction_delay = 1;
        chainspec.core_config.unbonding_delay = 3;
        // Assign a port for the first node (TODO: this has a race condition)
        let first_node_port = testing::unused_port_on_localhost();
        // Create the test network
        let network: Network<MultiStageTestReactor> = Network::new();
        let mut test_chain = TestChain {
            chainspec: Arc::new(chainspec),
            storages: Vec::new(),
            first_node_port,
            network,
        };
        // Add the nodes to the chain
        test_chain
            .add_node(true, first_node_secret_key_with_stake.secret_key, None, rng)
            .await;
        for secret_key_with_stake in other_secret_keys_with_stakes {
            test_chain
                .add_node(false, secret_key_with_stake.secret_key, None, rng)
                .await;
        }
        test_chain
    }
async fn new_with_keys ( first_node_secret_key_with_stake : SecretKeyWithStake , other_secret_keys_with_stakes : Vec < SecretKeyWithStake > , rng : & mut NodeRng , ) -> Self { // Load the `local` chainspec. let mut chainspec : Chainspec = Chainspec :: from_resources ( " " ) ; // Override accounts with those generated from the keys. let genesis_accounts = std :: iter :: once ( & first_node_secret_key_with_stake ) . chain ( other_secret_keys_with_stakes . iter ( ) ) . map ( | staked_secret_key | { let public_key = PublicKey :: from ( & * staked_secret_key . secret_key ) ; let validator_config = ValidatorConfig :: new ( Motes :: new ( U512 :: from ( staked_secret_key . stake ) ) , DelegationRate :: zero ( ) , ) ; AccountConfig :: new ( public_key , Motes :: new ( U512 :: from ( rng . gen_range ( 10000 .. 99999999 ) ) ) , Some ( validator_config ) , ) } ) . collect ( ) ; let delegators = vec ! [ ] ; chainspec . network_config . accounts_config = AccountsConfig :: new ( genesis_accounts , delegators ) ; // Make the genesis timestamp 45 seconds from now, to allow for all validators to start up. chainspec . protocol_config . activation_point = ActivationPoint :: Genesis ( Timestamp :: now ( ) + 45000 . into ( ) ) ; chainspec . core_config . minimum_era_height = 4 ; chainspec . highway_config . finality_threshold_fraction = Ratio :: new ( 34 , 100 ) ; chainspec . core_config . era_duration = 10 . into ( ) ; chainspec . core_config . auction_delay = 1 ; chainspec . core_config . unbonding_delay = 3 ; // Assign a port for the first node (TODO: this has a race condition) let first_node_port = testing :: unused_port_on_localhost ( ) ; // Create the test network let network : Network < MultiStageTestReactor > = Network :: new ( ) ; let mut test_chain = TestChain { chainspec : Arc :: new ( chainspec ) , storages : Vec :: new ( ) , first_node_port , network , } ; // Add the nodes to the chain test_chain . add_node ( true , first_node_secret_key_with_stake . secret_key , None , rng ) . await ; for secret_key_with_stake in other_secret_keys_with_stakes { test_chain . add_node ( false , secret_key_with_stake . secret_key , None , rng ) . await ; } test_chain }
Instantiates a new test chain configuration.
Instantiates a new test chain configuration .
first_node_secret_key_with_stake
SecretKeyWithStake
other_secret_keys_with_stakes
Vec<SecretKeyWithStake>
rng
&mut NodeRng
first_node_secret_key_with_stake
SecretKeyWithStake
other_secret_keys_with_stakes
Vec<SecretKeyWithStake>
rng
&mut NodeRng