Skip to content

Commit f3f4f57

Browse files
authored
Merge pull request #200 from ethereum/fixes
Fixes in compileStandardWrapper
2 parents 7bc8c62 + 3c8df6a commit f3f4f57

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

test/package.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const tape = require('tape');
22
const semver = require('semver');
33
const solc = require('../index.js');
4+
const linker = require('../linker.js');
45

56
function getBytecode (output, fileName, contractName) {
67
try {
@@ -373,6 +374,50 @@ tape('Compilation', function (t) {
373374
st.ok(L.length > 0);
374375
st.end();
375376
});
377+
378+
t.test('compiling standard JSON (using wrapper and libraries)', function (st) {
379+
// Example needs support for compileJSONMulti
380+
// FIXME: add test for wrapper without multiple files
381+
if (semver.lt(solc.semver(), '0.1.6')) {
382+
st.skip('Not supported by solc <0.1.6');
383+
st.end();
384+
return;
385+
}
386+
387+
var input = {
388+
'language': 'Solidity',
389+
'settings': {
390+
'libraries': {
391+
'lib.sol': {
392+
'L': '4200000000000000000000000000000000000001'
393+
}
394+
},
395+
'outputSelection': {
396+
'*': {
397+
'*': [ 'evm.bytecode' ]
398+
}
399+
}
400+
},
401+
'sources': {
402+
'lib.sol': {
403+
'content': 'library L { function f() returns (uint) { return 7; } }'
404+
},
405+
'cont.sol': {
406+
'content': 'import "lib.sol"; contract x { function g() { L.f(); } }'
407+
}
408+
}
409+
};
410+
411+
var output = JSON.parse(solc.compileStandardWrapper(JSON.stringify(input)));
412+
var x = getBytecodeStandard(output, 'cont.sol', 'x');
413+
st.ok(x);
414+
st.ok(x.length > 0);
415+
st.ok(Object.keys(linker.findLinkReferences(x)).length === 0);
416+
var L = getBytecodeStandard(output, 'lib.sol', 'L');
417+
st.ok(L);
418+
st.ok(L.length > 0);
419+
st.end();
420+
});
376421
});
377422

378423
tape('Loading Legacy Versions', function (t) {

wrapper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ function setupMethods (soljson) {
9393
'component': 'solcjs',
9494
'severity': 'error',
9595
'message': message,
96-
'formattedMessage': 'Error' + message
96+
'formattedMessage': 'Error: ' + message
9797
}
9898
]
9999
});
100100
}
101101

102-
if (readCallback !== null && typeof readCallback !== 'function') {
102+
if (readCallback !== undefined && typeof readCallback !== 'function') {
103103
return formatFatalError('Invalid import callback supplied');
104104
}
105105

0 commit comments

Comments
 (0)