File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ var linkBytecode = function (bytecode, libraries) {
2
2
// NOTE: for backwards compatibility support old compiler which didn't use file names
3
3
var librariesComplete = { } ;
4
4
for ( var libraryName in libraries ) {
5
- if ( typeof libraryName === 'object' ) {
5
+ if ( typeof libraries [ libraryName ] === 'object' ) {
6
6
// API compatible with the standard JSON i/o
7
7
for ( var lib in libraries [ libraryName ] ) {
8
8
librariesComplete [ lib ] = libraries [ libraryName ] [ lib ] ;
Original file line number Diff line number Diff line change @@ -456,6 +456,20 @@ tape('Linking', function (t) {
456
456
st . end ( ) ;
457
457
} ) ;
458
458
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
+
459
473
t . test ( 'linker to fail with missing library' , function ( st ) {
460
474
var input = {
461
475
'lib.sol' : 'library L { function f() returns (uint) { return 7; } }' ,
You can’t perform that action at this time.
0 commit comments