Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"{" in base contract constructor parameter string confuses instumentation #478

Closed
KaiRo-at opened this issue Feb 14, 2020 · 6 comments
Closed

Comments

@KaiRo-at
Copy link

KaiRo-at commented Feb 14, 2020

I have a contract using my patches in OpenZeppelin/openzeppelin-contracts#2029 to add a URL to an ERC-1155 token, with code like this:

import ".../ERC1155MetadataURICatchAll.sol";
contract MYToken is ERC1155MetadataURICatchAll("https://example.com/meta/{id}"), {
    // Some contract code...
}

This compiles and works fine in general, but when running coverage, the instrumentation gets confused by the curly braces in the string and I get an error like this:

.../MYToken.sol:15:51: ParserError: Expected string end-quote.
 ... oken is ERC1155MetadataURICatchAll("https://example.com/meta/{event __CoverageMYToken(string fileName, uint256 lineNumber);
                                        ^--------------------------------------------------------------------------------------^

Compilation failed. See above.
Truffle v5.1.12 (core: 5.1.12)
Node v10.18.1
Cleaning up...
Event trace could not be read.
Error: ENOENT: no such file or directory, open './allFiredEvents'
Exiting without generating coverage...

When I remove the curly braces from the string before running coverage, it works correctly.

@KaiRo-at
Copy link
Author

KaiRo-at commented Feb 14, 2020

FWIW, if I move to a pattern where the parameter is noted with the constructor, e.g.

import ".../ERC1155MetadataURICatchAll.sol";
contract MYToken is ERC1155MetadataURICatchAll {
    constructor()
    ERC1155MetadataURICatchAll("https://example.com/CS2PS/meta/{id}")
    public
    {
    }
}

I get the same kind of error (message cropping not entirely correct as I had to edit out our actual URL given the project will not be public for some time):

.../MYToken.sol:56:32: ParserError: Expected string end-quote.
    ERC1155MetadataURICatchAll("https://example.com/meta ... yproject/contracts/MYToken.sol',1);
                               ^---------------------------------------------------------------^

@cgewecke
Copy link
Member

@KaiRo-at Thanks for reporting! Nice catch.

This should be fixed by #479. We just published yesterday - it could be a week (+) before another patch is released.

I think Zeppelin is migrating to solidity-coverage 0.7.x in the near term but at the moment they are using an older fork which is set up differently.

There might be a bit of delay getting these changes to percolate through to your PR...

@cgewecke cgewecke changed the title "{" in constructor parameter string confuses instumentation "{" in base contract constructor parameter string confuses instumentation Feb 14, 2020
@KaiRo-at
Copy link
Author

KaiRo-at commented Feb 14, 2020

Awesome!
Just out of interest, does this cover the similar case in #478 (comment) (i.e. the additional comment where I moved that base constructor call into the constructor declaration instead of the contract declaration) as well?
(And FWIW, I'm using solidity-coverage 0.6.7 directly in our projects, I just in addition also contributed that ERC-1155 URL support in OpenZeppelin.)

@cgewecke
Copy link
Member

@KaiRo-at Ah! Thanks for double-checking that...I didn't look at the second example closely enough. That will probably need it's own fix...

@cgewecke
Copy link
Member

@KaiRo-at The second one is fixed in #480...

@cgewecke
Copy link
Member

cgewecke commented Apr 6, 2020

Published with 0.7.3

@cgewecke cgewecke closed this as completed Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants