File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,22 @@ tape('Compilation', function (t) {
177
177
st . end ( ) ;
178
178
} ) ;
179
179
180
+ t . test ( 'lazy-loading callback fails properly (with invalid callback)' , function ( st ) {
181
+ if ( semver . lt ( solc . semver ( ) , '0.2.1' ) ) {
182
+ st . skip ( 'Not supported by solc <0.2.1' ) ;
183
+ st . end ( ) ;
184
+ return ;
185
+ }
186
+
187
+ var input = {
188
+ 'cont.sol' : 'import "lib.sol"; contract x { function g() { L.f(); } }'
189
+ } ;
190
+ st . throws ( function ( ) {
191
+ solc . compile ( { sources : input } , 0 , "this isn't a callback" ) ;
192
+ } , / I n v a l i d c a l l b a c k s p e c i f i e d ./ ) ;
193
+ st . end ( ) ;
194
+ } ) ;
195
+
180
196
t . test ( 'file import without lazy-loading callback fails properly' , function ( st ) {
181
197
if ( semver . lt ( solc . semver ( ) , '0.2.1' ) ) {
182
198
st . skip ( 'Not supported by solc <0.2.1' ) ;
Original file line number Diff line number Diff line change
1
+ var assert = require ( 'assert' ) ;
1
2
var translate = require ( './translate.js' ) ;
2
3
var linker = require ( './linker.js' ) ;
3
4
var requireFromString = require ( 'require-from-string' ) ;
@@ -20,6 +21,7 @@ function setupMethods (soljson) {
20
21
soljson . setValue ( ptr , buffer , '*' ) ;
21
22
} ;
22
23
var wrapCallback = function ( callback ) {
24
+ assert ( typeof callback === 'function' , 'Invalid callback specified.' ) ;
23
25
return function ( path , contents , error ) {
24
26
var result = callback ( soljson . Pointer_stringify ( path ) ) ;
25
27
if ( typeof result . contents === 'string' ) {
You can’t perform that action at this time.
0 commit comments