Companion for Weight v1.5 (#5943)

* fix to latest substrate pr

* update weights

* cargo build -p polkadot-runtime-parachains

* fix xcm-builder

* fix import

* fix a bunch

* fix a bunch of weight stuff

* kusama compile

* unused

* builds

* maybe fix

* cargo test -p polkadot-runtime-parachains

* xcm simulator example

* fix tests

* xcm sim fuzz

* fix runtime tests

* remove unused

* fix integration tests

* scalar div

* update lockfile for {"substrate"}

Co-authored-by: parity-processbot <>
This commit is contained in:
Shawn Tabrizi
2022-08-31 12:59:39 +01:00
committed by GitHub
parent 138aae0a22
commit 28e94d97dd
231 changed files with 4577 additions and 4514 deletions
@@ -1136,7 +1136,7 @@ pub struct SessionChangeOutcome<BlockNumber> {
impl<T: Config> Pallet<T> {
/// Called by the initializer to initialize the configuration pallet.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight {
0
Weight::zero()
}
/// Called by the initializer to finalize the configuration pallet.
@@ -26,7 +26,7 @@ benchmarks! {
set_config_with_option_u32 {}: set_max_validators(RawOrigin::Root, Some(10))
set_config_with_weight {}: set_ump_service_total_weight(RawOrigin::Root, 3_000_000)
set_config_with_weight {}: set_ump_service_total_weight(RawOrigin::Root, Weight::from_ref_time(3_000_000))
set_hrmp_open_request_ttl {}: {
Err(BenchmarkError::Override(
@@ -319,7 +319,7 @@ fn setting_pending_config_members() {
max_upward_queue_count: 1337,
max_upward_queue_size: 228,
max_downward_message_size: 2048,
ump_service_total_weight: 20000,
ump_service_total_weight: Weight::from_ref_time(20000),
max_upward_message_size: 448,
max_upward_message_num_per_candidate: 5,
hrmp_sender_deposit: 22,
@@ -332,7 +332,7 @@ fn setting_pending_config_members() {
hrmp_max_parachain_outbound_channels: 10,
hrmp_max_parathread_outbound_channels: 20,
hrmp_max_message_num_per_candidate: 20,
ump_max_individual_weight: 909,
ump_max_individual_weight: Weight::from_ref_time(909),
pvf_checking_enabled: true,
pvf_voting_ttl: 3,
minimum_validation_upgrade_delay: 20,
+3 -3
View File
@@ -322,7 +322,7 @@ impl<BlockNumber: Ord> DisputesHandler<BlockNumber> for () {
}
fn initializer_initialize(_now: BlockNumber) -> Weight {
0
Weight::zero()
}
fn initializer_finalize() {}
@@ -398,7 +398,7 @@ pub trait WeightInfo {
pub struct TestWeightInfo;
impl WeightInfo for TestWeightInfo {
fn force_unfreeze() -> Weight {
0
Weight::zero()
}
}
@@ -797,7 +797,7 @@ impl<T: Config> Pallet<T> {
pub(crate) fn initializer_initialize(now: T::BlockNumber) -> Weight {
let config = <configuration::Pallet<T>>::config();
let mut weight = 0;
let mut weight = Weight::new();
for (session_index, candidate_hash, mut dispute) in <Disputes<T>>::iter() {
weight += T::DbWeight::get().reads_writes(1, 0);
+1 -1
View File
@@ -109,7 +109,7 @@ pub mod pallet {
impl<T: Config> Pallet<T> {
/// Block initialization logic, called by initializer.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight {
0
Weight::zero()
}
/// Block finalization logic, called by initializer.
+3 -3
View File
@@ -609,7 +609,7 @@ fn preopen_hrmp_channel<T: Config>(
impl<T: Config> Pallet<T> {
/// Block initialization logic, called by initializer.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight {
0
Weight::zero()
}
/// Block finalization logic, called by initializer.
@@ -953,7 +953,7 @@ impl<T: Config> Pallet<T> {
}
pub(crate) fn prune_hrmp(recipient: ParaId, new_hrmp_watermark: T::BlockNumber) -> Weight {
let mut weight = 0;
let mut weight = Weight::new();
// sift through the incoming messages digest to collect the paras that sent at least one
// message to this parachain between the old and new watermarks.
@@ -1020,7 +1020,7 @@ impl<T: Config> Pallet<T> {
sender: ParaId,
out_hrmp_msgs: Vec<OutboundHrmpMessage<ParaId>>,
) -> Weight {
let mut weight = 0;
let mut weight = Weight::new();
let now = <frame_system::Pallet<T>>::block_number();
for out_msg in out_hrmp_msgs {
@@ -303,7 +303,7 @@ const LOG_TARGET: &str = "runtime::inclusion";
impl<T: Config> Pallet<T> {
/// Block initialization logic, called by initializer.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight {
0
Weight::zero()
}
/// Block finalization logic, called by initializer.
+6 -6
View File
@@ -82,7 +82,7 @@ where
parameter_types! {
pub const BlockHashCount: u32 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(4 * 1024 * 1024);
frame_system::limits::BlockWeights::simple_max(Weight::from_ref_time(4 * 1024 * 1024));
}
pub type AccountId = u64;
@@ -204,11 +204,11 @@ impl frame_support::traits::EstimateNextSessionRotation<u32> for TestNextSession
}
fn estimate_current_session_progress(_now: u32) -> (Option<Permill>, Weight) {
(None, 0)
(None, Weight::zero())
}
fn estimate_next_session_rotation(_now: u32) -> (Option<u32>, Weight) {
(None, 0)
(None, Weight::zero())
}
}
@@ -222,7 +222,7 @@ impl crate::paras::Config for Test {
impl crate::dmp::Config for Test {}
parameter_types! {
pub const FirstMessageFactorPercent: u64 = 100;
pub const FirstMessageFactorPercent: Weight = Weight::from_ref_time(100);
}
impl crate::ump::Config for Test {
@@ -392,8 +392,8 @@ impl UmpSink for TestUmpSink {
max_weight: Weight,
) -> Result<Weight, (MessageId, Weight)> {
let weight = match u32::decode(&mut &actual_msg[..]) {
Ok(w) => w as Weight,
Err(_) => return Ok(0), // same as the real `UmpSink`
Ok(w) => Weight::from_ref_time(w as u64),
Err(_) => return Ok(Weight::zero()), // same as the real `UmpSink`
};
if weight > max_weight {
let id = sp_io::hashing::blake2_256(actual_msg);
+6 -6
View File
@@ -449,7 +449,7 @@ impl WeightInfo for TestWeightInfo {
}
fn include_pvf_check_statement() -> Weight {
// This special value is to distinguish from the finalizing variants above in tests.
Weight::MAX - 1
Weight::MAX - Weight::one()
}
}
@@ -1372,7 +1372,7 @@ impl<T: Config> Pallet<T> {
sessions_observed: SessionIndex,
cfg: &configuration::HostConfiguration<T::BlockNumber>,
) -> Weight {
let mut weight = 0;
let mut weight = Weight::new();
for cause in causes {
weight += T::DbWeight::get().reads_writes(3, 2);
Self::deposit_event(Event::PvfCheckAccepted(*code_hash, cause.para_id()));
@@ -1417,7 +1417,7 @@ impl<T: Config> Pallet<T> {
relay_parent_number: T::BlockNumber,
cfg: &configuration::HostConfiguration<T::BlockNumber>,
) -> Weight {
let mut weight = 0;
let mut weight = Weight::new();
// Compute the relay-chain block number starting at which the code upgrade is ready to be
// applied.
@@ -1457,7 +1457,7 @@ impl<T: Config> Pallet<T> {
code_hash: &ValidationCodeHash,
causes: Vec<PvfCheckCause<T::BlockNumber>>,
) -> Weight {
let mut weight = 0;
let mut weight = Weight::new();
for cause in causes {
// Whenever PVF pre-checking is started or a new cause is added to it, the RC is bumped.
@@ -1746,7 +1746,7 @@ impl<T: Config> Pallet<T> {
code: ValidationCode,
cfg: &configuration::HostConfiguration<T::BlockNumber>,
) -> Weight {
let mut weight = 0;
let mut weight = Weight::new();
weight += T::DbWeight::get().reads_writes(3, 2);
Self::deposit_event(Event::PvfCheckStarted(code_hash, cause.para_id()));
@@ -1845,7 +1845,7 @@ impl<T: Config> Pallet<T> {
Self::note_past_code(id, expected_at, now, prior_code_hash)
} else {
log::error!(target: LOG_TARGET, "Missing prior code hash for para {:?}", &id);
0 as Weight
Weight::zero()
};
// add 1 to writes due to heads update.
@@ -339,7 +339,8 @@ impl<T: Config> Pallet<T> {
let max_block_weight = <T as frame_system::Config>::BlockWeights::get().max_block;
METRICS.on_before_filter(candidates_weight + bitfields_weight + disputes_weight);
METRICS
.on_before_filter((candidates_weight + bitfields_weight + disputes_weight).ref_time());
T::DisputesHandler::assure_deduplicated_and_sorted(&mut disputes)
.map_err(|_e| Error::<T>::DisputeStatementsUnsortedOrDuplicates)?;
@@ -377,9 +378,9 @@ impl<T: Config> Pallet<T> {
{
log::warn!("Overweight para inherent data reached the runtime {:?}", parent_hash);
backed_candidates.clear();
candidates_weight = 0;
candidates_weight = Weight::zero();
signed_bitfields.clear();
bitfields_weight = 0;
bitfields_weight = Weight::zero();
}
let entropy = compute_entropy::<T>(parent_hash);
@@ -537,7 +538,7 @@ impl<T: Config> Pallet<T> {
// this is max config.ump_service_total_weight
let _ump_weight = <ump::Pallet<T>>::process_pending_upward_messages();
METRICS.on_after_filter(total_consumed_weight);
METRICS.on_after_filter(total_consumed_weight.ref_time());
Ok(Some(total_consumed_weight).into())
}
@@ -803,7 +804,7 @@ fn random_sel<X, F: Fn(&X) -> Weight>(
weight_limit: Weight,
) -> (Weight, Vec<usize>) {
if selectables.is_empty() {
return (0 as Weight, Vec::new())
return (Weight::zero(), Vec::new())
}
// all indices that are not part of the preferred set
let mut indices = (0..selectables.len())
@@ -812,7 +813,7 @@ fn random_sel<X, F: Fn(&X) -> Weight>(
.collect::<Vec<_>>();
let mut picked_indices = Vec::with_capacity(selectables.len().saturating_sub(1));
let mut weight_acc = 0 as Weight;
let mut weight_acc = Weight::zero();
preferred_indices.shuffle(rng);
for preferred_idx in preferred_indices {
@@ -893,7 +894,7 @@ fn apply_weight_limit<T: Config + inclusion::Config>(
// There is weight remaining to be consumed by a subset of candidates
// which are going to be picked now.
if let Some(max_consumable_by_candidates) =
max_consumable_weight.checked_sub(total_bitfields_weight)
max_consumable_weight.checked_sub(&total_bitfields_weight)
{
let (acc_candidate_weight, indices) =
random_sel::<BackedCandidate<<T as frame_system::Config>::Hash>, _>(
@@ -1265,7 +1266,7 @@ fn limit_and_sanitize_disputes<
let remote_disputes = disputes.split_off(idx);
// Accumualated weight of all disputes picked, that passed the checks.
let mut weight_acc = 0 as Weight;
let mut weight_acc = Weight::zero();
// Select disputes in-order until the remaining weight is attained
disputes.iter().for_each(|dss| {
@@ -37,18 +37,18 @@ pub struct TestWeightInfo;
impl WeightInfo for TestWeightInfo {
fn enter_variable_disputes(v: u32) -> Weight {
// MAX Block Weight should fit 4 disputes
80_000 * v as Weight + 80_000
Weight::from_ref_time(80_000 * v as u64 + 80_000)
}
fn enter_bitfields() -> Weight {
// MAX Block Weight should fit 4 backed candidates
40_000 as Weight
Weight::from_ref_time(40_000u64)
}
fn enter_backed_candidates_variable(v: u32) -> Weight {
// MAX Block Weight should fit 4 backed candidates
40_000 * v as Weight + 40_000
Weight::from_ref_time(40_000 * v as u64 + 40_000)
}
fn enter_backed_candidate_code_upgrade() -> Weight {
0
Weight::zero()
}
}
// To simplify benchmarks running as tests, we set all the weights to 0. `enter` will exit early
@@ -57,16 +57,16 @@ impl WeightInfo for TestWeightInfo {
#[cfg(feature = "runtime-benchmarks")]
impl WeightInfo for TestWeightInfo {
fn enter_variable_disputes(_v: u32) -> Weight {
0
Weight::zero()
}
fn enter_bitfields() -> Weight {
0
Weight::zero()
}
fn enter_backed_candidates_variable(_v: u32) -> Weight {
0
Weight::zero()
}
fn enter_backed_candidate_code_upgrade() -> Weight {
0
Weight::zero()
}
}
@@ -99,12 +99,12 @@ pub fn multi_dispute_statement_sets_weight<
.as_ref()
.iter()
.map(|d| dispute_statement_set_weight::<T, &S>(d))
.fold(0, |acc_weight, weight| acc_weight.saturating_add(weight))
.fold(Weight::new(), |acc_weight, weight| acc_weight.saturating_add(weight))
}
pub fn signed_bitfields_weight<T: Config>(bitfields_len: usize) -> Weight {
<<T as Config>::WeightInfo as WeightInfo>::enter_bitfields()
.saturating_mul(bitfields_len as Weight)
.saturating_mul(Weight::from_ref_time(bitfields_len as u64))
}
pub fn backed_candidate_weight<T: frame_system::Config + Config>(
@@ -125,5 +125,5 @@ pub fn backed_candidates_weight<T: frame_system::Config + Config>(
candidates
.iter()
.map(|c| backed_candidate_weight::<T>(c))
.fold(0, |acc, x| acc.saturating_add(x))
.fold(Weight::new(), |acc, x| acc.saturating_add(x))
}
+1 -1
View File
@@ -226,7 +226,7 @@ pub mod pallet {
impl<T: Config> Pallet<T> {
/// Called by the initializer to initialize the scheduler pallet.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight {
0
Weight::zero()
}
/// Called by the initializer to finalize the scheduler pallet.
@@ -188,7 +188,7 @@ impl<T: Config> Pallet<T> {
/// Called by the initializer to initialize the session info pallet.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight {
0
Weight::zero()
}
/// Called by the initializer to finalize the session info pallet.
+1 -1
View File
@@ -75,7 +75,7 @@ pub mod pallet {
impl<T: Config> Pallet<T> {
/// Called by the initializer to initialize the configuration pallet.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight {
0
Weight::zero()
}
/// Called by the initializer to finalize the configuration pallet.
+12 -10
View File
@@ -73,7 +73,7 @@ impl UmpSink for () {
_: &[u8],
_: Weight,
) -> Result<Weight, (MessageId, Weight)> {
Ok(0)
Ok(Weight::zero())
}
}
@@ -123,7 +123,7 @@ impl<XcmExecutor: xcm::latest::ExecuteXcm<C::Call>, C: Config> UmpSink for XcmSi
match maybe_msg_and_weight {
Err(_) => {
Pallet::<C>::deposit_event(Event::InvalidFormat(id));
Ok(0)
Ok(Weight::zero())
},
Ok((Err(()), weight_used)) => {
Pallet::<C>::deposit_event(Event::UnsupportedVersion(id));
@@ -131,11 +131,13 @@ impl<XcmExecutor: xcm::latest::ExecuteXcm<C::Call>, C: Config> UmpSink for XcmSi
},
Ok((Ok(xcm_message), weight_used)) => {
let xcm_junction = Junction::Parachain(origin.into());
let outcome = XcmExecutor::execute_xcm(xcm_junction, xcm_message, max_weight);
let outcome =
XcmExecutor::execute_xcm(xcm_junction, xcm_message, max_weight.ref_time());
match outcome {
Outcome::Error(XcmError::WeightLimitReached(required)) => Err((id, required)),
Outcome::Error(XcmError::WeightLimitReached(required)) =>
Err((id, Weight::from_ref_time(required))),
outcome => {
let outcome_weight = outcome.weight_used();
let outcome_weight = Weight::from_ref_time(outcome.weight_used());
Pallet::<C>::deposit_event(Event::ExecutedUpward(id, outcome));
Ok(weight_used.saturating_add(outcome_weight))
},
@@ -368,7 +370,7 @@ pub mod pallet {
impl<T: Config> Pallet<T> {
/// Block initialization logic, called by initializer.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight {
0
Weight::zero()
}
/// Block finalization logic, called by initializer.
@@ -385,7 +387,7 @@ impl<T: Config> Pallet<T> {
/// Iterate over all paras that were noted for offboarding and remove all the data
/// associated with them.
fn perform_outgoing_para_cleanup(outgoing: &[ParaId]) -> Weight {
let mut weight: Weight = 0;
let mut weight: Weight = Weight::new();
for outgoing_para in outgoing {
weight = weight.saturating_add(Self::clean_ump_after_outgoing(outgoing_para));
}
@@ -467,7 +469,7 @@ impl<T: Config> Pallet<T> {
para: ParaId,
upward_messages: Vec<UpwardMessage>,
) -> Weight {
let mut weight = 0;
let mut weight = Weight::new();
if !upward_messages.is_empty() {
let (extra_count, extra_size) = upward_messages
@@ -503,7 +505,7 @@ impl<T: Config> Pallet<T> {
/// Devote some time into dispatching pending upward messages.
pub(crate) fn process_pending_upward_messages() -> Weight {
let mut weight_used = 0;
let mut weight_used = Weight::new();
let config = <configuration::Pallet<T>>::config();
let mut cursor = NeedsDispatchCursor::new::<T>();
@@ -517,7 +519,7 @@ impl<T: Config> Pallet<T> {
// if so - bail.
break
}
let max_weight = if weight_used == 0 {
let max_weight = if weight_used == Weight::zero() {
// we increase the amount of weight that we're allowed to use on the first message to try to prevent
// the possibility of blockage of the queue.
config.ump_service_total_weight * T::FirstMessageFactorPercent::get() / 100
@@ -43,7 +43,7 @@ fn create_message_min_size<T: Config>(size: u32) -> Vec<u8> {
// Create a message with an empty remark call to determine the encoding overhead
let msg_size_empty_transact = VersionedXcm::<T>::from(Xcm::<T>(vec![Transact {
origin_type: OriginKind::SovereignAccount,
require_weight_at_most: Weight::MAX,
require_weight_at_most: Weight::MAX.ref_time(),
call: frame_system::Call::<T>::remark_with_event { remark: vec![] }.encode().into(),
}]))
.encode()
@@ -55,7 +55,7 @@ fn create_message_min_size<T: Config>(size: u32) -> Vec<u8> {
remark.resize(size, 0u8);
let msg = VersionedXcm::<T>::from(Xcm::<T>(vec![Transact {
origin_type: OriginKind::SovereignAccount,
require_weight_at_most: Weight::MAX,
require_weight_at_most: Weight::MAX.ref_time(),
call: frame_system::Call::<T>::remark_with_event { remark }.encode().into(),
}]))
.encode();
@@ -70,7 +70,7 @@ fn create_message_overweight<T: Config>() -> Vec<u8> {
let call = frame_system::Call::<T>::set_code { code: vec![] };
VersionedXcm::<T>::from(Xcm::<T>(vec![Transact {
origin_type: OriginKind::Superuser,
require_weight_at_most: max_block_weight,
require_weight_at_most: max_block_weight.ref_time(),
call: call.encode().into(),
}]))
.encode()
@@ -107,7 +107,7 @@ frame_benchmarking::benchmarks! {
service_overweight {
let host_conf = configuration::ActiveConfig::<T>::get();
let weight = host_conf.ump_max_individual_weight + host_conf.ump_max_individual_weight + 1000000;
let weight = host_conf.ump_max_individual_weight + host_conf.ump_max_individual_weight + Weight::from_ref_time(1000000);
let para = ParaId::from(1978);
// The message's weight does not really matter here, as we add service_overweight's
// max_weight parameter to the extrinsic's weight in the weight calculation.
@@ -117,18 +117,18 @@ frame_benchmarking::benchmarks! {
let msg = create_message_overweight::<T>();
// This just makes sure that 0 is not a valid index and we can use it later on.
let _ = Ump::<T>::service_overweight(RawOrigin::Root.into(), 0, 1000);
let _ = Ump::<T>::service_overweight(RawOrigin::Root.into(), 0, Weight::from_ref_time(1000));
// Start with the block number 1. This is needed because should an event be
// emitted during the genesis block they will be implicitly wiped.
frame_system::Pallet::<T>::set_block_number(1u32.into());
queue_upward_msg::<T>(&host_conf, para, msg.clone());
Ump::<T>::process_pending_upward_messages();
assert_last_event_type::<T>(
Event::OverweightEnqueued(para, upward_message_id(&msg), 0, 0).into()
Event::OverweightEnqueued(para, upward_message_id(&msg), 0, Weight::zero()).into()
);
}: _(RawOrigin::Root, 0, Weight::MAX)
verify {
assert_last_event_type::<T>(Event::OverweightServiced(0, 0).into());
assert_last_event_type::<T>(Event::OverweightServiced(0, Weight::zero()).into());
}
}
+28 -14
View File
@@ -38,8 +38,8 @@ impl Default for GenesisConfigBuilder {
max_upward_message_num_per_candidate: 2,
max_upward_queue_count: 4,
max_upward_queue_size: 64,
ump_service_total_weight: 1000,
ump_max_individual_weight: 100,
ump_service_total_weight: Weight::from_ref_time(1000),
ump_max_individual_weight: Weight::from_ref_time(100),
}
}
}
@@ -155,7 +155,11 @@ fn dispatch_resume_after_exceeding_dispatch_stage_weight() {
let q_msg = (500u32, "q_msg").encode();
new_test_ext(
GenesisConfigBuilder { ump_service_total_weight: 500, ..Default::default() }.build(),
GenesisConfigBuilder {
ump_service_total_weight: Weight::from_ref_time(500),
..Default::default()
}
.build(),
)
.execute_with(|| {
queue_upward_msg(q, q_msg.clone());
@@ -199,8 +203,8 @@ fn dispatch_keeps_message_after_weight_exhausted() {
new_test_ext(
GenesisConfigBuilder {
ump_service_total_weight: 500,
ump_max_individual_weight: 300,
ump_service_total_weight: Weight::from_ref_time(500),
ump_max_individual_weight: Weight::from_ref_time(300),
..Default::default()
}
.build(),
@@ -238,7 +242,11 @@ fn dispatch_correctly_handle_remove_of_latest() {
let b_msg_1 = (300u32, "b_msg_1").encode();
new_test_ext(
GenesisConfigBuilder { ump_service_total_weight: 900, ..Default::default() }.build(),
GenesisConfigBuilder {
ump_service_total_weight: Weight::from_ref_time(900),
..Default::default()
}
.build(),
)
.execute_with(|| {
// We want to test here an edge case, where we remove the queue with the highest
@@ -288,7 +296,7 @@ fn service_overweight_unknown() {
// the next test.
new_test_ext(GenesisConfigBuilder::default().build()).execute_with(|| {
assert_noop!(
Ump::service_overweight(Origin::root(), 0, 1000),
Ump::service_overweight(Origin::root(), 0, Weight::from_ref_time(1000)),
Error::<Test>::UnknownMessageIndex
);
});
@@ -304,8 +312,8 @@ fn overweight_queue_works() {
new_test_ext(
GenesisConfigBuilder {
ump_service_total_weight: 900,
ump_max_individual_weight: 300,
ump_service_total_weight: Weight::from_ref_time(900),
ump_max_individual_weight: Weight::from_ref_time(300),
..Default::default()
}
.build(),
@@ -326,24 +334,30 @@ fn overweight_queue_works() {
queue_upward_msg(para_a, a_msg_3.clone());
Ump::process_pending_upward_messages();
assert_last_event(
Event::OverweightEnqueued(para_a, upward_message_id(&a_msg_3[..]), 0, 500).into(),
Event::OverweightEnqueued(
para_a,
upward_message_id(&a_msg_3[..]),
0,
Weight::from_ref_time(500),
)
.into(),
);
// Now verify that if we wanted to service this overweight message with less than enough
// weight it will fail.
assert_noop!(
Ump::service_overweight(Origin::root(), 0, 499),
Ump::service_overweight(Origin::root(), 0, Weight::from_ref_time(499)),
Error::<Test>::WeightOverLimit
);
// ... and if we try to service it with just enough weight it will succeed as well.
assert_ok!(Ump::service_overweight(Origin::root(), 0, 500));
assert_last_event(Event::OverweightServiced(0, 500).into());
assert_ok!(Ump::service_overweight(Origin::root(), 0, Weight::from_ref_time(500)));
assert_last_event(Event::OverweightServiced(0, Weight::from_ref_time(500)).into());
// ... and if we try to service a message with index that doesn't exist it will error
// out.
assert_noop!(
Ump::service_overweight(Origin::root(), 1, 1000),
Ump::service_overweight(Origin::root(), 1, Weight::from_ref_time(1000)),
Error::<Test>::UnknownMessageIndex
);
});