From d12bf8968c19634494319a06a199b74f51568c07 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 25 Jan 2017 17:02:55 +0100 Subject: [PATCH] don't display local var if stack is too low --- src/solidity/localDecoder.js | 4 +--- test/solidity/localsTests/misc.js | 18 +----------------- test/solidity/localsTests/misc2.js | 2 +- test/solidity/localsTests/structArray.js | 2 +- 4 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/solidity/localDecoder.js b/src/solidity/localDecoder.js index 18b4b304e4..c2e76a6d12 100644 --- a/src/solidity/localDecoder.js +++ b/src/solidity/localDecoder.js @@ -10,10 +10,8 @@ function solidityLocals (vmtraceIndex, internalTreeCall, stack, memory) { memory = formatMemory(memory) for (var local in scope.locals) { let variable = scope.locals[local] - if (variable.type.decodeFromStack) { + if (variable.stackDepth < stack.length) { locals[variable.name] = variable.type.decodeFromStack(variable.stackDepth, stack, memory) - } else { - locals[variable.name] = '' } } return locals diff --git a/test/solidity/localsTests/misc.js b/test/solidity/localsTests/misc.js index 6b082c314f..329cbffd5b 100644 --- a/test/solidity/localsTests/misc.js +++ b/test/solidity/localsTests/misc.js @@ -56,23 +56,7 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu helper.decodeLocals(st, 7, traceManager, callTree, function (locals) { try { - st.equals(locals['boolFalse'].value, false) - st.equals(locals['boolTrue'].value, false) - st.equals(locals['testEnum'].value, 'one') - st.equals(locals['sender'].value, '0x0000000000000000000000000000000000000000') - st.equals(locals['_bytes1'].value, '0x') - st.equals(locals['__bytes1'].value, '0x') - st.equals(locals['__bytes2'].value, '0x') - st.equals(locals['__bytes4'].value, '0x') - st.equals(locals['__bytes6'].value, '0x') - st.equals(locals['__bytes7'].value, '0x') - st.equals(locals['__bytes8'].value, '0x') - st.equals(locals['__bytes9'].value, '0x') - st.equals(locals['__bytes13'].value, '0x') - st.equals(locals['__bytes16'].value, '0x') - st.equals(locals['__bytes24'].value, '0x') - st.equals(locals['__bytes32'].value, '0x') - st.equals(Object.keys(locals).length, 16) + st.equals(Object.keys(locals).length, 0) } catch (e) { st.fail(e.message) } diff --git a/test/solidity/localsTests/misc2.js b/test/solidity/localsTests/misc2.js index 20e8d7de77..4dd4e0f169 100644 --- a/test/solidity/localsTests/misc2.js +++ b/test/solidity/localsTests/misc2.js @@ -42,7 +42,7 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu helper.decodeLocals(st, 7, traceManager, callTree, function (locals) { try { - st.equals(Object.keys(locals).length, 2) + st.equals(Object.keys(locals).length, 0) } catch (e) { st.fail(e.message) } diff --git a/test/solidity/localsTests/structArray.js b/test/solidity/localsTests/structArray.js index 90b1d6534a..6b7ecfad53 100644 --- a/test/solidity/localsTests/structArray.js +++ b/test/solidity/localsTests/structArray.js @@ -100,7 +100,7 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu helper.decodeLocals(st, 7, traceManager, callTree, function (locals) { try { - st.equals(Object.keys(locals).length, 8) + st.equals(Object.keys(locals).length, 0) } catch (e) { st.fail(e.message) }