pallet-referenda: Detect incorrect pre-image length (#3850)

There has been a case that a referenda failed because the length given
to `submit` was incorrect. The pallet can actually check the length if
the pre-image already exists to ensure that these kind of issues are not
happening again.
This commit is contained in:
Bastian Köcher
2024-03-27 23:52:50 +00:00
committed by GitHub
parent 597ea9203a
commit 5d314eb03e
3 changed files with 43 additions and 0 deletions
+16
View File
@@ -666,3 +666,19 @@ fn clear_metadata_works() {
}));
});
}
#[test]
fn detects_incorrect_len() {
ExtBuilder::default().build_and_execute(|| {
let hash = note_preimage(1);
assert_noop!(
Referenda::submit(
RuntimeOrigin::signed(1),
Box::new(RawOrigin::Root.into()),
frame_support::traits::Bounded::Lookup { hash, len: 3 },
DispatchTime::At(1),
),
Error::<Test>::PreimageStoredWithDifferentLength
);
});
}