I recently started working on Ethereum Blockchain development. Most of the tools, including the solidity language are biased towards javascript. While I managed to get started using when it came to testing, I found that javascript tests were (IMO) unnecessarily too long. truffle But that is the nature of the language. I have always been more comfortable with python than JS. I liked and have used in my previous projects. So when I had an option to test my smart contracts using , I definitely was gonna give it a try. py.test py.test That is when I came across . Turns out it aims to be “truffle for pythonistas” (my words, not the “official” tagline, but they can use it.) populus Initially it was a personal project — which was officially adopted by ethereum organization (on github) adding credibility to the excellent work done so far. You can read the official documentation here Testing As I mentioned earlier, I came for the chance to use for testing the smart contracts. py.test Writing the tests (along with ) was quite easy. web3.py Running the tests in not (like ). As I mentioned earlier, it is via . So it is populus test truffle test py.test py.test <folder_containing_tests>/ .. and this is where I ran into a “glitch”. Turns out there is a known and a issue solution One thing I liked about using was that I did not require to start py.test explicitly testrpc For testrpc or is required to be run explicitly. Else you get the following error: truffle test geth $ truffle test Could not connect to your Ethereum client. Please check that your Ethereum client: - is running - is accepting RPC connections (i.e., "--rpc" option is used in geth) - is accessible over the network - is properly configured in your Truffle configuration file (truffle.js) I’m not saying that there is anything is wrong in that, just that it is nice to omit a step. Local Chain(s) One more nice feature has over is the ability to create local instance. populus truffle geth This can be done easily with populus chain new <chain_name> This does several of the following things : Creates a (Usually one needs to create this by hand, or copy an existing one from “somewhere” and modify) genesis.json Creates one account, that has enough balance. Creates two scripts : One to creates genesis block( ) and other to start the “node” ( ) init_chain.sh run_chain.sh Benefit of this is that a new developer does not need to understand the complexities of various options in both and the long list of command line options to genesis.json geth It just works. This is useful to semi-experienced developer as well. She can modify the and the scripts as required. genesis.json Since there is no “change password” concept, one can not create a “better” password without removing the existing account and recreating a new one. This means you need to modify the script, since it mentions an account for the parameter. One also needs to modify since the “pre-populated” account is mentioned there under . run_chain.sh --unlock genesis.json alloc But that is OK, since is meant for the development anyway. populus Read the detailed tutorial about using populus to create local chains here There is also _populus chain reset <chain_name>_ but it doesn’t work. I’ve filed an issue here Deploying the Contracts For simple, one-off contracts, there is a command line version : populus deploy For a slightly complex deployments, especially when one needs to pass arguments to the Contract constructor, one needs to write their own python code. This is no different than writing migrations scripts in land, except there one gets “default” scripts on , here we don’t. truffle truffle init Read details here Migrations had this feature in older version, but it was removed. when asked on gitter, I was told that there is a plan to “bring them back” See populus this Should I ditch truffle ? Not yet. While I wanted to use as the only option, I think it is behind the “maturity” compared to populus truffle For now, I use for the project I share with others (since seems to be more “well known”) but for my “personal” project, I will continue to use (and report issues, discuss on gitter and send in the PR if/where I can) truffle truffle populus : You can view my (work-in-progress) code . It has both as well as config files. The tests are only in python. I do have a deployment script in python. Note here truffle populus Originally published at mandarvaze.bitbucket.io on March 20, 2018.
Share Your Thoughts