mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 05:31:02 +00:00
Weight v1.5: Opaque Struct (#12138)
* initial idea * update frame_support * update a bunch more * add ord * adjust RuntimeDbWeight * frame_system builds * re-export * frame_support tests pass * frame_executive compile * frame_executive builds * frame_system tests passing * pallet-utility tests pass * fix a bunch of pallets * more * phragmen * state-trie-migration * scheduler and referenda * pallet-election-provider-multi-phase * aura * staking * more * babe * balances * bunch more * sudo * transaction-payment * asset-tx-payment * last pallets * fix alliance merge * fix node template runtime * fix pallet-contracts cc @athei * fix node runtime * fix compile on runtime-benchmarks feature * comment * fix frame-support-test * fix more tests * weight regex * frame system works * fix a bunch * more * more * more * more * more * more fixes * update templates * fix contracts benchmarks * Update lib.rs * Update lib.rs * fix ui * make scalar saturating mul const * more const functions * scalar div * refactor using constant functions * move impl * fix overhead template * use compactas * Update lib.rs
This commit is contained in:
@@ -99,7 +99,7 @@ frame_support::construct_runtime!(
|
||||
|
||||
parameter_types! {
|
||||
pub BlockWeights: frame_system::limits::BlockWeights =
|
||||
frame_system::limits::BlockWeights::simple_max(Weight::max_value());
|
||||
frame_system::limits::BlockWeights::simple_max(Weight::MAX);
|
||||
}
|
||||
impl frame_system::Config for Test {
|
||||
type BaseCallFilter = TestBaseCallFilter;
|
||||
@@ -191,7 +191,7 @@ fn call_transfer(dest: u64, value: u64) -> Call {
|
||||
Call::Balances(BalancesCall::transfer { dest, value })
|
||||
}
|
||||
|
||||
fn call_foobar(err: bool, start_weight: u64, end_weight: Option<u64>) -> Call {
|
||||
fn call_foobar(err: bool, start_weight: Weight, end_weight: Option<Weight>) -> Call {
|
||||
Call::Example(ExampleCall::foobar { err, start_weight, end_weight })
|
||||
}
|
||||
|
||||
@@ -213,8 +213,8 @@ fn as_derivative_works() {
|
||||
#[test]
|
||||
fn as_derivative_handles_weight_refund() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let start_weight = 100;
|
||||
let end_weight = 75;
|
||||
let start_weight = Weight::from_ref_time(100);
|
||||
let end_weight = Weight::from_ref_time(75);
|
||||
let diff = start_weight - end_weight;
|
||||
|
||||
// Full weight when ok
|
||||
@@ -364,24 +364,24 @@ fn batch_weight_calculation_doesnt_overflow() {
|
||||
use sp_runtime::Perbill;
|
||||
new_test_ext().execute_with(|| {
|
||||
let big_call = Call::System(SystemCall::fill_block { ratio: Perbill::from_percent(50) });
|
||||
assert_eq!(big_call.get_dispatch_info().weight, Weight::max_value() / 2);
|
||||
assert_eq!(big_call.get_dispatch_info().weight, Weight::MAX / 2);
|
||||
|
||||
// 3 * 50% saturates to 100%
|
||||
let batch_call = Call::Utility(crate::Call::batch {
|
||||
calls: vec![big_call.clone(), big_call.clone(), big_call.clone()],
|
||||
});
|
||||
|
||||
assert_eq!(batch_call.get_dispatch_info().weight, Weight::max_value());
|
||||
assert_eq!(batch_call.get_dispatch_info().weight, Weight::MAX);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_handles_weight_refund() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let start_weight = 100;
|
||||
let end_weight = 75;
|
||||
let start_weight = Weight::from_ref_time(100);
|
||||
let end_weight = Weight::from_ref_time(75);
|
||||
let diff = start_weight - end_weight;
|
||||
let batch_len: Weight = 4;
|
||||
let batch_len = 4;
|
||||
|
||||
// Full weight when ok
|
||||
let inner_call = call_foobar(false, start_weight, None);
|
||||
@@ -420,7 +420,7 @@ fn batch_handles_weight_refund() {
|
||||
let good_call = call_foobar(false, start_weight, Some(end_weight));
|
||||
let bad_call = call_foobar(true, start_weight, Some(end_weight));
|
||||
let batch_calls = vec![good_call, bad_call];
|
||||
let batch_len = batch_calls.len() as Weight;
|
||||
let batch_len = Weight::from_ref_time(batch_calls.len() as u64);
|
||||
let call = Call::Utility(UtilityCall::batch { calls: batch_calls });
|
||||
let info = call.get_dispatch_info();
|
||||
let result = call.dispatch(Origin::signed(1));
|
||||
@@ -494,10 +494,10 @@ fn batch_all_revert() {
|
||||
#[test]
|
||||
fn batch_all_handles_weight_refund() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let start_weight = 100;
|
||||
let end_weight = 75;
|
||||
let start_weight = Weight::from_ref_time(100);
|
||||
let end_weight = Weight::from_ref_time(75);
|
||||
let diff = start_weight - end_weight;
|
||||
let batch_len: Weight = 4;
|
||||
let batch_len = 4;
|
||||
|
||||
// Full weight when ok
|
||||
let inner_call = call_foobar(false, start_weight, None);
|
||||
@@ -533,7 +533,7 @@ fn batch_all_handles_weight_refund() {
|
||||
let good_call = call_foobar(false, start_weight, Some(end_weight));
|
||||
let bad_call = call_foobar(true, start_weight, Some(end_weight));
|
||||
let batch_calls = vec![good_call, bad_call];
|
||||
let batch_len = batch_calls.len() as Weight;
|
||||
let batch_len = Weight::from_ref_time(batch_calls.len() as u64);
|
||||
let call = Call::Utility(UtilityCall::batch_all { calls: batch_calls });
|
||||
let info = call.get_dispatch_info();
|
||||
let result = call.dispatch(Origin::signed(1));
|
||||
@@ -616,7 +616,7 @@ fn force_batch_works() {
|
||||
Origin::signed(1),
|
||||
vec![
|
||||
call_transfer(2, 5),
|
||||
call_foobar(true, 75, None),
|
||||
call_foobar(true, Weight::from_ref_time(75), None),
|
||||
call_transfer(2, 10),
|
||||
call_transfer(2, 5),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user