pull/7/head
yann300 8 years ago
parent 5ca197d060
commit 4603a41e3e
  1. 124
      test/solidity/storageDecoder.js

@ -54,47 +54,91 @@ function testIntStorage (st) {
function testByteStorage (st) { function testByteStorage (st) {
var byteStorage = require('./contracts/byteStorage') var byteStorage = require('./contracts/byteStorage')
var output = compiler.compile(byteStorage.contract, 0) var output = compiler.compile(byteStorage.contract, 0)
var decoded = stateDecoder.solidityState(byteStorage.storage, output.sources, 'byteStorage') for (var storage of [byteStorage.storage, shrinkStorage(byteStorage.storage)]) {
var decoded = stateDecoder.solidityState(storage, output.sources, 'byteStorage')
st.equal(decoded['b1'], false)
st.equal(decoded['a1'], '0xfe350f199f244ac9a79038d254400b632a633225')
st.equal(decoded['b2'], true)
st.equal(decoded['dynb1'], '0x64796e616d69636279746573')
st.equal(decoded['stab'], '0x1')
st.equal(decoded['stab1'], '0x12')
st.equal(decoded['stab2'], '0x1579')
st.equal(decoded['stab3'], '0x359356')
st.equal(decoded['stab4'], '0x2375')
st.equal(decoded['stab5'], '0x2357645')
st.equal(decoded['stab6'], '0x324435')
st.equal(decoded['stab7'], '0x324324')
st.equal(decoded['stab8'], '0x324554645765')
st.equal(decoded['stab9'], '0x3434543')
st.equal(decoded['stab10'], '0x4543543654657')
st.equal(decoded['stab11'], '0x54354654')
st.equal(decoded['stab12'], '0x3')
st.equal(decoded['stab13'], '0x3243242345435')
st.equal(decoded['stab14'], '0x32454354354353')
st.equal(decoded['stab15'], '0x32454434435')
st.equal(decoded['stab16'], '0x3245435444')
st.equal(decoded['stab17'], '0x32454343243243245')
st.equal(decoded['stab18'], '0x324534325435435')
st.equal(decoded['stab19'], '0x324543435435435')
st.equal(decoded['stab20'], '0x32454543543AB35')
st.equal(decoded['stab21'], '0x32454432423435')
st.equal(decoded['stab22'], '0x324543AEF5')
st.equal(decoded['stab23'], '0x3245435FFF')
st.equal(decoded['stab24'], '0x3245435F')
st.equal(decoded['stab25'], '0x3245435F')
st.equal(decoded['stab26'], '0x3245435F')
st.equal(decoded['stab27'], '0x3245FFFFFFF')
st.equal(decoded['stab28'], '0x3241235')
st.equal(decoded['stab29'], '0x325213213')
st.equal(decoded['stab30'], '0x3245435232423')
st.equal(decoded['stab31'], '0x3245435123')
st.equal(decoded['stab32'], '0x324324423432543543AB')
st.equal(decoded['enumDec'], 'd')
st.equal(decoded['str1'], 'short')
st.equal(decoded['str2'], 'long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long')
}
decoded = stateDecoder.solidityState({}, output.sources, 'byteStorage')
st.equal(decoded['b1'], false) st.equal(decoded['b1'], false)
st.equal(decoded['a1'], '0xfe350f199f244ac9a79038d254400b632a633225') st.equal(decoded['a1'], '0x0000000000000000000000000000000000000000')
st.equal(decoded['b2'], true) st.equal(decoded['b2'], false)
st.equal(decoded['dynb1'], '0x64796e616d69636279746573') st.equal(decoded['dynb1'], '0x')
st.equal(decoded['stab'], '0x1') st.equal(decoded['stab'], '0x')
st.equal(decoded['stab1'], '0x12') st.equal(decoded['stab1'], '0x')
st.equal(decoded['stab2'], '0x1579') st.equal(decoded['stab2'], '0x')
st.equal(decoded['stab3'], '0x359356') st.equal(decoded['stab3'], '0x')
st.equal(decoded['stab4'], '0x2375') st.equal(decoded['stab4'], '0x')
st.equal(decoded['stab5'], '0x2357645') st.equal(decoded['stab5'], '0x')
st.equal(decoded['stab6'], '0x324435') st.equal(decoded['stab6'], '0x')
st.equal(decoded['stab7'], '0x324324') st.equal(decoded['stab7'], '0x')
st.equal(decoded['stab8'], '0x324554645765') st.equal(decoded['stab8'], '0x')
st.equal(decoded['stab9'], '0x3434543') st.equal(decoded['stab9'], '0x')
st.equal(decoded['stab10'], '0x4543543654657') st.equal(decoded['stab10'], '0x')
st.equal(decoded['stab11'], '0x54354654') st.equal(decoded['stab11'], '0x')
st.equal(decoded['stab12'], '0x3') st.equal(decoded['stab12'], '0x')
st.equal(decoded['stab13'], '0x3243242345435') st.equal(decoded['stab13'], '0x')
st.equal(decoded['stab14'], '0x32454354354353') st.equal(decoded['stab14'], '0x')
st.equal(decoded['stab15'], '0x32454434435') st.equal(decoded['stab15'], '0x')
st.equal(decoded['stab16'], '0x3245435444') st.equal(decoded['stab16'], '0x')
st.equal(decoded['stab17'], '0x32454343243243245') st.equal(decoded['stab17'], '0x')
st.equal(decoded['stab18'], '0x324534325435435') st.equal(decoded['stab18'], '0x')
st.equal(decoded['stab19'], '0x324543435435435') st.equal(decoded['stab19'], '0x')
st.equal(decoded['stab20'], '0x32454543543AB35') st.equal(decoded['stab20'], '0x')
st.equal(decoded['stab21'], '0x32454432423435') st.equal(decoded['stab21'], '0x')
st.equal(decoded['stab22'], '0x324543AEF5') st.equal(decoded['stab22'], '0x')
st.equal(decoded['stab23'], '0x3245435FFF') st.equal(decoded['stab23'], '0x')
st.equal(decoded['stab24'], '0x3245435F') st.equal(decoded['stab24'], '0x')
st.equal(decoded['stab25'], '0x3245435F') st.equal(decoded['stab25'], '0x')
st.equal(decoded['stab26'], '0x3245435F') st.equal(decoded['stab26'], '0x')
st.equal(decoded['stab27'], '0x3245FFFFFFF') st.equal(decoded['stab27'], '0x')
st.equal(decoded['stab28'], '0x3241235') st.equal(decoded['stab28'], '0x')
st.equal(decoded['stab29'], '0x325213213') st.equal(decoded['stab29'], '0x')
st.equal(decoded['stab30'], '0x3245435232423') st.equal(decoded['stab30'], '0x')
st.equal(decoded['stab31'], '0x3245435123') st.equal(decoded['stab31'], '0x')
st.equal(decoded['stab32'], '0x324324423432543543AB') st.equal(decoded['stab32'], '0x')
st.equal(decoded['enumDec'], 'd') st.equal(decoded['enumDec'], 'a')
st.equal(decoded['str1'], 'short') st.equal(decoded['str1'], '')
st.equal(decoded['str2'], 'long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long') st.equal(decoded['str2'], '')
} }
function shrinkStorage (storage) { function shrinkStorage (storage) {

Loading…
Cancel
Save