Skip to content

Commit 586d1c1

Browse files
committed
Add test for compileStandard with imports
1 parent 54e9352 commit 586d1c1

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test/package.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,48 @@ tape('Compilation', function (t) {
396396
st.end();
397397
});
398398

399+
t.test('compiling standard JSON (with imports)', function (st) {
400+
// <0.1.6 doesn't have this
401+
if (!solc.features.multipleInputs) {
402+
st.skip('Not supported by solc');
403+
st.end();
404+
return;
405+
}
406+
407+
var input = {
408+
'language': 'Solidity',
409+
'settings': {
410+
'outputSelection': {
411+
'*': {
412+
'*': [ 'evm.bytecode' ]
413+
}
414+
}
415+
},
416+
'sources': {
417+
'cont.sol': {
418+
'content': 'import "lib.sol"; contract x { function g() public { L.f(); } }'
419+
}
420+
}
421+
};
422+
423+
function findImports (path) {
424+
if (path === 'lib.sol') {
425+
return { contents: 'library L { function f() public returns (uint) { return 7; } }' };
426+
} else {
427+
return { error: 'File not found' };
428+
}
429+
}
430+
431+
var output = JSON.parse(solc.compile(JSON.stringify(input), findImports));
432+
var x = getBytecodeStandard(output, 'cont.sol', 'x');
433+
st.ok(x);
434+
st.ok(x.length > 0);
435+
var L = getBytecodeStandard(output, 'lib.sol', 'L');
436+
st.ok(L);
437+
st.ok(L.length > 0);
438+
st.end();
439+
});
440+
399441
t.test('compiling standard JSON (using libraries)', function (st) {
400442
// <0.1.6 doesn't have this
401443
if (!solc.features.multipleInputs) {

0 commit comments

Comments
 (0)