/// Merge the maturity for a given neuron and assert that the neuron's stake,
/// maturity and account balance were correctly modified
Merge the maturity for a given neuron and assert that the neuron's stake,
maturity and account balance were correctly modified
Merge the maturity for a given neuron and assert that the neuron ' s stake maturity and account balance were correctly modified
fn assert_merge_maturity_executes_as_expected(
    gov: &mut Governance,
    id: NeuronId,
    controller: &PrincipalId,
    percentage_to_merge: u32,
    expected_merged_maturity: u64,
    driver: &FakeDriver,
) {
    let neuron = gov.get_neuron(&id).unwrap().clone();
    let account = AccountIdentifier::new(
        ic_base_types::PrincipalId::from(GOVERNANCE_CANISTER_ID),
        Some(Subaccount::try_from(neuron.account.as_slice()).unwrap()),
    );
    let response = merge_maturity(gov, id.clone(), &controller, percentage_to_merge).unwrap();
    let merged_maturity = response.merged_maturity_e8s;
    assert_eq!(merged_maturity, expected_merged_maturity);
    let expected_resulting_maturity = neuron.maturity_e8s_equivalent - merged_maturity;
    let expected_resulting_stake = neuron.cached_neuron_stake_e8s + merged_maturity;
    let post_merge_account_balance = driver
        .account_balance(account)
        .now_or_never()
        .unwrap()
        .unwrap()
        .get_e8s();
    let merged_neuron = gov.get_neuron(&id).unwrap();
    assert_eq!(
        merged_neuron.maturity_e8s_equivalent,
        expected_resulting_maturity
    );
    assert_eq!(
        merged_neuron.cached_neuron_stake_e8s,
        expected_resulting_stake
    );
    assert_eq!(
        merged_neuron.cached_neuron_stake_e8s,
        post_merge_account_balance
    );
    assert!(neuron.aging_since_timestamp_seconds < merged_neuron.aging_since_timestamp_seconds);
}
fn assert_merge_maturity_executes_as_expected ( gov : & mut Governance , id : NeuronId , controller : & PrincipalId , percentage_to_merge : u32 , expected_merged_maturity : u64 , driver : & FakeDriver , ) { let neuron = gov . get_neuron ( & id ) . unwrap ( ) . clone ( ) ; let account = AccountIdentifier :: new ( ic_base_types :: PrincipalId :: from ( GOVERNANCE_CANISTER_ID ) , Some ( Subaccount :: try_from ( neuron . account . as_slice ( ) ) . unwrap ( ) ) , ) ; let response = merge_maturity ( gov , id . clone ( ) , & controller , percentage_to_merge ) . unwrap ( ) ; let merged_maturity = response . merged_maturity_e8s ; assert_eq ! ( merged_maturity expected_merged_maturity ) ; let expected_resulting_maturity = neuron . maturity_e8s_equivalent - merged_maturity ; let expected_resulting_stake = neuron . cached_neuron_stake_e8s + merged_maturity ; let post_merge_account_balance = driver . account_balance ( account ) . now_or_never ( ) . unwrap ( ) . unwrap ( ) . get_e8s ( ) ; let merged_neuron = gov . get_neuron ( & id ) . unwrap ( ) ; assert_eq ! ( merged_neuron maturity_e8s_equivalent expected_resulting_maturity ) ; assert_eq ! ( merged_neuron cached_neuron_stake_e8s expected_resulting_stake ) ; assert_eq ! ( merged_neuron cached_neuron_stake_e8s post_merge_account_balance ) ; assert ! ( neuron aging_since_timestamp_seconds merged_neuron aging_since_timestamp_seconds ) ; }
Merge the maturity for a given neuron and assert that the neuron's stake,
maturity and account balance were correctly modified
Merge the maturity for a given neuron and assert that the neuron ' s stake maturity and account balance were correctly modified
gov
&mut Governance
id
NeuronId
controller
&PrincipalId
percentage_to_merge
u32
expected_merged_maturity
u64
driver
&FakeDriver