diff --git a/lib/instrumentSolidity.js b/lib/instrumentSolidity.js index acc227b..120ac77 100644 --- a/lib/instrumentSolidity.js +++ b/lib/instrumentSolidity.js @@ -40,7 +40,8 @@ module.exports = function instrumentSolidity(contractSource, fileName) { ast = SolidityParser.parse(contract.preprocessed); const contractStatement = ast.body.filter(node => (node.type === 'ContractStatement' || - node.type === 'LibraryStatement')); + node.type === 'LibraryStatement' || + node.type === 'InterfaceStatement')); contract.contractName = contractStatement[0].name; parse[ast.type](contract, ast); diff --git a/lib/parse.js b/lib/parse.js index f00d2ec..187c09a 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -102,6 +102,10 @@ parse.IfStatement = function parseIfStatement(contract, expression) { } }; +parse.InterfaceStatement = function parseInterfaceStatement(contract, expression) { + parse.ContractOrLibraryStatement(contract, expression); +}; + parse.LibraryStatement = function parseLibraryStatement(contract, expression) { parse.ContractOrLibraryStatement(contract, expression); }; diff --git a/test/cli/totallyPure.js b/test/cli/totallyPure.js index d71a1f1..63e0891 100644 --- a/test/cli/totallyPure.js +++ b/test/cli/totallyPure.js @@ -74,4 +74,10 @@ contract('TotallyPure', accounts => { const value = await instance.multiline(5, 7) assert.equal(value.toNumber(), 99); }); + + it('calls a method who signature is defined by an interface', async () => { + const instance = await TotallyPure.deployed(); + await instance.cry(); + }); + }); \ No newline at end of file diff --git a/test/sources/cli/Face.sol b/test/sources/cli/Face.sol new file mode 100644 index 0000000..1b95f0c --- /dev/null +++ b/test/sources/cli/Face.sol @@ -0,0 +1,7 @@ +pragma experimental "v0.5.0"; +//pragma solidity ^0.4.17; + +interface Face { + function stare(uint a, uint b) external; + function cry() external; +} \ No newline at end of file diff --git a/test/sources/cli/TotallyPure.sol b/test/sources/cli/TotallyPure.sol index 7f5b1a3..eb7fb4d 100644 --- a/test/sources/cli/TotallyPure.sol +++ b/test/sources/cli/TotallyPure.sol @@ -1,10 +1,11 @@ pragma experimental "v0.5.0"; //pragma solidity ^0.4.17; +import "./../assets/Face.sol"; import "./../assets/PureView.sol"; import "./../assets/CLibrary.sol"; -contract TotallyPure is PureView { +contract TotallyPure is PureView, Face { uint onehundred = 99; function usesThem() { @@ -49,4 +50,11 @@ contract TotallyPure is PureView { return onehundred; } + function stare(uint a, uint b) external { + uint z = a + b; + } + + function cry() external { + + } } \ No newline at end of file diff --git a/test/util/mockTruffle.js b/test/util/mockTruffle.js index 5d801e3..ea05eb9 100644 --- a/test/util/mockTruffle.js +++ b/test/util/mockTruffle.js @@ -167,6 +167,7 @@ module.exports.installLibraryTest = function installInheritanceTest(config) { shell.cp('./test/cli/totallyPure.js', './mock/test/totallyPure.js'); shell.cp('./test/sources/cli/PureView.sol', './mock/assets/PureView.sol'); shell.cp('./test/sources/cli/CLibrary.sol', './mock/assets/CLibrary.sol'); + shell.cp('./test/sources/cli/Face.sol', './mock/assets/Face.sol'); // Mock truffle.js const trufflejs = `module.exports = {