@@ -35,6 +35,20 @@ function runTests (solc, versionText) {
35
35
}
36
36
}
37
37
38
+ function getGasEstimate ( output , fileName , contractName ) {
39
+ try {
40
+ var outputFile ;
41
+ if ( semver . lt ( solc . semver ( ) , '0.4.9' ) ) {
42
+ outputFile = output . contracts [ '' ] ;
43
+ } else {
44
+ outputFile = output . contracts [ fileName ] ;
45
+ }
46
+ return outputFile [ contractName ] [ 'evm' ] [ 'gasEstimates' ] ;
47
+ } catch ( e ) {
48
+ return '' ;
49
+ }
50
+ }
51
+
38
52
function expectError ( output , errorType , message ) {
39
53
if ( output . errors ) {
40
54
for ( var error in output . errors ) {
@@ -406,7 +420,7 @@ function runTests (solc, versionText) {
406
420
'settings' : {
407
421
'outputSelection' : {
408
422
'*' : {
409
- '*' : [ 'evm.bytecode' ]
423
+ '*' : [ 'evm.bytecode' , 'evm.gasEstimates' ]
410
424
}
411
425
}
412
426
} ,
@@ -415,7 +429,7 @@ function runTests (solc, versionText) {
415
429
'content' : 'library L { function f() public returns (uint) { return 7; } }'
416
430
} ,
417
431
'cont.sol' : {
418
- 'content' : 'import "lib.sol"; contract x { function g() public { L.f(); } }'
432
+ 'content' : 'import "lib.sol"; contract x { function g() public { L.f(); } function h() internal {} }'
419
433
}
420
434
}
421
435
} ;
@@ -424,6 +438,14 @@ function runTests (solc, versionText) {
424
438
var x = getBytecodeStandard ( output , 'cont.sol' , 'x' ) ;
425
439
st . ok ( typeof x === 'string' ) ;
426
440
st . ok ( x . length > 0 ) ;
441
+ var xGas = getGasEstimate ( output , 'cont.sol' , 'x' ) ;
442
+ st . ok ( typeof xGas === 'object' ) ;
443
+ st . ok ( typeof xGas [ 'creation' ] === 'object' ) ;
444
+ st . ok ( typeof xGas [ 'creation' ] [ 'codeDepositCost' ] === 'string' ) ;
445
+ st . ok ( typeof xGas [ 'external' ] === 'object' ) ;
446
+ st . ok ( typeof xGas [ 'external' ] [ 'g()' ] === 'string' ) ;
447
+ st . ok ( typeof xGas [ 'internal' ] === 'object' ) ;
448
+ st . ok ( typeof xGas [ 'internal' ] [ 'h()' ] === 'string' ) ;
427
449
var L = getBytecodeStandard ( output , 'lib.sol' , 'L' ) ;
428
450
st . ok ( typeof L === 'string' ) ;
429
451
st . ok ( L . length > 0 ) ;
0 commit comments