add more tests

pull/7/head
yann300 8 years ago
parent 25da05dc59
commit 222a4f8363
  1. 2
      src/solidity/decodeInfo.js
  2. 40
      test/solidity/contracts.js
  3. 15
      test/solidity/storageLocation.js

@ -200,7 +200,7 @@ function Struct (type, stateDefinitions) {
function getEnum (type, stateDefinitions) {
for (var k in stateDefinitions) {
var dec = stateDefinitions[k]
if (type === 'enum ' + dec.attributes.name) {
if (dec.attributes && dec.attributes.name && type === 'enum ' + dec.attributes.name) {
return dec
}
}

@ -38,5 +38,43 @@ module.exports = `
int32 i32;
uint ui32;
int16 i16;
}
}
contract testSimpleStorage1 {
uint32 uibase1;
}
contract testSimpleStorage is testSimpleStorage1 {
uint ui1;
uint ui2;
uint[1] ui3;
uint[][1][4] ui4;
int16 i16;
struct structDef {
uint ui;
string str;
}
structDef structDec;
structDef[3] arrayStructDec;
int32 i32;
int16 i16_2;
enum enumDef {
first,
second,
third
}
enumDef enumDec;
bool boolean;
uint[][2][][3] ui5;
string _string;
}
`

@ -31,6 +31,21 @@ tape('solidity', function (t) {
checkLocation(st, stateDec[4].location, 1, 0)
checkLocation(st, stateDec[5].location, 2, 0)
stateDec = index.solidity.stateDecoder.extractStateVariables('testSimpleStorage', output.sources)
checkLocation(st, stateDec[0].location, 0, 0)
checkLocation(st, stateDec[1].location, 1, 0)
checkLocation(st, stateDec[2].location, 2, 0)
checkLocation(st, stateDec[3].location, 3, 0)
checkLocation(st, stateDec[4].location, 4, 0)
checkLocation(st, stateDec[5].location, 8, 0)
checkLocation(st, stateDec[6].location, 9, 0)
checkLocation(st, stateDec[8].location, 17, 0)
checkLocation(st, stateDec[9].location, 17, 4)
checkLocation(st, stateDec[10].location, 17, 6)
checkLocation(st, stateDec[11].location, 17, 7)
checkLocation(st, stateDec[12].location, 18, 0)
checkLocation(st, stateDec[13].location, 21, 0)
st.end()
})
})

Loading…
Cancel
Save