Skip to content

Commit f5e670e

Browse files
committed
Applied suggestions from Serban's comments
1 parent 1483435 commit f5e670e

File tree

1 file changed

+18
-2
lines changed
  • runtimes/bulletin-polkadot/tests

1 file changed

+18
-2
lines changed

runtimes/bulletin-polkadot/tests/tests.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ use sp_runtime::traits::Dispatchable;
1212
use sp_keyring::Sr25519Keyring;
1313
use sp_runtime::ApplyExtrinsicResult;
1414
use sp_transaction_storage_proof::TransactionStorageProof;
15+
use pallet_transaction_storage::DEFAULT_MAX_TRANSACTION_SIZE;
1516

16-
fn run_to_block(n: u32) {
17+
fn advance_block() {
1718
Executive::finalize_block();
1819
let next_number = System::block_number() + 1;
1920
let header = Header::new(next_number, Default::default(), Default::default(), Default::default(), Default::default());
@@ -118,14 +119,29 @@ fn transaction_storage_runtime_sizes() {
118119
assert!(res.is_ok(), "Failed at size={} bytes: {:?}", size, res);
119120

120121
block_number += 1;
121-
run_to_block(block_number);
122+
advance_block();
122123
}
123124

124125
assert_eq!(
125126
runtime::TransactionStorage::account_authorization_extent(who.clone()),
126127
AuthorizationExtent { transactions: 0, bytes: 0 },
127128
);
128129

130+
// 11 MB should exceed MaxTransactionSize (8 MB) and fail
131+
let oversize: usize = DEFAULT_MAX_TRANSACTION_SIZE as usize + 1;//11 * 1024 * 1024;
132+
assert_ok!(runtime::TransactionStorage::authorize_account(
133+
runtime::RuntimeOrigin::root(),
134+
who.clone(),
135+
1,
136+
oversize as u64,
137+
));
138+
let too_big_call = RuntimeCall::TransactionStorage(TxCall::<runtime::Runtime>::store { data: vec![0u8; oversize] });
139+
let res = construct_and_apply_extrinsic(alice_pair, too_big_call);
140+
assert_eq!(
141+
res,
142+
Err(BAD_DATA_SIZE.into())
143+
);
144+
129145
});
130146
}
131147

0 commit comments

Comments
 (0)