Specifics of testing blockchain-based apps
Blockchain is a popular and technically complicated subject. Initially the technology was created to serve the Bitcoin cryptocurrency. However as time went by the sphere of the blockchain application widened.
Today any product that uses database can be migrated to the blockchain.
However, it goes without saying that any product should be thoroughly tested before going live. In this article, we focus on testing of the decentralized blockchain-based apps.
Before getting down to testing peculiarities and recommendations, look through the list of terms you’ll need to get a better understanding of the article.
- Block is a piece of code that contains a list of transactions. The first block in the chain is called the genesis block.
- Blockchain is a constantly growing chain of blocks. The copies of the chain are stored on a number of computers (nodes) that partake in the network.
- Cryptocurrency is digital money with no physical equivalent.
- Bitcoin is a digital payment method and the most popular kind of cryptocurrency these days.
- Ethereum is the second most popular cryptocurrency with the large market capitalization (second only to Bitcoin).
- Fork is a change to the blockchain protocol that results in a chain split into two chains that will function independently.
- Mining is the process by which transactions are verified and added to the blockchain, and also the means through which new Bitcoin are released.
- Fee is the commission miners get for verifying a transaction and adding it to the blockchain.
- Smart contract is the protocol that digitally facilitates the negotiation or performance of a contract.
- Faucets are websites that give away small portions of Bitcoins for free.
Blockchain: what’s in this word for a software testing engineer?
In the first place, the blockchain is the software functionality. In 90% of cases it’s a type of a payment method.
Accordingly, tests should be almost the same as an engineer runs when testing the payment gateway system: transaction process verification, testing all payment components, checking whether additional requirements are met (e.g., terms of a smart contract) and no double-spending opportunities exist.
Three aspects to consider before starting testing blockchain-based apps
1. Specific testing environment
All transactions executed in the blockchain change its current state. In order to add or change any entry, miners’ resources are required. Miners, as you remember, charge fee for verifying a transaction and adding it to the block. That’s why it may appear to be too expensive to perform tests in the live environment.
On one of the a1qa projects, the execution of a single bitcoin transaction cost several hundred USD.
Employing a testnet for running tests will help to avoid losing money and cut down on QA costs. Testnet coins have nothing to do with the actual ones and testers get an opportunity to experiment with the application without being worried of breaking the blockchain.
The team may set up their local testnet or use one of publicly available. For Ethereum-based apps, the Ropsten Network can be used. It uses the same protocol as Ethereum does and allows to get free coins from a pool of the Ethereum faucet. Instantly.
And do not forget to return the left coins to the faucet website. This is the matter of courtesy.
Also keep it in mind that even if you prefer to use the testnet, you will also have to deal with miners who validate transactions in the network. However, they are not that numerous in the testnet as comparing to the real network. So it will take more time to validate the transaction.
To speed up testing, you can set up several virtual networks and start mining yourself. It will take less power than verification of real cryptocurrency transactions.
2. Transactions are irreversible
All blockchain-based apps are decentralized. This is the main idea behind them. Decentralization means that the app resides on numerous computers and its code can be accessed by anyone. As there is no central server, 99% of failures, errors that made it to the blockchain can not be reversed.
Knowing this, it becomes extremely important to make sure all transaction details are correct before sending them to the network. Any missed defect will be a critical one.
It makes the testers’ job even more responsible.
3. All transactions are paid
This point correlates with the first one. The tester’s task is to guarantee the mistake-free process of the transactions adding and processing in the network. However, as any transaction in the blockchain requires the fee, it makes testing process rather specific.
If you test in a real Bitcoin network, remember that besides the input itself, you’ll have to pay to miners to get your transaction processed.
In Ethereum, every transaction a certain number of gas, which is the special currency used in the network. Operations that require more computational resources cost more gas.
It’s also important to know the difference between the gas cost and gas price.
The gas cost is the amount of work that goes into something (e.g. the number of hours of labour). The gas price is similar to the hourly wage you pay for the work to be done. The combination of the two determines the total transaction fee.
Remember: if the gas price is very low, no one in the network will process it.
What types of testing are relevant for blockchain-based apps?
As we’ve already mentioned, testing of the blockchain products slightly differs from testing payment apps and looks like a functional testing of the payment gateway system.
Test plan will take into account the predefined requirements from stakeholders.
A software engineer should consider the requirements and think creatively to generate test ideas and cover the most improbable user scenarios.
High quality of the final product can be assured through the following standard testing types:
Functional testing will help to understand whether all the functional requirements have been implemented by the dev team.
Load testing will help to determine the capacity of the system that directly interacts with the blockchain.
Security testing. The blockchain is anonymous. Any holder of the private key will have access to the wallet and the right to sign the transactions. The system of keys storage and encrypting is yet vulnerable to security attacks. Pen testing will help to identify and eliminate the bottlenecks.
What tools will you need for testing?
The selection of the right testing tools is the first step to successful and effective testing. This is the list that might be considered by those who’ll have to ensure the blockchain-based apps:
- Testnet indexing tool. For example, the website ropsten.etherscan.io allows to check the real-time wallet balance and the detailed information on any transaction.
- Bug and test tracking tools.
- It can be required to set up a local node for the given blockchain. There are various tools with comfortable UI that will help doing this.
- API testing tools (Postman, soapUI).
- Database testing tools.
- Encoding and encryption software.
Will blockchain-based apps benefit from test automation?
Like on any other testing project, decentralized apps can be tested automatically.
What is more, given the sheer number of nodes and combinations that are likely to take part, automation of testing becomes an important need.
Test results can be easily compared by analyzing the real information in the network or sending requests to the testnet indexing website.
How to choose the testing team?
Not so many QA teams can boast of having worked with the blockchain technology. However, the following testing capabilities can compensate for the lack of experience: good knowledge of the customer’s domain, analytical mindset, skills in reading the code and pseudo code.
The tester that will be involved in testing the blockchain apps should follow the development of the technology, its forks and be good at numbers. Yes, there will be a lot of counting job with the blockchain verification.
Afterword
The technology of blockchain catches on and more and more industries open up its opportunities.
Considering the scale of its application, the growing level of users’ competence and the critical status of defects that get into the network, testing must be viewed as an integral part of the development lifecycle.
Book an obligation-free consultation by the a1qa pros and learn how our solutions will help your product hit the mark.