Merge pull request #5481 from ethereum/fix-byecodecompare

Fix storebytecode.sh for bytecode comparison
This commit is contained in:
Alex Beregszaszi 2018-11-22 19:10:35 +00:00 committed by GitHub
commit 5515d70be9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,7 +58,7 @@ for (var optimize of [false, true])
if (filename !== undefined)
{
var inputs = {}
inputs[filename] = fs.readFileSync(filename).toString()
inputs[filename] = { content: fs.readFileSync(filename).toString() }
var input = {
language: 'Solidity',
sources: inputs,
@ -68,16 +68,22 @@ for (var optimize of [false, true])
}
}
var result = JSON.parse(compiler.compile(JSON.stringify(input)))
if (!('contracts' in result) || Object.keys(result['contracts']).length === 0)
if (
!('contracts' in result) ||
Object.keys(result['contracts']).length === 0 ||
!result['contracts'][filename] ||
Object.keys(result['contracts'][filename]).length === 0
)
{
// NOTE: do not exit here because this may be run on source which cannot be compiled
console.log(filename + ': ERROR')
}
else
{
for (var contractName in result['contracts'])
for (var contractName in result['contracts'][filename])
{
console.log(contractName + ' ' + result['contracts'][contractName].evm.bytecode.object)
console.log(contractName + ' ' + result['contracts'][contractName].metadata)
console.log(contractName + ' ' + result['contracts'][filename][contractName].evm.bytecode.object)
console.log(contractName + ' ' + result['contracts'][filename][contractName].metadata)
}
}
}