From e234b7fdbf2c9ab30044073579fd1bd8488f51b6 Mon Sep 17 00:00:00 2001 From: fro Date: Fri, 28 Jul 2017 16:38:03 +0300 Subject: [PATCH 1/2] realloc test added --- ethcore/evm/src/wasm/env.rs | 37 ++++++++++++++++++++++++++++++++++- ethcore/evm/src/wasm/tests.rs | 24 +++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/ethcore/evm/src/wasm/env.rs b/ethcore/evm/src/wasm/env.rs index cabd38bd9..00770bb4a 100644 --- a/ethcore/evm/src/wasm/env.rs +++ b/ethcore/evm/src/wasm/env.rs @@ -115,5 +115,40 @@ pub const SIGNATURES: &'static [UserFunctionDescriptor] = &[ "_emscripten_memcpy_big", &[I32; 3], Some(I32), - ) + ), + Static( + "___syscall140", + &[I32; 2], + Some(I32) + ), + Static( + "___syscall146", + &[I32; 2], + Some(I32) + ), + Static( + "___syscall54", + &[I32; 2], + Some(I32) + ), + Static( + "___syscall6", + &[I32; 2], + Some(I32) + ), + Static( + "_llvm_trap", + &[I32; 0], + None + ), + Static( + "abortOnCannotGrowMemory", + &[I32; 0], + Some(I32) + ), + Static( + "___setErrNo", + &[I32; 1], + None + ), ]; diff --git a/ethcore/evm/src/wasm/tests.rs b/ethcore/evm/src/wasm/tests.rs index 8ae13daae..8c2ec0b3f 100644 --- a/ethcore/evm/src/wasm/tests.rs +++ b/ethcore/evm/src/wasm/tests.rs @@ -272,3 +272,27 @@ fn create() { )); assert_eq!(gas_left, U256::from(99_768)); } + +// Realloc test +#[test] +fn realloc() { + let code = load_sample!("realloc.wasm"); + + let mut params = ActionParams::default(); + params.gas = U256::from(100_000); + params.code = Some(Arc::new(code)); + params.data = Some(vec![0u8]); + let mut ext = FakeExt::new(); + + let (gas_left, result) = { + let mut interpreter = wasm_interpreter(); + let result = interpreter.exec(params, &mut ext).expect("Interpreter to execute without any errors"); + match result { + GasLeft::Known(_) => { panic!("Realloc should return payload"); }, + GasLeft::NeedsReturn { gas_left: gas, data: result, apply_state: _apply } => (gas, result.to_vec()), + } + }; + assert_eq!(gas_left, U256::from(98326)); + assert_eq!(result, vec![0u8; 2]); + +} From fe6bdc870c150a708253a2338d29e8605c1514be Mon Sep 17 00:00:00 2001 From: fro Date: Mon, 31 Jul 2017 16:54:26 +0300 Subject: [PATCH 2/2] realloc test contract submodule update --- ethcore/res/wasm-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethcore/res/wasm-tests b/ethcore/res/wasm-tests index 9ed630431..04c9d84c5 160000 --- a/ethcore/res/wasm-tests +++ b/ethcore/res/wasm-tests @@ -1 +1 @@ -Subproject commit 9ed6304313fa949ed92aa0570fb2bc759fb6dc58 +Subproject commit 04c9d84c5fe5c3ad707be58664c7e72b97cc9996