question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Constant / view / pure functions still requiring .call()

See original GitHub issue

Using 0.4.9.

https://github.com/sc-forks/solidity-coverage/pull/161 seems like a pretty reasonable thing to do, and it should work, but I’m having trouble with it on aragonOS.

From what I gather, the problem seems to be from truffle test compiling the contracts again. I see the compiler running three times: once for the original, once for the modified, (at this point the modified’s ABI is switched out for the original, and I can verify this in the coverageEnv/builds folder), and then again when truffle test is run.

I’m not familiar with how everything is hooked up in truffle, but running through the code, it seems to be that:

  1. Running truffle test will compile any necessary files with the test files (it first checks for any updated files, and here it doesn’t find any)
  2. The compiler is invoked for any necessary files, and then with all the necessary files’ dependencies. The only necessary files at this point are the test mocks that we use.
  3. Now tests are run, with contract artifacts being created, etc. When creating the contract artifacts in the test, truffle checks if the function in the abi is constant or not, and if so, provides the .call() for us. This last bit is the weird part: I can confirm in the coverageEnv/build folder that the ABIs have been swapped, and that any constant functions are appropriately marked. However, the above check when creating the contract artifacts seems to be failing for a lot of these functions, leading me to think that the re-compile done by truffle test is causing a newer version of the ABI to be used.

I tried to see if not compiling the tests’ dependencies would work… but that started giving me parser/compiler errors D:

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
sohkaicommented, Jan 26, 2018

Awesome, it looks good! We might not be able to upgrade yet because we do have some solidity test files, so looking forward to the new version 😃.

Read more comments on GitHub >

github_iconTop Results From Across the Web

solidity - When to use "View" and "Pure" in place of "Constant"
To execute/call these pure or view functions from outside, no transaction is needed. Just a call is enough since the state of the...
Read more >
Solidity – Pure and View Modifiers – Blog - Avantrio
When you call the function viewExample it will read the contract storage and return the state and makes no changes to the state....
Read more >
Can a pure function depend on an external constant?
Yes, it is a pure function. Pure functions are referentially transparent, i.e. one can replace the function call with its result without ...
Read more >
Contracts — Solidity 0.8.17 documentation
They still can call other contracts, send them Ether and destroy the contract ... Pure functions are able to use the revert() and...
Read more >
Solidity - View and Pure Functions - GeeksforGeeks
The view functions are read-only function, which ensures that state variables cannot be modified after calling them.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found