Better error for when origin filter prevent the call to be dispatched (#10134)

* better error

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* remove unused

* fix error

* fmt

* fix tests

* fmt

* Update frame/contracts/src/exec.rs

Co-authored-by: Alexander Theißen <alex.theissen@me.com>

* fix typo

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
This commit is contained in:
Guillaume Thiolliere
2021-11-02 15:20:00 +01:00
committed by GitHub
parent 977cf450b3
commit 20c9afcdc1
9 changed files with 67 additions and 37 deletions
+6 -6
View File
@@ -1094,10 +1094,7 @@ mod tests {
use pallet_contracts_primitives::ReturnFlags;
use pretty_assertions::assert_eq;
use sp_core::Bytes;
use sp_runtime::{
traits::{BadOrigin, Hash},
DispatchError,
};
use sp_runtime::{traits::Hash, DispatchError};
use std::{cell::RefCell, collections::HashMap, rc::Rc};
type System = frame_system::Pallet<Test>;
@@ -2114,7 +2111,10 @@ mod tests {
let forbidden_call = Call::Balances(BalanceCall::transfer { dest: CHARLIE, value: 22 });
// simple cases: direct call
assert_err!(ctx.ext.call_runtime(forbidden_call.clone()), BadOrigin);
assert_err!(
ctx.ext.call_runtime(forbidden_call.clone()),
frame_system::Error::<Test>::CallFiltered
);
// as part of a patch: return is OK (but it interrupted the batch)
assert_ok!(ctx.ext.call_runtime(Call::Utility(UtilCall::batch {
@@ -2159,7 +2159,7 @@ mod tests {
phase: Phase::Initialization,
event: MetaEvent::Utility(pallet_utility::Event::BatchInterrupted(
1,
BadOrigin.into()
frame_system::Error::<Test>::CallFiltered.into()
),),
topics: vec![],
},