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)
} 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

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

@ -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')
}
})
}

Loading…
Cancel
Save