Refund referendum submission deposit (#12788)

* optinal submission deposit and migration

* refund submission deposit call, test, bench

* try runtime fixes

* assert for bench

* Only refund cancelled/approved referenda deposits

* update storage version

Co-authored-by: Gav <gavin@parity.io>
This commit is contained in:
Muharem Ismailov
2022-12-07 13:20:48 +01:00
committed by GitHub
parent 1657feae3b
commit 198faaa6f9
8 changed files with 593 additions and 241 deletions
@@ -264,6 +264,19 @@ benchmarks_instance_pallet! {
assert_matches!(ReferendumInfoFor::<T, I>::get(index), Some(ReferendumInfo::Cancelled(_, _, None)));
}
refund_submission_deposit {
let (origin, index) = create_referendum::<T, I>();
let caller = frame_system::ensure_signed(origin.clone()).unwrap();
let balance = T::Currency::free_balance(&caller);
assert_ok!(Referenda::<T, I>::cancel(T::CancelOrigin::successful_origin(), index));
assert_matches!(ReferendumInfoFor::<T, I>::get(index), Some(ReferendumInfo::Cancelled(_, Some(_), _)));
}: _<T::RuntimeOrigin>(origin, index)
verify {
assert_matches!(ReferendumInfoFor::<T, I>::get(index), Some(ReferendumInfo::Cancelled(_, None, _)));
let new_balance = T::Currency::free_balance(&caller);
assert!(new_balance > balance);
}
cancel {
let (_origin, index) = create_referendum::<T, I>();
place_deposit::<T, I>(index);