make clap regardless of fail during applause

Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
Uncle Stinky
2025-06-18 17:03:09 +03:00
parent 99c43a0c24
commit 6100e79ebf
3 changed files with 13 additions and 17 deletions

View File

@@ -565,7 +565,13 @@ impl<T: Config> Pallet<T> {
) > Perbill::from_percent(T::ApplauseThreshold::get());
if enough_authorities {
Self::try_applause(&clap, &received_claps_key)?;
if let Err(error_msg) = Self::try_applause(&clap, &received_claps_key) {
log::info!(
target: LOG_TARGET,
"👏 Could not applause because of: {:?}",
error_msg,
);
}
}
Ok(())

View File

@@ -524,7 +524,7 @@ fn should_throw_error_if_validator_disabled_and_ignore_later() {
}
#[test]
fn should_throw_error_on_gatekeeper_amount_overflow() {
fn should_clap_without_applause_on_gatekeeper_amount_overflow() {
let big_amount: u64 = u64::MAX;
let first_receiver: u64 = 1337;
let second_receiver: u64 = 420;
@@ -569,12 +569,7 @@ fn should_throw_error_on_gatekeeper_amount_overflow() {
};
let authority = UintAuthorityId::from((authority_index + 1) as u64);
let signature = authority.sign(&clap.encode()).unwrap();
if authority_index == 0 {
assert_ok!(SlowClap::slow_clap(RuntimeOrigin::none(), clap, signature));
} else {
assert_err!(SlowClap::slow_clap(RuntimeOrigin::none(), clap, signature),
Error::<Runtime>::CouldNotIncreaseGatekeeperAmount);
}
assert_ok!(SlowClap::slow_clap(RuntimeOrigin::none(), clap, signature));
}
assert_eq!(Balances::balance(&first_receiver), big_amount);
@@ -587,7 +582,7 @@ fn should_throw_error_on_gatekeeper_amount_overflow() {
}
#[test]
fn should_throw_error_on_commission_overflow() {
fn should_clap_without_applause_on_commission_overflow() {
let big_amount: u64 = u64::MAX;
let first_receiver: u64 = 1337;
let second_receiver: u64 = 420;
@@ -635,19 +630,14 @@ fn should_throw_error_on_commission_overflow() {
};
let authority = UintAuthorityId::from((authority_index + 1) as u64);
let signature = authority.sign(&clap.encode()).unwrap();
if authority_index == 0 {
assert_ok!(SlowClap::slow_clap(RuntimeOrigin::none(), clap, signature));
} else {
assert_err!(SlowClap::slow_clap(RuntimeOrigin::none(), clap, signature),
Error::<Runtime>::CouldNotAccumulateIncomingImbalance);
}
assert_ok!(SlowClap::slow_clap(RuntimeOrigin::none(), clap, signature));
}
assert_eq!(Balances::balance(&first_receiver), big_amount);
assert_eq!(Balances::balance(&second_receiver), 0);
assert_eq!(Networks::gatekeeper_amount(network_id), big_amount);
assert_eq!(Networks::gatekeeper_amount(network_id_other), 0);
assert_eq!(Networks::gatekeeper_amount(network_id_other), big_amount);
assert_eq!(Networks::bridged_imbalance().bridged_in, big_amount);
assert_eq!(Networks::bridged_imbalance().bridged_out, 0);
});