Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const web3Utils = require("web3-utils");
class Injector {
constructor(){
this.hashCounter = 0;
this.modifierCounter = 0;
this.modifiers = {};
}

Expand Down Expand Up @@ -353,11 +354,13 @@ class Injector {
}

injectModifier(contract, fileName, injectionPoint, injection, instrumentation){
this.modifierCounter++;

const type = 'modifier';
const contractId = `${fileName}:${injection.contractName}`;
const modifierId = `${fileName}:${injection.contractName}:` +
`${injection.modifierName}:${injection.fnId}:` +
`${injection.condition}`;
`${injection.condition}:${this.modifierCounter}`;

const {
start,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pragma solidity ^0.7.0;

contract Test {
modifier m(string memory val) {
_;
}

function a()
m('ETH')
m('BTC')
public
{
uint x = 5;
}
}
17 changes: 17 additions & 0 deletions test/units/modifiers.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,23 @@ describe('modifiers', () => {
});
});

it('should cover when same modifier is invoked twice on same fn', async function() {
const mapping = await setupAndRun('modifiers/duplicate-mods-same-fn');

assert.deepEqual(mapping[util.filePath].l, {
"5":2,"13":1
});
assert.deepEqual(mapping[util.filePath].b, {
"1":[1,0],"2":[1,0]
});
assert.deepEqual(mapping[util.filePath].s, {
1: 1
});
assert.deepEqual(mapping[util.filePath].f, {
1: 2, 2: 1
});
});

it('should *not* treat constructor inheritance invocations as branches', async function() {
const mapping = await setupAndRun('modifiers/constructor');
assert.deepEqual(mapping[util.filePath].b, {});
Expand Down