From 3a921e35df20d7d9f3046e5604274ad88410b1b6 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 6 Dec 2016 13:37:29 +0100 Subject: [PATCH] fix tests --- src/solidity/localDecoder.js | 6 +++--- test/solidity/contracts/intLocal.js | 2 +- test/solidity/localDecoder.js | 19 +++++++++++++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/solidity/localDecoder.js b/src/solidity/localDecoder.js index 5322b7bfac..649f103e91 100644 --- a/src/solidity/localDecoder.js +++ b/src/solidity/localDecoder.js @@ -33,11 +33,11 @@ LocalDecoder.prototype.push = function (index, step, callStack, cache) { console.log(error) } else { var file = self.parent.sourceList[result.file] - var ast = self.parent.sources[file] - this.astWalker.walk(ast, function (node) { + var ast = self.parent.sources[file].AST + self.astWalker.walk(ast, function (node) { if (node.name === 'VariableDeclaration' && node.src.indexOf(result.start + ':' + result.length) === 0) { self.locals[node.attributes.name] = { - type: decodeInfo.parseType(node, []), + type: decodeInfo.parseType(node.attributes.type, []), stack: step.stack } return false diff --git a/test/solidity/contracts/intLocal.js b/test/solidity/contracts/intLocal.js index 53f0957752..9860b7d3ac 100644 --- a/test/solidity/contracts/intLocal.js +++ b/test/solidity/contracts/intLocal.js @@ -3,7 +3,7 @@ module.exports = { contract: ` contract intLocal { - function set () { + function intLocal () { uint8 ui8 = 130; uint16 ui16 = 456; uint32 ui32 = 4356; diff --git a/test/solidity/localDecoder.js b/test/solidity/localDecoder.js index e0f1edad68..8663f173f4 100644 --- a/test/solidity/localDecoder.js +++ b/test/solidity/localDecoder.js @@ -32,12 +32,27 @@ tape('solidity', function (t) { tx.to = traceHelper.contractCreationToken('0') var traceManager = new TraceManager() var codeManager = new CodeManager(traceManager) - var locals = new LocalDecoder(output, codeManager, traceManager.traceAnalyser.event) + var localDecoder = new LocalDecoder(output, codeManager, traceManager.traceAnalyser.event) traceManager.resolveTrace(tx, function (error, result) { if (error) { st.fail(error) } else { - console.log(locals) + var locals = localDecoder.locals + st.equals(locals['ui8'].type.typeName, 'uint') + st.equals(locals['ui16'].type.typeName, 'uint') + st.equals(locals['ui32'].type.typeName, 'uint') + st.equals(locals['ui64'].type.typeName, 'uint') + st.equals(locals['ui128'].type.typeName, 'uint') + st.equals(locals['ui256'].type.typeName, 'uint') + st.equals(locals['ui'].type.typeName, 'uint') + st.equals(locals['i8'].type.typeName, 'int') + st.equals(locals['i16'].type.typeName, 'int') + st.equals(locals['i32'].type.typeName, 'int') + st.equals(locals['i64'].type.typeName, 'int') + st.equals(locals['i128'].type.typeName, 'int') + st.equals(locals['i256'].type.typeName, 'int') + st.equals(locals['i'].type.typeName, 'int') + st.equals(locals['ishrink'].type.typeName, 'int') } }) }