Private BlockChain Implementation on Ethereum — QA strategy (Testing Techniques & Tools for Essential components-EVM for Smart Contracts) — Part 4
In continuation to my last post, this post is going to be more interesting for those who likes to gets hand dirty to make concepts clear rather understanding theoretical concepts even I believe on the same. However, having some context before getting into action always helps. Now, there are lot of ways to test SMART Contract within test ethereum network locally. I will be explaining few of them along with how can same approach be utilized for any specific implementation of private blockchain on Ethereum platform.
Before dive into the action, first 2 components (EVM & SMART Contract) from last post ( Essentials Components of Private BlockChain) are compliment to each other in order to make blockchain platform programmable. Smart contract are nothing but just simple computer program which is designed to run on EVM. EVM makes Ethereum blockchain platform “Turing complete” machine which actually execute SMART Contract (same concept like JRE for Java application). If you design automated framework for testing smart contract then it will not only cover Smart contract testing but also EVM provided we are able to execute smart contract with its designed functionality. Now, question arises what should be the strategy for testing smart contract? To answer this question, I would like to explain how does testing of decentralized application built on ethereum start -
Testing of Decentralized application built on Ethereum platform -
Step -1 (Making Blockchain Network Up) : Very first steps to start testing over any blockchain platform or decentralized application, BlockChain network is supposed to be up & running. Now, question arises how to make blockchain platform up & running so there are plenty of tools & frameworks which comes with in-built blockchain network. Those network can be made up & running on any local environment. I have prepared youtube video ( Ethereum BlockChain Network setup on Window) to explain how ethereum test network can be made up & running on window machine. There are many tools available with ethereum blockchain network in built within those tools e.g. Truffle, Remix, Populus (specially for those who likes to use python), Exonum, Manticore, Embark & many more. Since I have used Remix, ethereum-tesrpc (now known as Ganache-cli) with Web3, Truffle tools & framework with Ganache-cli, Truffle with Quorum. In near future, I would like to give try to all of them to figure out which tools covers which components & functionality on blockchain network not only in simplest way but also up to which extent those are suffice enough to assure the quality. Since those tools also has integrated way to develop and test smart contract then these are become complete package to test from functionality standpoint. Smart Contract is the only way to design functionality on underlying blockchain platform.
Step-2 (Registering & Deploying Smart Contract on running Blockchain network) : As Smart contract are frequently being written in Solidity programming language, I will be covering tools which has end to end support for Solidity based smart contract not only for Developers but also helpful for Testers.. There are many tools available with test ethereum blockchain network in built within those tools e.g. Truffle, Remix, Populus (specially for those who likes to use python), Exonum, Manticore, Embark & many more. However I have used ethereum-tesrpc (now known as Ganache-cli) with Web3, Truffle tools & framework with Ganache-cli, Truffle with Quorum, Remix. In near future, I would like to give try to all of them to figure out which tools covers which components with not only in simple way but also extent to which it validate the smart contract.
Before selecting technique or tools for testing SMART Contract, we need to understand about ABI & Bytecode of smart contract. When we compile ( solc nodejs module is the compiler) smart contract written in solidity (*.sol where * is developer given contract name), it generates following 2 files ABI (*.abi) & Bytecode (*.bin). ABI stands for Application Binary Interface & it is used to store functions, arguments in JSON format on the blockchain. By using that information lot of user friendly end points can be configured. Bytecode is intermediate representation of smart contract in decimal numbers which eventually used by EVM Just-in-Time compiler to convert in machine code to execute requested functionality. ABI & Bytecode files are supposed to be registered & deployed on blockchain network by using available end points exposed by clients e.g. eth, geth (Go based), pyethapp (python based) for their respective blockchain. Web3.Js nodejs module which can be used to utilize these clients for interacting with blockchain nodes. Please refer following youtbe video to understand how any smart contract can be registered & deployed ( Registering & Deploying Smart Contract) by using web3.js with ethereum.
Step-3 (Execution of transaction through smart contract functionality deployed to Blockchain network) : Web3.js module uses all exposed functionality by eth, db, shh, net, personal, bzz, settings, version, providers etc. Within these functionality, there is another level of functionalities to process messages based on functionality within contracts, get information related to these functionalities like deployed contracts information, Blockchain related information, Block information, Hash rate, transactions, accounts, nodes, networks, peercount, listening port from nodes etc.
Selecting which technology & tool to be used for testing SMART Contract
It actually depends on the scope of testing defined by your customer. If you need to test only SMART contract then any tools mentioned above would be suffice enough to ensure the accuracy of SMART contract functionality. On the other hand if the need is to test complete Decentralized application built on Private blockchain then we need to cover testing of all the essentials components mentioned in Part-3 ( Essentials Components of private blockchain).
As per my experience Truffle (more information can be found onTruffle website) itseems to be the best choice at the moment. As Truffle is keep adding new feature to not only help developer but also tester to perform testing with more coverage and in automated way with little bit background on Java script programming along with understanding of Mocha-Chai framework.
Conclusion : If testing scope is to test only smart contract then any of these tools can be used with Ethereum to ensure that Smart contract is working as per defined business use cases. However if the need is to test complete Decentralized application then you need to wait until I cover all the essentials components testing. Eventually, I will collate together all technology & tools to have one generic strategy with identified technology & tools to have complete generic framework in place for testing of Decentralized application built on private blockchain.
For defining strategy for all components, stay tune for next post until then keep learning………..
BlockChain Evangelist & Enthusiast-Building Generic Automation Framework for BlockChain DApps for Ethereum at Startup
Originally published at https://www.linkedin.com on April 21, 2018.