2019-09-25 13:59:52 +00:00
|
|
|
const tape = require('tape');
|
|
|
|
const fs = require('fs');
|
|
|
|
const solc = require('../index.js');
|
|
|
|
|
|
|
|
tape('Deterministic Compilation', function (t) {
|
|
|
|
t.test('DAO', function (st) {
|
2021-12-21 15:17:22 +00:00
|
|
|
const input = {};
|
|
|
|
let prevBytecode = null;
|
|
|
|
const testdir = 'test/DAO/';
|
|
|
|
const files = ['DAO.sol', 'Token.sol', 'TokenCreation.sol', 'ManagedAccount.sol'];
|
|
|
|
let i;
|
2019-09-25 13:59:52 +00:00
|
|
|
for (i in files) {
|
2021-12-21 15:17:22 +00:00
|
|
|
const file = files[i];
|
2019-09-25 13:59:52 +00:00
|
|
|
input[file] = { content: fs.readFileSync(testdir + file, 'utf8') };
|
|
|
|
}
|
|
|
|
for (i = 0; i < 10; i++) {
|
2021-12-21 15:17:22 +00:00
|
|
|
const output = JSON.parse(solc.compile(JSON.stringify({
|
2019-09-25 13:59:52 +00:00
|
|
|
language: 'Solidity',
|
|
|
|
settings: {
|
|
|
|
optimizer: {
|
|
|
|
enabled: true
|
|
|
|
},
|
|
|
|
outputSelection: {
|
|
|
|
'*': {
|
2021-12-21 15:17:22 +00:00
|
|
|
'*': ['evm.bytecode']
|
2019-09-25 13:59:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
sources: input
|
|
|
|
})));
|
|
|
|
st.ok(output);
|
|
|
|
st.ok(output.contracts);
|
|
|
|
st.ok(output.contracts['DAO.sol']);
|
2021-12-21 15:17:22 +00:00
|
|
|
st.ok(output.contracts['DAO.sol'].DAO);
|
|
|
|
st.ok(output.contracts['DAO.sol'].DAO.evm.bytecode.object);
|
|
|
|
const bytecode = output.contracts['DAO.sol'].DAO.evm.bytecode.object;
|
2019-09-25 13:59:52 +00:00
|
|
|
st.ok(bytecode.length > 0);
|
|
|
|
if (prevBytecode !== null) {
|
|
|
|
st.equal(prevBytecode, bytecode);
|
|
|
|
}
|
|
|
|
prevBytecode = bytecode;
|
|
|
|
}
|
|
|
|
st.end();
|
|
|
|
});
|
|
|
|
});
|