Skip to content

Commit 6cd1350

Browse files
gabriele-0201rphmeier
authored andcommitted
Fee Adjustment Tests
1 parent 796f883 commit 6cd1350

File tree

4 files changed

+588
-56
lines changed

4 files changed

+588
-56
lines changed

sugondat-chain/runtimes/sugondat-kusama/src/fee_adjustment.rs

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,9 @@ where
100100
let max_multiplier = MaximumMultiplierBlockSize::get();
101101
let previous_len_multiplier = previous_len_multiplier.max(min_multiplier);
102102

103-
// Pick the limiting dimension. (from TargetedFeeAdjustment::convert)
104-
//
105-
// In this case it is the length of all extrinsic, always
103+
// The limiting dimension is the length of all extrinsic
106104
let (normal_limiting_dimension, max_limiting_dimension) = (
107-
<frame_system::Pallet<T>>::all_extrinsics_len(),
105+
<frame_system::Pallet<T>>::all_extrinsics_len().min(MAXIMUM_BLOCK_LENGTH),
108106
MAXIMUM_BLOCK_LENGTH as u64,
109107
);
110108

@@ -197,7 +195,7 @@ impl<T: frame_system::Config> sp_weights::WeightToFee for BlobsLengthToFee<T> {
197195
#[cfg(test)]
198196
mod tests {
199197
use super::*;
200-
use crate::{MaxBlobSize, Runtime};
198+
use crate::Runtime;
201199
use sp_runtime::BuildStorage;
202200

203201
fn new_test_ext() -> sp_io::TestExternalities {
@@ -225,37 +223,4 @@ mod tests {
225223
);
226224
});
227225
}
228-
229-
#[test]
230-
fn test_blobs_fee_adjustment_convert() {
231-
use codec::Encode;
232-
use sp_core::twox_128;
233-
234-
for len in (0..MaxBlobSize::get()).into_iter().step_by(100) {
235-
new_test_ext().execute_with(|| {
236-
// AllExtrinsicsLen is a private storage value of the system pallet
237-
// so the key must be manually constructed
238-
sp_io::storage::set(
239-
&[twox_128(b"System"), twox_128(b"AllExtrinsicsLen")].concat(),
240-
&len.encode(),
241-
);
242-
243-
let fee_multiplier = Multiplier::saturating_from_rational(7, 8);
244-
245-
let new_fee_multiplier = BlobsFeeAdjustment::<Runtime>::convert(fee_multiplier);
246-
247-
// fee_multiplier should follow the standard behavior
248-
let expected_fee_multiplier = TargetedFeeAdjustment::<
249-
Runtime,
250-
TargetBlockFullness,
251-
AdjustmentVariableBlockFullness,
252-
MinimumMultiplierBlockFullness,
253-
MaximumMultiplierBlockFullness,
254-
>::convert(fee_multiplier);
255-
assert_eq!(new_fee_multiplier, expected_fee_multiplier);
256-
257-
// TODO: Ensure length multiplier is update properly
258-
});
259-
}
260-
}
261226
}

0 commit comments

Comments
 (0)