Skip to content

Commit

Permalink
Remove module_from_bytes helper
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Sep 19, 2019
1 parent 0e94948 commit 8af28d3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
2 changes: 1 addition & 1 deletion chisel/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ fn execute_module(context: &ModuleContext, module: &mut Module) -> bool {

fn chisel_execute(context: &ChiselContext) -> Result<bool, &'static str> {
if let Ok(buffer) = read(context.file()) {
if let Ok(module) = module_from_bytes(&buffer) {
if let Ok(module) = Module::from_bytes(&buffer) {
// If we do not parse the NamesSection here, parity-wasm will drop it at serialisation
// It is useful to have this for a number of optimisation passes, including binaryenopt and snip
// TODO: better error handling
Expand Down
18 changes: 0 additions & 18 deletions libchisel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ pub mod verifyimports;

mod depgraph;

// This helper is exported here for users of this library not needing to import parity_wasm.
pub fn module_from_bytes<T: AsRef<[u8]>>(input: T) -> Result<Module, ModuleError> {
Ok(Module::from_bytes(input)?)
}

#[derive(Eq, PartialEq, Debug)]
pub enum ModuleKind {
Creator,
Expand Down Expand Up @@ -250,17 +245,4 @@ mod tests {
let result = as_trait.validate(&Module::default());
assert!(result.is_ok());
}

#[test]
fn loading_from_bytes() {
let module_orig = Module::default();

let output = module_orig.clone().to_bytes().unwrap();
let module = module_from_bytes(&output).unwrap();
assert_eq!(module_orig, module);

let output = module_orig.clone().to_bytes().unwrap();
let module = Module::from_bytes(&output).unwrap();
assert_eq!(module_orig, module);
}
}

0 comments on commit 8af28d3

Please sign in to comment.