fix and add tests

pull/7/head
yann300 8 years ago
parent 2e3d94f370
commit 72ab547de5
  1. 10
      test/solidity/contracts/addressLocal.js
  2. 32
      test/solidity/contracts/miscLocal.js
  3. 9
      test/solidity/localDecoder.js
  4. 38
      test/solidity/localsTests/misc.js

@ -1,10 +0,0 @@
'use strict'
module.exports = {
contract: `
contract addressLocal {
function addressLocal () {
address sender = msg.sender;
}
}
`}

@ -0,0 +1,32 @@
'use strict'
module.exports = {
contract: `
contract miscLocal {
enum enumDef {
one,
two,
three,
four
}
function miscLocal () {
bool boolFalse = false;
bool boolTrue = true;
enumDef testEnum;
testEnum = enumDef.three;
address sender = msg.sender;
byte _bytes1 = hex"99";
bytes1 __bytes1 = hex"99";
bytes2 __bytes2 = hex"99AB";
bytes4 __bytes4 = hex"99FA";
bytes6 __bytes6 = hex"99";
bytes7 __bytes7 = hex"993567";
bytes8 __bytes8 = hex"99ABD417";
bytes9 __bytes9 = hex"99156744AF";
bytes13 __bytes13 = hex"991234234253";
bytes16 __bytes16 = hex"99AFAD234324";
bytes24 __bytes24 = hex"99AFAD234324";
bytes32 __bytes32 = hex"9999ABD41799ABD417";
}
}
`}

@ -2,14 +2,13 @@
var tape = require('tape')
var compiler = require('solc')
var intLocal = require('./contracts/intLocal')
var addressLocal = require('./contracts/addressLocal')
var miscLocal = require('./contracts/miscLocal')
var VM = require('ethereumjs-vm')
var utileth = require('ethereumjs-util')
var Web3Providers = require('../../src/web3Provider/web3Providers')
var util = require('../../src/helpers/global')
var intLocalTest = require('./localsTests/int')
var addressLocalTest = require('./localsTests/address')
// var sync = require('sync')
var miscLocalTest = require('./localsTests/misc')
tape('solidity', function (t) {
t.test('local decoder', function (st) {
@ -47,7 +46,7 @@ function initVM (st, address) {
function test (st, vm, privateKey) {
var output = compiler.compile(intLocal.contract, 0)
intLocalTest(st, vm, privateKey, output.contracts['intLocal'].bytecode, output, function () {
output = compiler.compile(addressLocal.contract, 0)
addressLocalTest(st, vm, privateKey, output.contracts['addressLocal'].bytecode, output, function () {})
output = compiler.compile(miscLocal.contract, 0)
miscLocalTest(st, vm, privateKey, output.contracts['miscLocal'].bytecode, output, function () {})
})
}

@ -27,19 +27,49 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
var debuggerEvent = new EventManager()
var callTree = new InternalCallTree(debuggerEvent, traceManager, solidityProxy, codeManager, { includeLocalsVariables: true })
callTree.event.register('callTreeReady', (scopes, scopeStarts) => {
helper.decodeLocals(st, 10, traceManager, callTree, function (locals) {
helper.decodeLocals(st, 70, traceManager, callTree, function (locals) {
try {
st.equals(locals['boolFalse'], false)
st.equals(locals['boolTrue'], true)
st.equals(locals['testEnum'], 'three')
st.equals(locals['sender'], '0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db')
st.equals(Object.keys(locals).length, 1)
st.equals(locals['_bytes1'], '0x99')
st.equals(locals['__bytes1'], '0x99')
st.equals(locals['__bytes2'], '0x99AB')
st.equals(locals['__bytes4'], '0x99FA0000')
st.equals(locals['__bytes6'], '0x990000000000')
st.equals(locals['__bytes7'], '0x99356700000000')
st.equals(locals['__bytes8'], '0x99ABD41700000000')
st.equals(locals['__bytes9'], '0x99156744AF00000000')
st.equals(locals['__bytes13'], '0x99123423425300000000000000')
st.equals(locals['__bytes16'], '0x99AFAD23432400000000000000000000')
st.equals(locals['__bytes24'], '0x99AFAD234324000000000000000000000000000000000000')
st.equals(locals['__bytes32'], '0x9999ABD41799ABD4170000000000000000000000000000000000000000000000')
st.equals(Object.keys(locals).length, 16)
} catch (e) {
st.fail(e.message)
}
})
helper.decodeLocals(st, 4, traceManager, callTree, function (locals) {
helper.decodeLocals(st, 7, traceManager, callTree, function (locals) {
try {
st.equals(locals['boolFalse'], false)
st.equals(locals['boolTrue'], false)
st.equals(locals['testEnum'], 'one')
st.equals(locals['sender'], '0x0000000000000000000000000000000000000000')
st.equals(Object.keys(locals).length, 1)
st.equals(locals['_bytes1'], '0x')
st.equals(locals['__bytes1'], '0x')
st.equals(locals['__bytes2'], '0x')
st.equals(locals['__bytes4'], '0x')
st.equals(locals['__bytes6'], '0x')
st.equals(locals['__bytes7'], '0x')
st.equals(locals['__bytes8'], '0x')
st.equals(locals['__bytes9'], '0x')
st.equals(locals['__bytes13'], '0x')
st.equals(locals['__bytes16'], '0x')
st.equals(locals['__bytes24'], '0x')
st.equals(locals['__bytes32'], '0x')
st.equals(Object.keys(locals).length, 16)
} catch (e) {
st.fail(e.message)
}
Loading…
Cancel
Save