mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 20:21:03 +00:00
Change assert(is_err()) to assert_noop to check state consistency on errors (#8587)
* Change is_err() asserts in tests to assert_noop to check state consistency fixes #8545 * Update frame/transaction-payment/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update frame/contracts/src/exec.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * Update frame/democracy/src/benchmarking.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * Update frame/transaction-payment/src/lib.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * Don't assert no-changing state. see: https://github.com/paritytech/substrate/pull/8587#issuecomment-817137906 * fix expected error * Fix non-extrinsic-call asserts Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
committed by
GitHub
parent
b9ed6e01b3
commit
24311eee3e
@@ -21,8 +21,9 @@ use super::*;
|
||||
|
||||
use frame_benchmarking::{benchmarks, account, whitelist_account, impl_benchmark_test_suite};
|
||||
use frame_support::{
|
||||
IterableStorageMap,
|
||||
traits::{Currency, Get, EnsureOrigin, OnInitialize, UnfilteredDispatchable, schedule::DispatchTime},
|
||||
assert_noop, assert_ok, IterableStorageMap,
|
||||
traits::{Currency, Get, EnsureOrigin, OnInitialize, UnfilteredDispatchable,
|
||||
schedule::DispatchTime},
|
||||
};
|
||||
use frame_system::{RawOrigin, Pallet as System, self, EventRecord};
|
||||
use sp_runtime::traits::{Bounded, One};
|
||||
@@ -206,11 +207,14 @@ benchmarks! {
|
||||
let origin = T::CancellationOrigin::successful_origin();
|
||||
let referendum_index = add_referendum::<T>(0)?;
|
||||
let call = Call::<T>::emergency_cancel(referendum_index);
|
||||
assert!(Democracy::<T>::referendum_status(referendum_index).is_ok());
|
||||
assert_ok!(Democracy::<T>::referendum_status(referendum_index));
|
||||
}: { call.dispatch_bypass_filter(origin)? }
|
||||
verify {
|
||||
// Referendum has been canceled
|
||||
assert!(Democracy::<T>::referendum_status(referendum_index).is_err());
|
||||
assert_noop!(
|
||||
Democracy::<T>::referendum_status(referendum_index),
|
||||
Error::<T>::ReferendumInvalid,
|
||||
);
|
||||
}
|
||||
|
||||
blacklist {
|
||||
@@ -224,18 +228,23 @@ benchmarks! {
|
||||
|
||||
// Place our proposal in the external queue, too.
|
||||
let hash = T::Hashing::hash_of(&0);
|
||||
assert!(Democracy::<T>::external_propose(T::ExternalOrigin::successful_origin(), hash.clone()).is_ok());
|
||||
assert_ok!(
|
||||
Democracy::<T>::external_propose(T::ExternalOrigin::successful_origin(), hash.clone())
|
||||
);
|
||||
|
||||
// Add a referendum of our proposal.
|
||||
let referendum_index = add_referendum::<T>(0)?;
|
||||
assert!(Democracy::<T>::referendum_status(referendum_index).is_ok());
|
||||
assert_ok!(Democracy::<T>::referendum_status(referendum_index));
|
||||
|
||||
let call = Call::<T>::blacklist(hash, Some(referendum_index));
|
||||
let origin = T::BlacklistOrigin::successful_origin();
|
||||
}: { call.dispatch_bypass_filter(origin)? }
|
||||
verify {
|
||||
// Referendum has been canceled
|
||||
assert!(Democracy::<T>::referendum_status(referendum_index).is_err());
|
||||
assert_noop!(
|
||||
Democracy::<T>::referendum_status(referendum_index),
|
||||
Error::<T>::ReferendumInvalid
|
||||
);
|
||||
}
|
||||
|
||||
// Worst case scenario, we external propose a previously blacklisted proposal
|
||||
|
||||
Reference in New Issue
Block a user