Skip to content

Latest commit

 

History

History
executable file
·
96 lines (48 loc) · 2.68 KB

README.md

File metadata and controls

executable file
·
96 lines (48 loc) · 2.68 KB

Using Intellij Debugger for Truffle Testsuites

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.

Getting Started

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.

Prerequisites

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

The Files

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"

Applying the Settings

Inside of edit configurations, you will need to create a new run/debug configuration.

alt text alt text

Ensure that Command -> run, and Scripts -> test

alt text

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)

Running the Debugger

Now you should be able to run the project scripts and the following should be displayed in the console.

alt text alt text

Inside of the "test/TestIntellijDebug.js" file, you can see the following breakpoints and examine how it works.

alt text

Limitations

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.

Acknowledgements

Part of this example uses pieces of OpenZeppelin code.

Authors

[email protected]

https://80trill.com/