mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 01:11:04 +00:00
Introduce ModuleError struct (#10776)
* better partial eq impl * introduce module error * fmt * import module error * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * fixes * fmt Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -255,7 +255,7 @@ use sp_runtime::{
|
||||
InvalidTransaction, TransactionPriority, TransactionSource, TransactionValidity,
|
||||
TransactionValidityError, ValidTransaction,
|
||||
},
|
||||
DispatchError, PerThing, Perbill, RuntimeDebug, SaturatedConversion,
|
||||
DispatchError, ModuleError, PerThing, Perbill, RuntimeDebug, SaturatedConversion,
|
||||
};
|
||||
use sp_std::prelude::*;
|
||||
|
||||
@@ -1579,7 +1579,7 @@ impl<T: Config> ElectionProvider for Pallet<T> {
|
||||
/// number.
|
||||
pub fn dispatch_error_to_invalid(error: DispatchError) -> InvalidTransaction {
|
||||
let error_number = match error {
|
||||
DispatchError::Module { error, .. } => error,
|
||||
DispatchError::Module(ModuleError { error, .. }) => error,
|
||||
_ => 0,
|
||||
};
|
||||
InvalidTransaction::Custom(error_number)
|
||||
|
||||
@@ -752,7 +752,7 @@ mod tests {
|
||||
use sp_runtime::{
|
||||
offchain::storage_lock::{BlockAndTime, StorageLock},
|
||||
traits::ValidateUnsigned,
|
||||
PerU16,
|
||||
ModuleError, PerU16,
|
||||
};
|
||||
|
||||
type Assignment = crate::unsigned::Assignment<Runtime>;
|
||||
@@ -922,8 +922,8 @@ mod tests {
|
||||
#[test]
|
||||
#[should_panic(expected = "Invalid unsigned submission must produce invalid block and \
|
||||
deprive validator from their authoring reward.: \
|
||||
Module { index: 2, error: 1, message: \
|
||||
Some(\"PreDispatchWrongWinnerCount\") }")]
|
||||
Module(ModuleError { index: 2, error: 1, message: \
|
||||
Some(\"PreDispatchWrongWinnerCount\") })")]
|
||||
fn unfeasible_solution_panics() {
|
||||
ExtBuilder::default().build_and_execute(|| {
|
||||
roll_to(25);
|
||||
@@ -1033,11 +1033,11 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
MultiPhase::mine_check_save_submit().unwrap_err(),
|
||||
MinerError::PreDispatchChecksFailed(DispatchError::Module {
|
||||
MinerError::PreDispatchChecksFailed(DispatchError::Module(ModuleError {
|
||||
index: 2,
|
||||
error: 1,
|
||||
message: Some("PreDispatchWrongWinnerCount"),
|
||||
}),
|
||||
})),
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user