auto nullification during finalization and appropriate tests

Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
Uncle Stretch
2025-06-03 19:06:50 +03:00
parent 5847097e94
commit c55d9a05d9
4 changed files with 52 additions and 7 deletions

View File

@@ -798,7 +798,6 @@ fn bridged_inlation_reward_works() {
let total_staked_not_ideal: u128 = 68;
let total_issuance: u128 = 100;
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
total_staked_ideal * 1_000,
total_issuance * 1_000,
@@ -913,3 +912,26 @@ fn bridged_inlation_reward_works() {
1, total_issuance * 1_000_000_000_000_000_000_000_000 + amount, 0), (0, 0));
});
}
#[test]
fn bridged_inflation_era_payout_triggers_need_of_nullification() {
ExtBuilder::build()
.execute_with(|| {
let chain_id: u32 = 1;
let amount: u128 = 1337 * 1_000_000_000;
let commission: u128 = amount / 100; // 1% commission
let total_staked_ideal: u128 = 69;
let total_issuance: u128 = 100;
assert_ok!(GhostNetworks::accumulate_commission(&commission));
assert_ok!(GhostNetworks::increase_gatekeeper_amount(&chain_id, &amount));
assert_eq!(NullifyNeeded::<Test>::get(), false);
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
total_staked_ideal * 1_000,
total_issuance * 1_000 + amount,
0), (commission, 0));
assert_eq!(NullifyNeeded::<Test>::get(), true);
GhostNetworks::on_finalize(69);
assert_eq!(NullifyNeeded::<Test>::get(), false);
});
}