Skip to content

Commit 373eda4

Browse files
committed
Added advance_block and changed storage sizes
1 parent 64401a5 commit 373eda4

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

runtimes/bulletin-westend/tests/tests.rs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,26 @@ use xcm_runtime_apis::conversions::LocationToAccountHelper;
3535

3636
const ALICE: [u8; 32] = [1u8; 32];
3737

38+
/// Advance to the next block for testing transaction storage.
39+
fn advance_block() {
40+
use bulletin_westend_runtime::TransactionStorage;
41+
use frame_support::traits::{OnFinalize, OnInitialize};
42+
43+
let current = frame_system::Pallet::<Runtime>::block_number();
44+
45+
TransactionStorage::on_finalize(current);
46+
System::on_finalize(current);
47+
48+
let next = current + 1;
49+
System::set_block_number(next);
50+
51+
frame_system::BlockWeight::<Runtime>::kill();
52+
frame_system::AllExtrinsicsLen::<Runtime>::kill();
53+
54+
System::on_initialize(next);
55+
TransactionStorage::on_initialize(next);
56+
}
57+
3858
fn construct_extrinsic(
3959
sender: sp_core::sr25519::Pair,
4060
call: RuntimeCall,
@@ -105,11 +125,11 @@ fn transaction_storage_runtime_sizes() {
105125
let who: AccountId = account.to_account_id();
106126
#[allow(clippy::identity_op)]
107127
let sizes: [usize; 5] = [
108-
2000, // 2 KB
109-
256 * 1024, // 256 KB
110-
512 * 1024, // 512 KB
111-
1 * 1024 * 1024, // 1 MB
112-
(3 * 1024 * 1024) / 2, // 1.5 MB
128+
2000, // 2 KB
129+
1 * 1024 * 1024, // 1 MB
130+
4 * 1024 * 1024, // 4 MB
131+
6 * 1024 * 1024, // 6 MB
132+
8 * 1024 * 1024, // 8 MB
113133
];
114134
let total_bytes: u64 = sizes.iter().map(|s| *s as u64).sum();
115135

@@ -131,6 +151,9 @@ fn transaction_storage_runtime_sizes() {
131151

132152
// store data via signed extrinsics (ValidateSigned consumes authorization)
133153
for (index, size) in sizes.into_iter().enumerate() {
154+
// Advance to a new block for each store
155+
advance_block();
156+
134157
tracing::info!("Storing data with size: {size} and index: {index}");
135158
let res = construct_and_apply_extrinsic(
136159
account.pair(),

0 commit comments

Comments
 (0)