Fix error handling in sandboxing/contracts modules (#744)

* Fix error handling in sandboxing/contracts modules

* Add some docs.

* Add some tests.

* grammar
This commit is contained in:
Sergey Pepyakin
2018-09-19 11:01:25 +03:00
committed by Gav Wood
parent 400a22ebe5
commit 488830e81a
7 changed files with 154 additions and 21 deletions
+10
View File
@@ -81,6 +81,16 @@ impl_stubs!(
);
let ok = if let Ok(sandbox::ReturnValue::Value(sandbox::TypedValue::I32(0x1337))) = result { true } else { false };
[ok as u8].to_vec()
},
test_sandbox_instantiate NO_DECODE => |code: &[u8]| {
let env_builder = sandbox::EnvironmentDefinitionBuilder::new();
let code = match sandbox::Instance::new(code, &env_builder, &mut ()) {
Ok(_) => 0,
Err(sandbox::Error::Module) => 1,
Err(sandbox::Error::Execution) => 2,
Err(sandbox::Error::OutOfBounds) => 3,
};
[code].to_vec()
}
);