Fix bytecode tests for solc-js

This commit is contained in:
chriseth 2018-11-06 15:14:44 +01:00 committed by Alex Beregszaszi
parent 28d98d61ef
commit 6ed3765941

View File

@ -41,14 +41,15 @@ TMPDIR=$(mktemp -d)
if [[ "$SOLC_EMSCRIPTEN" = "On" ]]
then
# npm install solc
git clone --depth 1 https://github.com/ethereum/solc-js.git solc
cp "$REPO_ROOT/build/libsolc/soljson.js" .
git clone --depth 1 https://github.com/ethereum/solc-js.git solc-js
( cd solc-js; npm install )
cp "$REPO_ROOT/build/libsolc/soljson.js" solc-js/
cat > solc <<EOF
#!/usr/bin/env node
var process = require('process')
var fs = require('fs')
var compiler = require('solc/wrapper.js')(require('./soljson.js'))
var compiler = require('./solc-js/wrapper.js')(require('./solc-js/soljson.js'))
for (var optimize of [false, true])
{
@ -58,7 +59,15 @@ for (var optimize of [false, true])
{
var inputs = {}
inputs[filename] = fs.readFileSync(filename).toString()
var result = compiler.compile({sources: inputs}, optimize)
var input = {
language: 'Solidity',
sources: inputs,
settings: {
optimizer: { enabled: optimize },
outputSelection: { '*': { '*': ['evm.bytecode.object', 'metadata'] } }
}
}
var result = JSON.parse(compiler.compile(JSON.stringify(input)))
if (!('contracts' in result) || Object.keys(result['contracts']).length === 0)
{
console.log(filename + ': ERROR')
@ -67,7 +76,7 @@ for (var optimize of [false, true])
{
for (var contractName in result['contracts'])
{
console.log(contractName + ' ' + result['contracts'][contractName].bytecode)
console.log(contractName + ' ' + result['contracts'][contractName].evm.bytecode.object)
console.log(contractName + ' ' + result['contracts'][contractName].metadata)
}
}