How to debug and test Solidity

jwgcarlylejwgcarlyle Member Posts: 29
edited July 2015 in Solidity

I'm looking for some general tips in how to debug test non-trivial contracts written in Solidity. Here is what I currently use

1) - great for checking that a contract will compile

2) Alethzero - I'd really like to see more detailed documentation for this, specifically understanding / decoding the output from transaction calls (visible when clicking on a transaction sent to a contract in the blockchain view). I'd also like help decoding the internal state of the contract (visible when clicking on the Accounts tab and then selecting a contract).

3) Mix - latest Mac OS X build doesn't currently agree with 1) and 2), e.g. internal functions returning arrays of structs, but when building with an earlier version of Mix, it was very useful to set up scenarios, send transactions into the contract, query the current contract state via public functions etc. But now it seems to be less usable, and is lacking good documentation.

4) JS/web3.js front end, eg. AngularJS + Web3 - this is useful for querying state via public / external transactions, but doesn't give any line-by-line debugging facilities (and there is no println-like functionality that can be inserted). I have raised events and listened for them previously, but this is a heavyweight approach just to understand whether the internals are working correctly.

5) - I haven't tried this, although it looks impressive. It chokes on my Solidity code that compiles elsewhere, however.

6) or Embark - again, I haven't tried these, but like the idea of being able to unit-test contracts. But AFAIK, they still rely on black-box testing of external functions, so I'm not sure how to test internal functions.

I'd appreciate any other thoughts, particularly on how to test internal functions.

Post edited by jwgcarlyle on


Sign In or Register to comment.