mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-20 18:41:01 +00:00
Add more asserts and debug_asserts (#8541)
* Add more asserts and debug_asserts fixing #8106 * Remove assignments * convert debug_assert to runtime assert
This commit is contained in:
committed by
GitHub
parent
a600e278ed
commit
e932c3ecd2
@@ -44,7 +44,8 @@ benchmarks_instance_pallet! {
|
|||||||
let balance = existential_deposit.saturating_mul(ED_MULTIPLIER.into());
|
let balance = existential_deposit.saturating_mul(ED_MULTIPLIER.into());
|
||||||
let _ = <Balances<T, I> as Currency<_>>::make_free_balance_be(&caller, balance);
|
let _ = <Balances<T, I> as Currency<_>>::make_free_balance_be(&caller, balance);
|
||||||
|
|
||||||
// Transfer `e - 1` existential deposits + 1 unit, which guarantees to create one account, and reap this user.
|
// Transfer `e - 1` existential deposits + 1 unit, which guarantees to create one account,
|
||||||
|
// and reap this user.
|
||||||
let recipient: T::AccountId = account("recipient", 0, SEED);
|
let recipient: T::AccountId = account("recipient", 0, SEED);
|
||||||
let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient.clone());
|
let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient.clone());
|
||||||
let transfer_amount = existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into();
|
let transfer_amount = existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into();
|
||||||
|
|||||||
@@ -169,13 +169,13 @@ macro_rules! decl_tests {
|
|||||||
&info_from_weight(1),
|
&info_from_weight(1),
|
||||||
1,
|
1,
|
||||||
).is_err());
|
).is_err());
|
||||||
assert!(<ChargeTransactionPayment<$test> as SignedExtension>::pre_dispatch(
|
assert_ok!(<ChargeTransactionPayment<$test> as SignedExtension>::pre_dispatch(
|
||||||
ChargeTransactionPayment::from(0),
|
ChargeTransactionPayment::from(0),
|
||||||
&1,
|
&1,
|
||||||
CALL,
|
CALL,
|
||||||
&info_from_weight(1),
|
&info_from_weight(1),
|
||||||
1,
|
1,
|
||||||
).is_ok());
|
));
|
||||||
|
|
||||||
Balances::set_lock(ID_1, &1, 10, WithdrawReasons::TRANSACTION_PAYMENT);
|
Balances::set_lock(ID_1, &1, 10, WithdrawReasons::TRANSACTION_PAYMENT);
|
||||||
assert_ok!(<Balances as Currency<_>>::transfer(&1, &2, 1, AllowDeath));
|
assert_ok!(<Balances as Currency<_>>::transfer(&1, &2, 1, AllowDeath));
|
||||||
@@ -394,7 +394,7 @@ macro_rules! decl_tests {
|
|||||||
fn refunding_balance_should_work() {
|
fn refunding_balance_should_work() {
|
||||||
<$ext_builder>::default().build().execute_with(|| {
|
<$ext_builder>::default().build().execute_with(|| {
|
||||||
let _ = Balances::deposit_creating(&1, 42);
|
let _ = Balances::deposit_creating(&1, 42);
|
||||||
assert!(Balances::mutate_account(&1, |a| a.reserved = 69).is_ok());
|
assert_ok!(Balances::mutate_account(&1, |a| a.reserved = 69));
|
||||||
Balances::unreserve(&1, 69);
|
Balances::unreserve(&1, 69);
|
||||||
assert_eq!(Balances::free_balance(1), 111);
|
assert_eq!(Balances::free_balance(1), 111);
|
||||||
assert_eq!(Balances::reserved_balance(1), 0);
|
assert_eq!(Balances::reserved_balance(1), 0);
|
||||||
@@ -669,7 +669,9 @@ macro_rules! decl_tests {
|
|||||||
assert_eq!(Balances::reserved_balance(1), 50);
|
assert_eq!(Balances::reserved_balance(1), 50);
|
||||||
|
|
||||||
// Reserve some free balance
|
// Reserve some free balance
|
||||||
let _ = Balances::slash(&1, 1);
|
let res = Balances::slash(&1, 1);
|
||||||
|
assert_eq!(res, (NegativeImbalance::new(1), 0));
|
||||||
|
|
||||||
// The account should be dead.
|
// The account should be dead.
|
||||||
assert_eq!(Balances::free_balance(1), 0);
|
assert_eq!(Balances::free_balance(1), 0);
|
||||||
assert_eq!(Balances::reserved_balance(1), 0);
|
assert_eq!(Balances::reserved_balance(1), 0);
|
||||||
@@ -727,7 +729,8 @@ macro_rules! decl_tests {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
let _ = Balances::slash(&1, 1);
|
let res = Balances::slash(&1, 1);
|
||||||
|
assert_eq!(res, (NegativeImbalance::new(1), 0));
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
events(),
|
events(),
|
||||||
@@ -756,7 +759,8 @@ macro_rules! decl_tests {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
let _ = Balances::slash(&1, 100);
|
let res = Balances::slash(&1, 100);
|
||||||
|
assert_eq!(res, (NegativeImbalance::new(100), 0));
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
events(),
|
events(),
|
||||||
|
|||||||
@@ -175,12 +175,14 @@ fn emit_events_with_no_existential_deposit_suicide_with_dust() {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
let _ = Balances::slash(&1, 98);
|
let res = Balances::slash(&1, 98);
|
||||||
|
assert_eq!(res, (NegativeImbalance::new(98), 0));
|
||||||
|
|
||||||
// no events
|
// no events
|
||||||
assert_eq!(events(), []);
|
assert_eq!(events(), []);
|
||||||
|
|
||||||
let _ = Balances::slash(&1, 1);
|
let res = Balances::slash(&1, 1);
|
||||||
|
assert_eq!(res, (NegativeImbalance::new(1), 0));
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
events(),
|
events(),
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ impl pallet_transaction_payment::Config for Test {
|
|||||||
pub struct OnDustRemoval;
|
pub struct OnDustRemoval;
|
||||||
impl OnUnbalanced<NegativeImbalance<Test>> for OnDustRemoval {
|
impl OnUnbalanced<NegativeImbalance<Test>> for OnDustRemoval {
|
||||||
fn on_nonzero_unbalanced(amount: NegativeImbalance<Test>) {
|
fn on_nonzero_unbalanced(amount: NegativeImbalance<Test>) {
|
||||||
let _ = Balances::resolve_into_existing(&1, amount);
|
assert_ok!(Balances::resolve_into_existing(&1, amount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ fn pot_underflow_should_not_diminish() {
|
|||||||
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
||||||
assert_eq!(Treasury::pot(), 100); // Pot hasn't changed
|
assert_eq!(Treasury::pot(), 100); // Pot hasn't changed
|
||||||
|
|
||||||
let _ = Balances::deposit_into_existing(&Treasury::account_id(), 100).unwrap();
|
assert_ok!(Balances::deposit_into_existing(&Treasury::account_id(), 100));
|
||||||
<Treasury as OnInitialize<u64>>::on_initialize(4);
|
<Treasury as OnInitialize<u64>>::on_initialize(4);
|
||||||
assert_eq!(Balances::free_balance(3), 150); // Fund has been spent
|
assert_eq!(Balances::free_balance(3), 150); // Fund has been spent
|
||||||
assert_eq!(Treasury::pot(), 25); // Pot has finally changed
|
assert_eq!(Treasury::pot(), 25); // Pot has finally changed
|
||||||
@@ -689,7 +689,8 @@ fn claim_handles_high_fee() {
|
|||||||
<Treasury as OnInitialize<u64>>::on_initialize(5);
|
<Treasury as OnInitialize<u64>>::on_initialize(5);
|
||||||
|
|
||||||
// make fee > balance
|
// make fee > balance
|
||||||
let _ = Balances::slash(&Bounties::bounty_account_id(0), 10);
|
let res = Balances::slash(&Bounties::bounty_account_id(0), 10);
|
||||||
|
assert_eq!(res.0.peek(), 10);
|
||||||
|
|
||||||
assert_ok!(Bounties::claim_bounty(Origin::signed(1), 0));
|
assert_ok!(Bounties::claim_bounty(Origin::signed(1), 0));
|
||||||
|
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ mod tests {
|
|||||||
use sp_core::H256;
|
use sp_core::H256;
|
||||||
use hex_literal::hex;
|
use hex_literal::hex;
|
||||||
use sp_runtime::DispatchError;
|
use sp_runtime::DispatchError;
|
||||||
use frame_support::{dispatch::DispatchResult, weights::Weight};
|
use frame_support::{assert_ok, dispatch::DispatchResult, weights::Weight};
|
||||||
use assert_matches::assert_matches;
|
use assert_matches::assert_matches;
|
||||||
use pallet_contracts_primitives::{ExecReturnValue, ReturnFlags, ExecError, ErrorOrigin};
|
use pallet_contracts_primitives::{ExecReturnValue, ReturnFlags, ExecError, ErrorOrigin};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
@@ -597,12 +597,12 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn contract_transfer() {
|
fn contract_transfer() {
|
||||||
let mut mock_ext = MockExt::default();
|
let mut mock_ext = MockExt::default();
|
||||||
let _ = execute(
|
assert_ok!(execute(
|
||||||
CODE_TRANSFER,
|
CODE_TRANSFER,
|
||||||
vec![],
|
vec![],
|
||||||
&mut mock_ext,
|
&mut mock_ext,
|
||||||
&mut GasMeter::new(GAS_LIMIT),
|
&mut GasMeter::new(GAS_LIMIT),
|
||||||
).unwrap();
|
));
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&mock_ext.transfers,
|
&mock_ext.transfers,
|
||||||
@@ -663,12 +663,12 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn contract_call() {
|
fn contract_call() {
|
||||||
let mut mock_ext = MockExt::default();
|
let mut mock_ext = MockExt::default();
|
||||||
let _ = execute(
|
assert_ok!(execute(
|
||||||
CODE_CALL,
|
CODE_CALL,
|
||||||
vec![],
|
vec![],
|
||||||
&mut mock_ext,
|
&mut mock_ext,
|
||||||
&mut GasMeter::new(GAS_LIMIT),
|
&mut GasMeter::new(GAS_LIMIT),
|
||||||
).unwrap();
|
));
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&mock_ext.transfers,
|
&mock_ext.transfers,
|
||||||
@@ -739,12 +739,12 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn contract_instantiate() {
|
fn contract_instantiate() {
|
||||||
let mut mock_ext = MockExt::default();
|
let mut mock_ext = MockExt::default();
|
||||||
let _ = execute(
|
assert_ok!(execute(
|
||||||
CODE_INSTANTIATE,
|
CODE_INSTANTIATE,
|
||||||
vec![],
|
vec![],
|
||||||
&mut mock_ext,
|
&mut mock_ext,
|
||||||
&mut GasMeter::new(GAS_LIMIT),
|
&mut GasMeter::new(GAS_LIMIT),
|
||||||
).unwrap();
|
));
|
||||||
|
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
&mock_ext.instantiates[..],
|
&mock_ext.instantiates[..],
|
||||||
@@ -851,12 +851,12 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn contract_call_limited_gas() {
|
fn contract_call_limited_gas() {
|
||||||
let mut mock_ext = MockExt::default();
|
let mut mock_ext = MockExt::default();
|
||||||
let _ = execute(
|
assert_ok!(execute(
|
||||||
&CODE_TRANSFER_LIMITED_GAS,
|
&CODE_TRANSFER_LIMITED_GAS,
|
||||||
vec![],
|
vec![],
|
||||||
&mut mock_ext,
|
&mut mock_ext,
|
||||||
&mut GasMeter::new(GAS_LIMIT),
|
&mut GasMeter::new(GAS_LIMIT),
|
||||||
).unwrap();
|
));
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&mock_ext.transfers,
|
&mock_ext.transfers,
|
||||||
@@ -994,12 +994,12 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn caller() {
|
fn caller() {
|
||||||
let _ = execute(
|
assert_ok!(execute(
|
||||||
CODE_CALLER,
|
CODE_CALLER,
|
||||||
vec![],
|
vec![],
|
||||||
MockExt::default(),
|
MockExt::default(),
|
||||||
&mut GasMeter::new(GAS_LIMIT),
|
&mut GasMeter::new(GAS_LIMIT),
|
||||||
).unwrap();
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// calls `seal_address` and compares the result with the constant 69.
|
/// calls `seal_address` and compares the result with the constant 69.
|
||||||
@@ -1047,12 +1047,12 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn address() {
|
fn address() {
|
||||||
let _ = execute(
|
assert_ok!(execute(
|
||||||
CODE_ADDRESS,
|
CODE_ADDRESS,
|
||||||
vec![],
|
vec![],
|
||||||
MockExt::default(),
|
MockExt::default(),
|
||||||
&mut GasMeter::new(GAS_LIMIT),
|
&mut GasMeter::new(GAS_LIMIT),
|
||||||
).unwrap();
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
const CODE_BALANCE: &str = r#"
|
const CODE_BALANCE: &str = r#"
|
||||||
@@ -1099,12 +1099,12 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn balance() {
|
fn balance() {
|
||||||
let mut gas_meter = GasMeter::new(GAS_LIMIT);
|
let mut gas_meter = GasMeter::new(GAS_LIMIT);
|
||||||
let _ = execute(
|
assert_ok!(execute(
|
||||||
CODE_BALANCE,
|
CODE_BALANCE,
|
||||||
vec![],
|
vec![],
|
||||||
MockExt::default(),
|
MockExt::default(),
|
||||||
&mut gas_meter,
|
&mut gas_meter,
|
||||||
).unwrap();
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
const CODE_GAS_PRICE: &str = r#"
|
const CODE_GAS_PRICE: &str = r#"
|
||||||
@@ -1151,12 +1151,12 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn gas_price() {
|
fn gas_price() {
|
||||||
let mut gas_meter = GasMeter::new(GAS_LIMIT);
|
let mut gas_meter = GasMeter::new(GAS_LIMIT);
|
||||||
let _ = execute(
|
assert_ok!(execute(
|
||||||
CODE_GAS_PRICE,
|
CODE_GAS_PRICE,
|
||||||
vec![],
|
vec![],
|
||||||
MockExt::default(),
|
MockExt::default(),
|
||||||
&mut gas_meter,
|
&mut gas_meter,
|
||||||
).unwrap();
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
const CODE_GAS_LEFT: &str = r#"
|
const CODE_GAS_LEFT: &str = r#"
|
||||||
@@ -1258,12 +1258,12 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn value_transferred() {
|
fn value_transferred() {
|
||||||
let mut gas_meter = GasMeter::new(GAS_LIMIT);
|
let mut gas_meter = GasMeter::new(GAS_LIMIT);
|
||||||
let _ = execute(
|
assert_ok!(execute(
|
||||||
CODE_VALUE_TRANSFERRED,
|
CODE_VALUE_TRANSFERRED,
|
||||||
vec![],
|
vec![],
|
||||||
MockExt::default(),
|
MockExt::default(),
|
||||||
&mut gas_meter,
|
&mut gas_meter,
|
||||||
).unwrap();
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
const CODE_RETURN_FROM_START_FN: &str = r#"
|
const CODE_RETURN_FROM_START_FN: &str = r#"
|
||||||
@@ -1346,12 +1346,12 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn now() {
|
fn now() {
|
||||||
let mut gas_meter = GasMeter::new(GAS_LIMIT);
|
let mut gas_meter = GasMeter::new(GAS_LIMIT);
|
||||||
let _ = execute(
|
assert_ok!(execute(
|
||||||
CODE_TIMESTAMP_NOW,
|
CODE_TIMESTAMP_NOW,
|
||||||
vec![],
|
vec![],
|
||||||
MockExt::default(),
|
MockExt::default(),
|
||||||
&mut gas_meter,
|
&mut gas_meter,
|
||||||
).unwrap();
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
const CODE_MINIMUM_BALANCE: &str = r#"
|
const CODE_MINIMUM_BALANCE: &str = r#"
|
||||||
@@ -1397,12 +1397,12 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn minimum_balance() {
|
fn minimum_balance() {
|
||||||
let mut gas_meter = GasMeter::new(GAS_LIMIT);
|
let mut gas_meter = GasMeter::new(GAS_LIMIT);
|
||||||
let _ = execute(
|
assert_ok!(execute(
|
||||||
CODE_MINIMUM_BALANCE,
|
CODE_MINIMUM_BALANCE,
|
||||||
vec![],
|
vec![],
|
||||||
MockExt::default(),
|
MockExt::default(),
|
||||||
&mut gas_meter,
|
&mut gas_meter,
|
||||||
).unwrap();
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
const CODE_TOMBSTONE_DEPOSIT: &str = r#"
|
const CODE_TOMBSTONE_DEPOSIT: &str = r#"
|
||||||
@@ -1448,12 +1448,12 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn tombstone_deposit() {
|
fn tombstone_deposit() {
|
||||||
let mut gas_meter = GasMeter::new(GAS_LIMIT);
|
let mut gas_meter = GasMeter::new(GAS_LIMIT);
|
||||||
let _ = execute(
|
assert_ok!(execute(
|
||||||
CODE_TOMBSTONE_DEPOSIT,
|
CODE_TOMBSTONE_DEPOSIT,
|
||||||
vec![],
|
vec![],
|
||||||
MockExt::default(),
|
MockExt::default(),
|
||||||
&mut gas_meter,
|
&mut gas_meter,
|
||||||
).unwrap();
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
const CODE_RANDOM: &str = r#"
|
const CODE_RANDOM: &str = r#"
|
||||||
@@ -1637,12 +1637,12 @@ mod tests {
|
|||||||
fn deposit_event() {
|
fn deposit_event() {
|
||||||
let mut mock_ext = MockExt::default();
|
let mut mock_ext = MockExt::default();
|
||||||
let mut gas_meter = GasMeter::new(GAS_LIMIT);
|
let mut gas_meter = GasMeter::new(GAS_LIMIT);
|
||||||
let _ = execute(
|
assert_ok!(execute(
|
||||||
CODE_DEPOSIT_EVENT,
|
CODE_DEPOSIT_EVENT,
|
||||||
vec![],
|
vec![],
|
||||||
&mut mock_ext,
|
&mut mock_ext,
|
||||||
&mut gas_meter
|
&mut gas_meter
|
||||||
).unwrap();
|
));
|
||||||
|
|
||||||
assert_eq!(mock_ext.events, vec![
|
assert_eq!(mock_ext.events, vec![
|
||||||
(vec![H256::repeat_byte(0x33)],
|
(vec![H256::repeat_byte(0x33)],
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ frame_benchmarking::benchmarks! {
|
|||||||
// assume a queued solution is stored, regardless of where it comes from.
|
// assume a queued solution is stored, regardless of where it comes from.
|
||||||
<QueuedSolution<T>>::put(ready_solution);
|
<QueuedSolution<T>>::put(ready_solution);
|
||||||
}: {
|
}: {
|
||||||
let _ = <MultiPhase<T> as ElectionProvider<T::AccountId, T::BlockNumber>>::elect();
|
assert_ok!(<MultiPhase<T> as ElectionProvider<T::AccountId, T::BlockNumber>>::elect());
|
||||||
} verify {
|
} verify {
|
||||||
assert!(<MultiPhase<T>>::queued_solution().is_none());
|
assert!(<MultiPhase<T>>::queued_solution().is_none());
|
||||||
assert!(<DesiredTargets<T>>::get().is_none());
|
assert!(<DesiredTargets<T>>::get().is_none());
|
||||||
|
|||||||
@@ -1411,7 +1411,7 @@ mod tests {
|
|||||||
roll_to(30);
|
roll_to(30);
|
||||||
assert!(MultiPhase::current_phase().is_signed());
|
assert!(MultiPhase::current_phase().is_signed());
|
||||||
|
|
||||||
let _ = MultiPhase::elect().unwrap();
|
assert_ok!(MultiPhase::elect());
|
||||||
|
|
||||||
assert!(MultiPhase::current_phase().is_off());
|
assert!(MultiPhase::current_phase().is_off());
|
||||||
assert!(MultiPhase::snapshot().is_none());
|
assert!(MultiPhase::snapshot().is_none());
|
||||||
@@ -1434,7 +1434,7 @@ mod tests {
|
|||||||
assert!(MultiPhase::current_phase().is_off());
|
assert!(MultiPhase::current_phase().is_off());
|
||||||
|
|
||||||
// this module is now only capable of doing on-chain backup.
|
// this module is now only capable of doing on-chain backup.
|
||||||
let _ = MultiPhase::elect().unwrap();
|
assert_ok!(MultiPhase::elect());
|
||||||
|
|
||||||
assert!(MultiPhase::current_phase().is_off());
|
assert!(MultiPhase::current_phase().is_off());
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -553,25 +553,25 @@ mod tests {
|
|||||||
#[weight = 100]
|
#[weight = 100]
|
||||||
fn some_function(origin) {
|
fn some_function(origin) {
|
||||||
// NOTE: does not make any different.
|
// NOTE: does not make any different.
|
||||||
let _ = frame_system::ensure_signed(origin);
|
frame_system::ensure_signed(origin)?;
|
||||||
}
|
}
|
||||||
#[weight = (200, DispatchClass::Operational)]
|
#[weight = (200, DispatchClass::Operational)]
|
||||||
fn some_root_operation(origin) {
|
fn some_root_operation(origin) {
|
||||||
let _ = frame_system::ensure_root(origin);
|
frame_system::ensure_root(origin)?;
|
||||||
}
|
}
|
||||||
#[weight = 0]
|
#[weight = 0]
|
||||||
fn some_unsigned_message(origin) {
|
fn some_unsigned_message(origin) {
|
||||||
let _ = frame_system::ensure_none(origin);
|
frame_system::ensure_none(origin)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[weight = 0]
|
#[weight = 0]
|
||||||
fn allowed_unsigned(origin) {
|
fn allowed_unsigned(origin) {
|
||||||
let _ = frame_system::ensure_root(origin)?;
|
frame_system::ensure_root(origin)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[weight = 0]
|
#[weight = 0]
|
||||||
fn unallowed_unsigned(origin) {
|
fn unallowed_unsigned(origin) {
|
||||||
let _ = frame_system::ensure_root(origin)?;
|
frame_system::ensure_root(origin)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// module hooks.
|
// module hooks.
|
||||||
|
|||||||
@@ -621,7 +621,8 @@ decl_module! {
|
|||||||
let active_recovery = <ActiveRecoveries<T>>::take(&who, &rescuer).ok_or(Error::<T>::NotStarted)?;
|
let active_recovery = <ActiveRecoveries<T>>::take(&who, &rescuer).ok_or(Error::<T>::NotStarted)?;
|
||||||
// Move the reserved funds from the rescuer to the rescued account.
|
// Move the reserved funds from the rescuer to the rescued account.
|
||||||
// Acts like a slashing mechanism for those who try to maliciously recover accounts.
|
// Acts like a slashing mechanism for those who try to maliciously recover accounts.
|
||||||
let _ = T::Currency::repatriate_reserved(&rescuer, &who, active_recovery.deposit, BalanceStatus::Free);
|
let res = T::Currency::repatriate_reserved(&rescuer, &who, active_recovery.deposit, BalanceStatus::Free);
|
||||||
|
debug_assert!(res.is_ok());
|
||||||
Self::deposit_event(RawEvent::RecoveryClosed(who, rescuer));
|
Self::deposit_event(RawEvent::RecoveryClosed(who, rescuer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -997,7 +997,8 @@ decl_module! {
|
|||||||
match kind {
|
match kind {
|
||||||
BidKind::Deposit(deposit) => {
|
BidKind::Deposit(deposit) => {
|
||||||
// Slash deposit and move it to the society account
|
// Slash deposit and move it to the society account
|
||||||
let _ = T::Currency::repatriate_reserved(&who, &Self::account_id(), deposit, BalanceStatus::Free);
|
let res = T::Currency::repatriate_reserved(&who, &Self::account_id(), deposit, BalanceStatus::Free);
|
||||||
|
debug_assert!(res.is_ok());
|
||||||
}
|
}
|
||||||
BidKind::Vouch(voucher, _) => {
|
BidKind::Vouch(voucher, _) => {
|
||||||
// Ban the voucher from vouching again
|
// Ban the voucher from vouching again
|
||||||
|
|||||||
@@ -437,7 +437,8 @@ fn no_candidate_emergency_condition() {
|
|||||||
<Staking as crate::Store>::MinimumValidatorCount::put(10);
|
<Staking as crate::Store>::MinimumValidatorCount::put(10);
|
||||||
|
|
||||||
// try to chill
|
// try to chill
|
||||||
let _ = Staking::chill(Origin::signed(10));
|
let res = Staking::chill(Origin::signed(10));
|
||||||
|
assert_ok!(res);
|
||||||
|
|
||||||
// trigger era
|
// trigger era
|
||||||
mock::start_active_era(1);
|
mock::start_active_era(1);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use super::*;
|
|||||||
|
|
||||||
use frame_system::RawOrigin;
|
use frame_system::RawOrigin;
|
||||||
use frame_benchmarking::{benchmarks, account, whitelisted_caller, impl_benchmark_test_suite};
|
use frame_benchmarking::{benchmarks, account, whitelisted_caller, impl_benchmark_test_suite};
|
||||||
use sp_runtime::{traits::{Saturating}};
|
use sp_runtime::traits::Saturating;
|
||||||
|
|
||||||
use crate::Module as TipsMod;
|
use crate::Module as TipsMod;
|
||||||
|
|
||||||
|
|||||||
@@ -68,16 +68,16 @@ use serde::{Serialize, Deserialize};
|
|||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use frame_support::{decl_module, decl_storage, decl_event, ensure, print, decl_error};
|
use frame_support::{decl_module, decl_storage, decl_event, ensure, print, decl_error};
|
||||||
use frame_support::traits::{
|
use frame_support::traits::{
|
||||||
Currency, Get, Imbalance, OnUnbalanced, ExistenceRequirement::{KeepAlive},
|
Currency, Get, Imbalance, OnUnbalanced, ExistenceRequirement::KeepAlive,
|
||||||
ReservableCurrency, WithdrawReasons
|
ReservableCurrency, WithdrawReasons
|
||||||
};
|
};
|
||||||
use sp_runtime::{Permill, ModuleId, RuntimeDebug, traits::{
|
use sp_runtime::{Permill, ModuleId, RuntimeDebug, traits::{
|
||||||
Zero, StaticLookup, AccountIdConversion, Saturating
|
Zero, StaticLookup, AccountIdConversion, Saturating
|
||||||
}};
|
}};
|
||||||
use frame_support::weights::{Weight, DispatchClass};
|
use frame_support::weights::{Weight, DispatchClass};
|
||||||
use frame_support::traits::{EnsureOrigin};
|
use frame_support::traits::EnsureOrigin;
|
||||||
use codec::{Encode, Decode};
|
use codec::{Encode, Decode};
|
||||||
use frame_system::{ensure_signed};
|
use frame_system::ensure_signed;
|
||||||
pub use weights::WeightInfo;
|
pub use weights::WeightInfo;
|
||||||
|
|
||||||
pub type BalanceOf<T, I=DefaultInstance> =
|
pub type BalanceOf<T, I=DefaultInstance> =
|
||||||
@@ -187,10 +187,7 @@ decl_storage! {
|
|||||||
let account_id = <Module<T, I>>::account_id();
|
let account_id = <Module<T, I>>::account_id();
|
||||||
let min = T::Currency::minimum_balance();
|
let min = T::Currency::minimum_balance();
|
||||||
if T::Currency::free_balance(&account_id) < min {
|
if T::Currency::free_balance(&account_id) < min {
|
||||||
let _ = T::Currency::make_free_balance_be(
|
let _ = T::Currency::make_free_balance_be(&account_id, min);
|
||||||
&account_id,
|
|
||||||
min,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user