diff --git a/runtime/gdev/tests/fee_tests.rs b/runtime/gdev/tests/fee_tests.rs index 796cf12210897999359c923562df99c2bcf8a943..14c7f15e3e1e6cc3466913e4bfdeb9f4c0be7839 100644 --- a/runtime/gdev/tests/fee_tests.rs +++ b/runtime/gdev/tests/fee_tests.rs @@ -38,8 +38,14 @@ fn test_fees_empty() { value: 500, }); - let xt = - common::get_unchecked_extrinsic(call, 4u64, 8u64, AccountKeyring::Alice, 0u64, 0); + let xt = common::get_unchecked_extrinsic( + call, + 4u64, + 8u64, + AccountKeyring::Alice, + 0u64, + 0u32, + ); assert_ok!(Executive::apply_extrinsic(xt)); // The block is almost empty, so the extrinsic should incur no fee assert_eq!( @@ -61,35 +67,25 @@ fn test_fees_weight() { ]) .build() .execute_with(|| { - let mut transactions = 0u64; let weights = BlockWeights::get(); let normal_max_weight = weights .get(DispatchClass::Normal) .max_total .unwrap_or(weights.max_block); - // Stopping just below the limit - while System::block_weight() - .get(DispatchClass::Normal) - .all_lt(Target::get() * normal_max_weight * Perbill::from_percent(99)) - { - let call = RuntimeCall::System(SystemCall::remark { - remark: vec![255u8; 1], - }); - let xt = get_unchecked_extrinsic( - call, - 4u64, - 8u64, - AccountKeyring::Alice, - 0u64, - transactions as u32, - ); - assert_ok!(Executive::apply_extrinsic(xt)); - transactions += 1; - } + + // Ensure that the next extrinsic is below the limit. + System::set_block_consumed_resources(Weight::zero(), 0_usize); + + let call = RuntimeCall::System(SystemCall::remark { + remark: vec![255u8; 1], + }); + let xt = get_unchecked_extrinsic(call, 4u64, 8u64, AccountKeyring::Alice, 0u64, 0); + assert_ok!(Executive::apply_extrinsic(xt)); assert_eq!( Balances::free_balance(AccountKeyring::Alice.to_account_id()), 10_000 ); + // Ensure that the next extrinsic exceeds the limit. System::set_block_consumed_resources(Target::get() * normal_max_weight, 0_usize); // The block will reach the fee limit, so the next extrinsic should start incurring fees. @@ -97,14 +93,7 @@ fn test_fees_weight() { remark: vec![255u8; 1], }); - let xt = get_unchecked_extrinsic( - call, - 4u64, - 8u64, - AccountKeyring::Alice, - 0u64, - transactions as u32, - ); + let xt = get_unchecked_extrinsic(call, 4u64, 8u64, AccountKeyring::Alice, 0u64, 1u32); assert_ok!(Executive::apply_extrinsic(xt)); assert_ne!( Balances::free_balance(AccountKeyring::Alice.to_account_id()),