mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-25 17:37:56 +00:00
Improve Dispatch Errors (#878)
* better dispatch errors * dry_run to use same DispatchError * fix dry_run_fails; use correct transfer amount * Hide ModuleError impl and avoid pulling details from metadata unless user needs them * fix tests * actually fix the tests (hopefully..) * Add a couple more DispatchError test cases * Add a comment about where the error was copied from * Also expose a way to obtain the raw module error data * Remove redundant variant prefixes * explicit lifetime on From<str> for clarity * fmt
This commit is contained in:
@@ -68,8 +68,9 @@ async fn validate_not_possible_for_stash_account() -> Result<(), Error> {
|
||||
.wait_for_finalized_success()
|
||||
.await;
|
||||
assert_matches!(announce_validator, Err(Error::Runtime(DispatchError::Module(err))) => {
|
||||
assert_eq!(err.pallet, "Staking");
|
||||
assert_eq!(err.error, "NotController");
|
||||
let details = err.details().unwrap();
|
||||
assert_eq!(details.pallet(), "Staking");
|
||||
assert_eq!(details.error(), "NotController");
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
@@ -116,8 +117,9 @@ async fn nominate_not_possible_for_stash_account() -> Result<(), Error> {
|
||||
.await;
|
||||
|
||||
assert_matches!(nomination, Err(Error::Runtime(DispatchError::Module(err))) => {
|
||||
assert_eq!(err.pallet, "Staking");
|
||||
assert_eq!(err.error, "NotController");
|
||||
let details = err.details().unwrap();
|
||||
assert_eq!(details.pallet(), "Staking");
|
||||
assert_eq!(details.error(), "NotController");
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
@@ -161,8 +163,9 @@ async fn chill_works_for_controller_only() -> Result<(), Error> {
|
||||
.await;
|
||||
|
||||
assert_matches!(chill, Err(Error::Runtime(DispatchError::Module(err))) => {
|
||||
assert_eq!(err.pallet, "Staking");
|
||||
assert_eq!(err.error, "NotController");
|
||||
let details = err.details().unwrap();
|
||||
assert_eq!(details.pallet(), "Staking");
|
||||
assert_eq!(details.error(), "NotController");
|
||||
});
|
||||
|
||||
let is_chilled = api
|
||||
@@ -207,8 +210,9 @@ async fn tx_bond() -> Result<(), Error> {
|
||||
.await;
|
||||
|
||||
assert_matches!(bond_again, Err(Error::Runtime(DispatchError::Module(err))) => {
|
||||
assert_eq!(err.pallet, "Staking");
|
||||
assert_eq!(err.error, "AlreadyBonded");
|
||||
let details = err.details().unwrap();
|
||||
assert_eq!(details.pallet(), "Staking");
|
||||
assert_eq!(details.error(), "AlreadyBonded");
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user