trufflesuite / truffle-debugger

Core functionality for debugging Solidity files built with Truffle
67 stars 12 forks source link

Enable debugging tests #44

Open dmdque opened 6 years ago

dmdque commented 6 years ago

When debugging a transaction that occurred from a test, the following warning is given:

Warning: The source code for one or more contracts could not be found.

Is it possible to add the source code so the transaction can be debugged? If so, I can't find any mention of it. If not, then this should be a feature.

gnidan commented 6 years ago

Debugging tests is not currently supported due to a technical limitation. This is likely the reason for that error.

dmdque commented 6 years ago

What about debugging transactions from a testnet or mainnet with source code? I believe I saw a mention of it somewhere.

I don't know what the technical limitation is, so excuse the potentially naive question.

gnidan commented 6 years ago

Sorry, did not have bandwidth for a more detailed response the other day.

There are two main reasons behind why debugging tests is currently not supported:

  1. Truffle reverts Ganache after each test suite, so your transactions disappear (using the snapshot/revert feature) - this is not the issue you're facing, however.
  2. Truffle uses a temp. directory for your contracts for testing. This uses a separate truffle-resolver instance, and the artifacts don't completely match the ones in build/contracts/. This disparity is what I suspect to be the case of this issue.

We've been talking internally about this issue quite a lot, so please stay tuned as we plan to roll out better support for this obviously needed situation!

(Also, if you don't mind, can I rewrite this issue to be the central point of reference for debugging tests? Since I don't think there is one for that right now)

dmdque commented 6 years ago

can I rewrite this issue to be the central point of reference for debugging tests?

Of course.

Truffle reverts Ganache after each test suite, so your transactions disappear

This is a discussion for a different issue, but it reminds me of an issue I've encountered, where sometimes the blockchain state isn't reset. It tends to happen when ganache-cli is run separately somehow. I'll open another issue if I can figure out a more specific details.