Skip to content

Commit fa1993a

Browse files
authored
Merge pull request #208 from theoport/linker-bugfix
Fix linkBytecode to work properly with two-level lists
2 parents 37d7f76 + 3877344 commit fa1993a

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

linker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var linkBytecode = function (bytecode, libraries) {
22
// NOTE: for backwards compatibility support old compiler which didn't use file names
33
var librariesComplete = {};
44
for (var libraryName in libraries) {
5-
if (typeof libraryName === 'object') {
5+
if (typeof libraries[libraryName] === 'object') {
66
// API compatible with the standard JSON i/o
77
for (var lib in libraries[libraryName]) {
88
librariesComplete[lib] = libraries[libraryName][lib];

test/package.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,20 @@ tape('Linking', function (t) {
456456
st.end();
457457
});
458458

459+
t.test('link properly with two-level configuration (from standard JSON)', function (st) {
460+
var input = {
461+
'lib.sol': 'library L { function f() returns (uint) { return 7; } }',
462+
'cont.sol': 'import "lib.sol"; contract x { function g() { L.f(); } }'
463+
};
464+
var output = solc.compile({sources: input});
465+
var bytecode = getBytecode(output, 'cont.sol', 'x');
466+
st.ok(bytecode);
467+
st.ok(bytecode.length > 0);
468+
bytecode = solc.linkBytecode(bytecode, { 'lib.sol': { 'L': '0x123456' } });
469+
st.ok(bytecode.indexOf('_') < 0);
470+
st.end();
471+
});
472+
459473
t.test('linker to fail with missing library', function (st) {
460474
var input = {
461475
'lib.sol': 'library L { function f() returns (uint) { return 7; } }',

0 commit comments

Comments
 (0)