forked from ghostchain/ghost-node
		
	make clap regardless of fail during applause
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
		
							parent
							
								
									99c43a0c24
								
							
						
					
					
						commit
						6100e79ebf
					
				@ -1,6 +1,6 @@
 | 
			
		||||
[package]
 | 
			
		||||
name = "ghost-slow-clap"
 | 
			
		||||
version = "0.3.25"
 | 
			
		||||
version = "0.3.26"
 | 
			
		||||
description = "Applause protocol for the EVM bridge"
 | 
			
		||||
license.workspace = true
 | 
			
		||||
authors.workspace = true
 | 
			
		||||
 | 
			
		||||
@ -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(())
 | 
			
		||||
 | 
			
		||||
@ -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_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_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);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user