Public extrinsic apply doesn't panic (#178)

* Merge remote-tracking branch 'origin/master' into gav-xts-dont-panic

* Update wasm.

* consensus, session and staking all panic-safe.

* Democracy doesn't panic in apply.

* Fix tests.

* Extra helper macro, council depanicked.

* Fix one test.

* Fix up all council tests. No panics!

* Council voting depanicked.

* utilise hygene
This commit is contained in:
Gav Wood
2018-05-31 22:11:09 +02:00
committed by GitHub
parent 32d85fbecf
commit 44eaa4a180
23 changed files with 331 additions and 227 deletions
@@ -44,3 +44,62 @@ mod hashable;
pub use self::storage::{StorageVec, StorageList, StorageValue, StorageMap};
pub use self::hashable::Hashable;
pub use self::dispatch::{Parameter, Dispatchable, Callable, AuxDispatchable, AuxCallable, IsSubType, IsAuxSubType};
pub use runtime_io::print;
#[macro_export]
macro_rules! fail {
( $y:expr ) => {{
$crate::print($y);
return;
}}
}
#[macro_export]
macro_rules! ensure {
( $x:expr, $y:expr ) => {{
if !$x {
fail!($y);
}
}};
($x:expr) => {{
if !$x {
$crate::print("Bailing! Cannot ensure: ");
$crate::print(stringify!($x));
return;
}
}}
}
#[macro_export]
macro_rules! ensure_unwrap {
($x:expr, $y: expr) => {
if let Some(v) = $x {
v
} else {
fail!{$y}
}
}
}
#[macro_export]
macro_rules! ensure_unwrap_err {
($x:expr, $y: expr) => {
if let Err(v) = $x {
v
} else {
fail!{$y}
}
}
}
#[macro_export]
#[cfg(feature = "std")]
macro_rules! assert_noop {
( $( $x:tt )* ) => {
let h = runtime_io::storage_root();
{
$( $x )*
}
assert_eq!(h, runtime_io::storage_root());
}
}