pull/7/head
yann300 8 years ago
parent 85de091767
commit 3a921e35df
  1. 6
      src/solidity/localDecoder.js
  2. 2
      test/solidity/contracts/intLocal.js
  3. 19
      test/solidity/localDecoder.js

@ -33,11 +33,11 @@ LocalDecoder.prototype.push = function (index, step, callStack, cache) {
console.log(error) console.log(error)
} else { } else {
var file = self.parent.sourceList[result.file] var file = self.parent.sourceList[result.file]
var ast = self.parent.sources[file] var ast = self.parent.sources[file].AST
this.astWalker.walk(ast, function (node) { self.astWalker.walk(ast, function (node) {
if (node.name === 'VariableDeclaration' && node.src.indexOf(result.start + ':' + result.length) === 0) { if (node.name === 'VariableDeclaration' && node.src.indexOf(result.start + ':' + result.length) === 0) {
self.locals[node.attributes.name] = { self.locals[node.attributes.name] = {
type: decodeInfo.parseType(node, []), type: decodeInfo.parseType(node.attributes.type, []),
stack: step.stack stack: step.stack
} }
return false return false

@ -3,7 +3,7 @@
module.exports = { module.exports = {
contract: ` contract: `
contract intLocal { contract intLocal {
function set () { function intLocal () {
uint8 ui8 = 130; uint8 ui8 = 130;
uint16 ui16 = 456; uint16 ui16 = 456;
uint32 ui32 = 4356; uint32 ui32 = 4356;

@ -32,12 +32,27 @@ tape('solidity', function (t) {
tx.to = traceHelper.contractCreationToken('0') tx.to = traceHelper.contractCreationToken('0')
var traceManager = new TraceManager() var traceManager = new TraceManager()
var codeManager = new CodeManager(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) { traceManager.resolveTrace(tx, function (error, result) {
if (error) { if (error) {
st.fail(error) st.fail(error)
} else { } 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')
} }
}) })
} }

Loading…
Cancel
Save