mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 03:27:58 +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
@@ -120,6 +120,7 @@ impl<T: Config> SignedExtension for CheckNonce<T> where
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::mock::{Test, new_test_ext, CALL};
|
||||
use frame_support::{assert_noop, assert_ok};
|
||||
|
||||
#[test]
|
||||
fn signed_ext_check_nonce_works() {
|
||||
@@ -134,14 +135,23 @@ mod tests {
|
||||
let info = DispatchInfo::default();
|
||||
let len = 0_usize;
|
||||
// stale
|
||||
assert!(CheckNonce::<Test>(0).validate(&1, CALL, &info, len).is_err());
|
||||
assert!(CheckNonce::<Test>(0).pre_dispatch(&1, CALL, &info, len).is_err());
|
||||
assert_noop!(
|
||||
CheckNonce::<Test>(0).validate(&1, CALL, &info, len),
|
||||
InvalidTransaction::Stale
|
||||
);
|
||||
assert_noop!(
|
||||
CheckNonce::<Test>(0).pre_dispatch(&1, CALL, &info, len),
|
||||
InvalidTransaction::Stale
|
||||
);
|
||||
// correct
|
||||
assert!(CheckNonce::<Test>(1).validate(&1, CALL, &info, len).is_ok());
|
||||
assert!(CheckNonce::<Test>(1).pre_dispatch(&1, CALL, &info, len).is_ok());
|
||||
assert_ok!(CheckNonce::<Test>(1).validate(&1, CALL, &info, len));
|
||||
assert_ok!(CheckNonce::<Test>(1).pre_dispatch(&1, CALL, &info, len));
|
||||
// future
|
||||
assert!(CheckNonce::<Test>(5).validate(&1, CALL, &info, len).is_ok());
|
||||
assert!(CheckNonce::<Test>(5).pre_dispatch(&1, CALL, &info, len).is_err());
|
||||
assert_ok!(CheckNonce::<Test>(5).validate(&1, CALL, &info, len));
|
||||
assert_noop!(
|
||||
CheckNonce::<Test>(5).pre_dispatch(&1, CALL, &info, len),
|
||||
InvalidTransaction::Future
|
||||
);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user