Currently when it comes to debugging smart contracts in Solidity, developers must use a plethora of tools to test and debug their code. Unfortunately this is less than desirable, as it can cause unneccesary friction and inefficiency in your workflow. By utilizing some of the configurations inside of Intellij, we have found a way to debug Truffle Javascript test suites inside of the IDE.
This will allow you to utilize the built in debugger.
As you can see inside of this example project, this will prove to be invaluable when it comes to testing smart contracts.
The following instructions will allow you to run a small test suite for demonstration purposes. There is certainly room for improving on the setup, but for now this will open the door to improving the development process for Solidity Smart Contracts.
This requires an up-to-date installation of the Intellij IDE, the Intellij-Solidity plugin, and NPM.
https://www.jetbrains.com/idea/
https://plugins.jetbrains.com/plugin/9475-intellij-solidity
Navigate to the project root and install the dependencies via NPM.
npm install
Here is the directory which contains the scripts used to run the debugger. As well as a modified "truffle-config.js"
"truffle-intellij-debug/scripts/setup.sh"
"truffle-intellij-debug/scripts/test.sh"
"truffle-intellij-debug/truffle-config.js"
Inside of edit configurations, you will need to create a new run/debug configuration.
Ensure that Command -> run, and Scripts -> test
Ensure that external tool "start testrpc" has Program -> Setup.sh, and Working Directory -> truffle-intellij-debug
(The relative paths where they are saved on your computer)
Now you should be able to run the project scripts and the following should be displayed in the console.
Inside of the "test/TestIntellijDebug.js" file, you can see the following breakpoints and examine how it works.
For the foreseeable future, the debugger only allows you to monitor variables inside of the Javascript test files. It cannot display the variables being stored in the .Sol files.
Part of this example uses pieces of OpenZeppelin code.