diff --git a/lib/app.js b/lib/app.js index 0bec678..ae9bbad 100644 --- a/lib/app.js +++ b/lib/app.js @@ -285,10 +285,13 @@ class App { postProcessPure(env) { shell.ls(`${env}/**/*.sol`).forEach(file => { const pureRe = /\spure\s/gi; - + const viewRe = /\sview\s/gi; + const constantRe = /\sconstant\s/gi; const contractPath = this.platformNeutralPath(file); let contract = fs.readFileSync(contractPath).toString(); contract = contract.replace(pureRe, ' '); + contract = contract.replace(viewRe, ' '); + contract = contract.replace(constantRe, ' '); fs.writeFileSync(contractPath, contract); }) } diff --git a/test/app.js b/test/app.js index ee4b59e..202155d 100644 --- a/test/app.js +++ b/test/app.js @@ -261,7 +261,7 @@ describe('app', () => { assert(produced[path].fnMap['1'].name === 'usesThem', 'coverage.json should map "usesThem"'); assert(produced[path].fnMap['2'].name === 'isPure', 'coverage.json should map "getX"'); collectGarbage(); - }) + }); it('tests require assets outside of test folder: should generate coverage, cleanup & exit(0)', () => { // Directory should be clean diff --git a/test/cli/totallyPure.js b/test/cli/totallyPure.js index 8374c97..4e31b72 100644 --- a/test/cli/totallyPure.js +++ b/test/cli/totallyPure.js @@ -4,39 +4,44 @@ const TotallyPure = artifacts.require('./TotallyPure.sol'); contract('TotallyPure', accounts => { - - it('calls imported, inherited pure/view functions within its own function', async function(){ + it('calls imported, inherited pure/view functions within its own function', async () => { const instance = await TotallyPure.deployed(); await instance.usesThem(); }); - it('calls an imported, inherited pure function', async function(){ + it('calls an imported, inherited pure function', async () => { const instance = await TotallyPure.deployed(); - const value = await instance.isPure(4,5); + const value = await instance.isPure.call(4, 5); + assert.equal(value.toNumber(), 20); }); - it('calls an imported, inherited view function', async function(){ + it('calls an imported, inherited view function', async () => { const instance = await TotallyPure.deployed(); - const value = await instance.isView(); - }) + const value = await instance.isView.call(); + assert.equal(value.toNumber(), 5); + }); - it('calls an imported, inherited constant function', async function(){ + it('calls an imported, inherited constant function', async () => { const instance = await TotallyPure.deployed(); - const value = await instance.isConstant(); - }) + const value = await instance.isConstant.call(); + assert.equal(value.toNumber(), 99); + }); - it('overrides an imported, inherited abstract pure function', async function(){ + it('overrides an imported, inherited abstract pure function', async () => { const instance = await TotallyPure.deployed(); - const value = await instance.bePure(4,5); - }) + const value = await instance.bePure.call(4, 5); + assert.equal(value.toNumber(), 9); + }); - it('overrides an imported, inherited abstract view function', async function(){ + it('overrides an imported, inherited abstract view function', async () => { const instance = await TotallyPure.deployed(); - const value = await instance.beView(); + const value = await instance.beView.call(); + assert.equal(value.toNumber(), 99); }); - it('overrides an imported, inherited abstract constant function', async function(){ + it('overrides an imported, inherited abstract constant function', async () => { const instance = await TotallyPure.deployed(); - const value = await instance.beConstant(); + const value = await instance.beConstant.call(); + assert.equal(value.toNumber(), 99); }); }); \ No newline at end of file