Commit c519a35d authored by yann300's avatar yann300

return typename together with the value

parent 0de74536
...@@ -52,7 +52,8 @@ class ArrayType extends RefType { ...@@ -52,7 +52,8 @@ class ArrayType extends RefType {
} }
return { return {
value: ret, value: ret,
length: '0x' + size.toString(16) length: '0x' + size.toString(16),
type: this.typeName
} }
} }
...@@ -69,7 +70,11 @@ class ArrayType extends RefType { ...@@ -69,7 +70,11 @@ class ArrayType extends RefType {
ret.push(this.underlyingType.decodeFromMemory(contentOffset, memory)) ret.push(this.underlyingType.decodeFromMemory(contentOffset, memory))
offset += 32 offset += 32
} }
return ret return {
value: ret,
length: '0x' + length.toString(16),
type: this.typeName
}
} }
} }
......
...@@ -30,7 +30,8 @@ class DynamicByteArray extends RefType { ...@@ -30,7 +30,8 @@ class DynamicByteArray extends RefType {
var size = parseInt(value.substr(value.length - 2, 2), 16) / 2 var size = parseInt(value.substr(value.length - 2, 2), 16) / 2
return { return {
value: '0x' + value.substr(0, size * 2), value: '0x' + value.substr(0, size * 2),
length: '0x' + size.toString(16) length: '0x' + size.toString(16),
type: this.typeName
} }
} }
} }
...@@ -41,7 +42,8 @@ class DynamicByteArray extends RefType { ...@@ -41,7 +42,8 @@ class DynamicByteArray extends RefType {
length = 2 * parseInt(length, 16) length = 2 * parseInt(length, 16)
return { return {
length: '0x' + length.toString(16), length: '0x' + length.toString(16),
value: '0x' + memory.substr(offset + 64, length) value: '0x' + memory.substr(offset + 64, length),
type: this.typeName
} }
} }
} }
......
...@@ -17,7 +17,10 @@ class Struct extends RefType { ...@@ -17,7 +17,10 @@ class Struct extends RefType {
} }
ret[item.name] = item.type.decodeFromStorage(globalLocation, storageContent) ret[item.name] = item.type.decodeFromStorage(globalLocation, storageContent)
}) })
return ret return {
value: ret,
type: this.typeName
}
} }
decodeFromMemoryInternal (offset, memory) { decodeFromMemoryInternal (offset, memory) {
...@@ -28,7 +31,10 @@ class Struct extends RefType { ...@@ -28,7 +31,10 @@ class Struct extends RefType {
ret[item.name] = member ret[item.name] = member
offset += 32 offset += 32
}) })
return ret return {
value: ret,
type: this.typeName
}
} }
} }
......
...@@ -18,7 +18,10 @@ class ValueType { ...@@ -18,7 +18,10 @@ class ValueType {
*/ */
decodeFromStorage (location, storageContent) { decodeFromStorage (location, storageContent) {
var value = util.extractHexValue(location, storageContent, this.storageBytes) var value = util.extractHexValue(location, storageContent, this.storageBytes)
return this.decodeValue(value) return {
value: this.decodeValue(value),
type: this.typeName
}
} }
/** /**
...@@ -30,10 +33,15 @@ class ValueType { ...@@ -30,10 +33,15 @@ class ValueType {
* @return {Object} - decoded value * @return {Object} - decoded value
*/ */
decodeFromStack (stackDepth, stack, memory) { decodeFromStack (stackDepth, stack, memory) {
var value
if (stackDepth >= stack.length) { if (stackDepth >= stack.length) {
return this.decodeValue('') value = this.decodeValue('')
} else { } else {
return this.decodeValue(stack[stack.length - 1 - stackDepth].replace('0x', '')) value = this.decodeValue(stack[stack.length - 1 - stackDepth].replace('0x', ''))
}
return {
value: value,
type: this.typeName
} }
} }
...@@ -46,7 +54,10 @@ class ValueType { ...@@ -46,7 +54,10 @@ class ValueType {
*/ */
decodeFromMemory (offset, memory) { decodeFromMemory (offset, memory) {
var value = memory.substr(2 * offset, 64) var value = memory.substr(2 * offset, 64)
return this.decodeValue(util.extractHexByteSlice(value, this.storageBytes, 0)) return {
value: this.decodeValue(util.extractHexByteSlice(value, this.storageBytes, 0)),
type: this.typeName
}
} }
} }
......
...@@ -63,26 +63,26 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu ...@@ -63,26 +63,26 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
helper.decodeLocals(st, 125, traceManager, callTree, function (locals) { helper.decodeLocals(st, 125, traceManager, callTree, function (locals) {
st.equals(Object.keys(locals).length, 16) st.equals(Object.keys(locals).length, 16)
st.equals(locals['ui8'], '130') st.equals(locals['ui8'].value, '130')
st.equals(locals['ui16'], '456') st.equals(locals['ui16'].value, '456')
st.equals(locals['ui32'], '4356') st.equals(locals['ui32'].value, '4356')
st.equals(locals['ui64'], '3543543543') st.equals(locals['ui64'].value, '3543543543')
st.equals(locals['ui128'], '234567') st.equals(locals['ui128'].value, '234567')
st.equals(locals['ui256'], '115792089237316195423570985008687907853269984665640564039457584007880697216513') st.equals(locals['ui256'].value, '115792089237316195423570985008687907853269984665640564039457584007880697216513')
st.equals(locals['ui'], '123545666') st.equals(locals['ui'].value, '123545666')
st.equals(locals['i8'], '-45') st.equals(locals['i8'].value, '-45')
st.equals(locals['i16'], '-1234') st.equals(locals['i16'].value, '-1234')
st.equals(locals['i32'], '3455') st.equals(locals['i32'].value, '3455')
st.equals(locals['i64'], '-35566') st.equals(locals['i64'].value, '-35566')
st.equals(locals['i128'], '-444444') st.equals(locals['i128'].value, '-444444')
st.equals(locals['i256'], '3434343') st.equals(locals['i256'].value, '3434343')
st.equals(locals['i'], '-32432423423') st.equals(locals['i'].value, '-32432423423')
st.equals(locals['ishrink'], '2') st.equals(locals['ishrink'].value, '2')
}) })
helper.decodeLocals(st, 177, traceManager, callTree, function (locals) { helper.decodeLocals(st, 177, traceManager, callTree, function (locals) {
try { try {
st.equals(locals['ui8'], '123') st.equals(locals['ui8'].value, '123')
st.equals(Object.keys(locals).length, 1) st.equals(Object.keys(locals).length, 1)
} catch (e) { } catch (e) {
st.fail(e.message) st.fail(e.message)
......
...@@ -32,22 +32,22 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu ...@@ -32,22 +32,22 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
callTree.event.register('callTreeReady', (scopes, scopeStarts) => { callTree.event.register('callTreeReady', (scopes, scopeStarts) => {
helper.decodeLocals(st, 70, traceManager, callTree, function (locals) { helper.decodeLocals(st, 70, traceManager, callTree, function (locals) {
try { try {
st.equals(locals['boolFalse'], false) st.equals(locals['boolFalse'].value, false)
st.equals(locals['boolTrue'], true) st.equals(locals['boolTrue'].value, true)
st.equals(locals['testEnum'], 'three') st.equals(locals['testEnum'].value, 'three')
st.equals(locals['sender'], '0x4B0897B0513FDC7C541B6D9D7E929C4E5364D2DB') st.equals(locals['sender'].value, '0x4B0897B0513FDC7C541B6D9D7E929C4E5364D2DB')
st.equals(locals['_bytes1'], '0x99') st.equals(locals['_bytes1'].value, '0x99')
st.equals(locals['__bytes1'], '0x99') st.equals(locals['__bytes1'].value, '0x99')
st.equals(locals['__bytes2'], '0x99AB') st.equals(locals['__bytes2'].value, '0x99AB')
st.equals(locals['__bytes4'], '0x99FA0000') st.equals(locals['__bytes4'].value, '0x99FA0000')
st.equals(locals['__bytes6'], '0x990000000000') st.equals(locals['__bytes6'].value, '0x990000000000')
st.equals(locals['__bytes7'], '0x99356700000000') st.equals(locals['__bytes7'].value, '0x99356700000000')
st.equals(locals['__bytes8'], '0x99ABD41700000000') st.equals(locals['__bytes8'].value, '0x99ABD41700000000')
st.equals(locals['__bytes9'], '0x99156744AF00000000') st.equals(locals['__bytes9'].value, '0x99156744AF00000000')
st.equals(locals['__bytes13'], '0x99123423425300000000000000') st.equals(locals['__bytes13'].value, '0x99123423425300000000000000')
st.equals(locals['__bytes16'], '0x99AFAD23432400000000000000000000') st.equals(locals['__bytes16'].value, '0x99AFAD23432400000000000000000000')
st.equals(locals['__bytes24'], '0x99AFAD234324000000000000000000000000000000000000') st.equals(locals['__bytes24'].value, '0x99AFAD234324000000000000000000000000000000000000')
st.equals(locals['__bytes32'], '0x9999ABD41799ABD4170000000000000000000000000000000000000000000000') st.equals(locals['__bytes32'].value, '0x9999ABD41799ABD4170000000000000000000000000000000000000000000000')
st.equals(Object.keys(locals).length, 16) st.equals(Object.keys(locals).length, 16)
} catch (e) { } catch (e) {
st.fail(e.message) st.fail(e.message)
...@@ -56,22 +56,22 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu ...@@ -56,22 +56,22 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
helper.decodeLocals(st, 7, traceManager, callTree, function (locals) { helper.decodeLocals(st, 7, traceManager, callTree, function (locals) {
try { try {
st.equals(locals['boolFalse'], false) st.equals(locals['boolFalse'].value, false)
st.equals(locals['boolTrue'], false) st.equals(locals['boolTrue'].value, false)
st.equals(locals['testEnum'], 'one') st.equals(locals['testEnum'].value, 'one')
st.equals(locals['sender'], '0x0000000000000000000000000000000000000000') st.equals(locals['sender'].value, '0x0000000000000000000000000000000000000000')
st.equals(locals['_bytes1'], '0x') st.equals(locals['_bytes1'].value, '0x')
st.equals(locals['__bytes1'], '0x') st.equals(locals['__bytes1'].value, '0x')
st.equals(locals['__bytes2'], '0x') st.equals(locals['__bytes2'].value, '0x')
st.equals(locals['__bytes4'], '0x') st.equals(locals['__bytes4'].value, '0x')
st.equals(locals['__bytes6'], '0x') st.equals(locals['__bytes6'].value, '0x')
st.equals(locals['__bytes7'], '0x') st.equals(locals['__bytes7'].value, '0x')
st.equals(locals['__bytes8'], '0x') st.equals(locals['__bytes8'].value, '0x')
st.equals(locals['__bytes9'], '0x') st.equals(locals['__bytes9'].value, '0x')
st.equals(locals['__bytes13'], '0x') st.equals(locals['__bytes13'].value, '0x')
st.equals(locals['__bytes16'], '0x') st.equals(locals['__bytes16'].value, '0x')
st.equals(locals['__bytes24'], '0x') st.equals(locals['__bytes24'].value, '0x')
st.equals(locals['__bytes32'], '0x') st.equals(locals['__bytes32'].value, '0x')
st.equals(Object.keys(locals).length, 16) st.equals(Object.keys(locals).length, 16)
} catch (e) { } catch (e) {
st.fail(e.message) st.fail(e.message)
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment