Skip to content

Commit 40c7ce3

Browse files
authored
Add imports only test, fix instrumenter (#450)
1 parent e25728a commit 40c7ce3

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

lib/instrumenter.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ class Instrumenter {
7070

7171
// Walk the AST, recording injection points
7272
ast = SolidityParser.parse(contract.instrumented, {range: true});
73-
contract.contractName = ast.children.filter(node => this._isRootNode(node))[0].name;
73+
74+
const root = ast.children.filter(node => this._isRootNode(node));
75+
76+
// Handle contracts which only contain import statements
77+
contract.contractName = (root.length) ? root[0].name : null;
7478
parse[ast.type](contract, ast);
7579

7680
// We have to iterate through these points in descending order
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pragma solidity >=0.4.21 <0.6.0;
2+
3+
import "package/AnotherImport.sol";
4+
5+
interface Void {}

test/integration/projects/import-paths/node_modules/package/AnotherImport.sol

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)