/// Creates a neuron that has accumulated some maturity.
///
/// If `dissolved` is true, the returned neuron is in the "dissolved" state,
/// otherwise the returned neuron is in the "not-dissolving" state.
Creates a neuron that has accumulated some maturity.
If `dissolved` is true, the returned neuron is in the "dissolved" state,
otherwise the returned neuron is in the "not-dissolving" state.
Creates a neuron that has accumulated some maturity . If ` dissolved ` is true the returned neuron is in the " dissolved " state otherwise the returned neuron is in the " not - dissolving " state .
fn create_mature_neuron(dissolved: bool) -> (FakeDriver, Governance, Neuron) {
    let from = *TEST_NEURON_1_OWNER_PRINCIPAL;
    // Compute the subaccount to which the transfer would have been made
    let nonce = 1234u64;
    let block_height = 543212234;
    let dissolve_delay_seconds = MIN_DISSOLVE_DELAY_FOR_VOTE_ELIGIBILITY_SECONDS;
    let neuron_stake_e8s = 100_000_000;
    let (mut driver, mut gov, id, to_subaccount) = governance_with_staked_neuron(
        dissolve_delay_seconds,
        neuron_stake_e8s,
        block_height,
        from,
        nonce,
    );
    // Make sure the neuron was created with the right details.
    assert_eq!(
        gov.proto.neurons.get(&id.id).unwrap(),
        &Neuron {
            id: Some(id.clone()),
            account: to_subaccount.to_vec(),
            controller: Some(from),
            cached_neuron_stake_e8s: neuron_stake_e8s,
            created_timestamp_seconds: driver.now(),
            aging_since_timestamp_seconds: driver.now(),
            dissolve_state: Some(DissolveState::DissolveDelaySeconds(dissolve_delay_seconds)),
            transfer: Some(NeuronStakeTransfer {
                transfer_timestamp: driver.now(),
                from: Some(from),
                from_subaccount: Vec::new(),
                to_subaccount: to_subaccount.to_vec(),
                neuron_stake_e8s,
                block_height,
                memo: nonce,
            }),
            kyc_verified: true,
            ..Default::default()
        }
    );
    assert_eq!(gov.get_neuron_ids_by_principal(&from), vec![id.id]);
    let neuron = gov.proto.neurons.get_mut(&id.id).unwrap();
    // Dissolve the neuron if `dissolved` is true
    if dissolved {
        neuron
            .configure(
                &from,
                driver.now(),
                &Configure {
                    operation: Some(Operation::StartDissolving(StartDissolving {})),
                },
            )
            .unwrap();
        // Advance the time in the env
        driver.advance_time_by(MIN_DISSOLVE_DELAY_FOR_VOTE_ELIGIBILITY_SECONDS + 1);
        // The neuron state should now be "Dissolved", meaning we can
        // now disburse the neuron.
        assert_eq!(
            neuron.get_neuron_info(driver.now()).state(),
            NeuronState::Dissolved
        );
    } else {
        driver.advance_time_by(MIN_DISSOLVE_DELAY_FOR_VOTE_ELIGIBILITY_SECONDS + 1);
    }
    let neuron_fees_e8s = 50_000_000; // 0.5 ICPT
    let neuron_maturity = 25_000_000;
    // Pretend the neuron has some rewards and fees to pay.
    neuron.neuron_fees_e8s = neuron_fees_e8s;
    // .. and some maturity to collect.
    neuron.maturity_e8s_equivalent = neuron_maturity;
    let n = neuron.clone();
    (driver, gov, n)
}
fn create_mature_neuron ( dissolved : bool ) -> ( FakeDriver , Governance , Neuron ) { let from = * TEST_NEURON_1_OWNER_PRINCIPAL ; // Compute the subaccount to which the transfer would have been made let nonce = 1234u64 ; let block_height = 543212234 ; let dissolve_delay_seconds = MIN_DISSOLVE_DELAY_FOR_VOTE_ELIGIBILITY_SECONDS ; let neuron_stake_e8s = 100_000_000 ; let ( mut driver , mut gov , id , to_subaccount ) = governance_with_staked_neuron ( dissolve_delay_seconds , neuron_stake_e8s , block_height , from , nonce , ) ; // Make sure the neuron was created with the right details. assert_eq ! ( gov proto neurons get ( id id ) unwrap ( ) Neuron { id Some ( id clone ( ) ) account to_subaccount to_vec ( ) controller Some ( from ) cached_neuron_stake_e8s neuron_stake_e8s created_timestamp_seconds driver now ( ) aging_since_timestamp_seconds driver now ( ) dissolve_state Some ( DissolveState DissolveDelaySeconds ( dissolve_delay_seconds ) ) transfer Some ( NeuronStakeTransfer { transfer_timestamp driver now ( ) from Some ( from ) from_subaccount Vec new ( ) to_subaccount to_subaccount to_vec ( ) neuron_stake_e8s block_height memo nonce } ) kyc_verified true Default default ( ) } ) ; assert_eq ! ( gov get_neuron_ids_by_principal ( from ) vec [ id id ] ) ; let neuron = gov . proto . neurons . get_mut ( & id . id ) . unwrap ( ) ; // Dissolve the neuron if `dissolved` is true if dissolved { neuron . configure ( & from , driver . now ( ) , & Configure { operation : Some ( Operation :: StartDissolving ( StartDissolving { } ) ) , } , ) . unwrap ( ) ; // Advance the time in the env driver . advance_time_by ( MIN_DISSOLVE_DELAY_FOR_VOTE_ELIGIBILITY_SECONDS + 1 ) ; // The neuron state should now be "Dissolved", meaning we can // now disburse the neuron. assert_eq ! ( neuron get_neuron_info ( driver now ( ) ) state ( ) NeuronState Dissolved ) ; } else { driver . advance_time_by ( MIN_DISSOLVE_DELAY_FOR_VOTE_ELIGIBILITY_SECONDS + 1 ) ; } let neuron_fees_e8s = 50_000_000 ; // 0.5 ICPT let neuron_maturity = 25_000_000 ; // Pretend the neuron has some rewards and fees to pay. neuron . neuron_fees_e8s = neuron_fees_e8s ; // .. and some maturity to collect. neuron . maturity_e8s_equivalent = neuron_maturity ; let n = neuron . clone ( ) ; ( driver , gov , n ) }
Creates a neuron that has accumulated some maturity.
Creates a neuron that has accumulated some maturity .
dissolved
bool