The ins and outs of testing blockchain apps
Testing blockchain applications is a unique challenge with its own technical and theoretical underpinning. Learn more about the essential tools and techniques that are specific to blockchain app testing.
While blockchain is often discussed in the context of financial services and cryptocurrencies, this technology has a much broader range of potential applications. That’s why blockchain-enabled technologies are becoming more prevalent. Just one of such technologies, a smart contract is a digital protocol that allows entities to exchange information with no intermediary in a way that’s both trackable and verifiable.
This creates endless possibilities for business. AXA Insurance processes payouts through blockchain. The country of Georgia uses blockchain to verify and store land property rights. Projects such as MicroGrid in Brooklyn even use blockchain to control electricity consumption and availability.
All of these and many other viable implementations push the adoption of blockchain even further. This hype and pressure driven by success stories only intensify other businesses’ FOMO – the fear of missing out. That is, missing out on the benefits of using blockchain. It pushes many companies to head into blockchain projects hastily. And this is where problems usually start.
SEE ALSO: Top 5 development tools for Ethereum
With the relative novelty of the technology, many development teams still don’t have experience with blockchain-based applications. Additionally, advanced skills in the domain are scarce and costly. That’s why Gartner lists technological failures among the threats to blockchain adoption
How can companies mitigate these risks? The answer may be straightforward, while the execution requires a lot of work. This answer is blockchain testing.
Testing a blockchain-based app or another type of software comprehensively and rigorously ensures its quality and minimizes the risks associated with the lack of skill or experience in developing blockchain products.
At the same time, testing can help to mitigate the colossal cost of error since the very nature of blockchain makes it impossible to amend data that has already been recorded. For example, the Bitcoin base layer transactions are irreversible and final. Imagine not being able to make a chargeback on a fraudulent transaction through your bank? In short, blockchain testing is like making sure that every transaction in all of the bank’s history is legitimate, in advance.
In this article, we’ll take a look at the specifics of blockchain app testing. Given the nature of current blockchain applications, many of the concepts and ideas will steer towards cryptocurrencies. Yet they can easily be applied to other domains.
The basic tools for blockchain testing
Testing is all about the tools, especially when it comes to testing blockchain-based applications. If you don’t have a proper setup and the right tools, you’re likely to fail.
There is a massive variety of tools that you can use for testing. They vary depending on the applications and the blockchain platforms you use. What follows is a mixed toolset, with a focus on Bitcoin and Etherium tools for testing. Let’s start with the basics.
Testnets for blockchain: Think of them as alternative versions of the actual blockchain, a system that resembles the original but on a much smaller scale.
Ethereum Testnets: There are many options in this category. We recommend taking a look at three of them: Ropsten, Kovan, and Rinkeby. Ropsten is the preferred choice because of its architecture, as it closely resembles the live Ethereum mainnet. As a trade-off, it’s less stable since its authentication method is similar to that of Ethereum and is therefore susceptible to spam attacks. Kocan and Rinkeby are better in this regard. However, they support smaller chain data sizes and can’t support actual mining of ether, which can affect the testing routines.
Blockchain testing frameworks
There are some specific frameworks to help you test blockchain-based applications. Most of them will allow you to run everything locally and have full control over most of the activities in the network.
Ethereum Tester is a pretty straightforward testing library that’s available as a Github repo. Since it’s open-source, the setup is relatively easy, and it has a decent API support for forks (Homestead, DAO, etc.) mining, as well as other testing-critical functions.
BitcoinJ is an excellent Java-based framework for Bitcoin-based apps as it allows you to interact with the real BTC network and test transactions. You don’t even have to download the standard BTC Core files from Bitcoin.com to start using it. There’s also a user forum if you’ll find yourself in a tricky situation, where you can always ask for help.
Populus has Ethereum testing functionality baked in in the form of a specific set of features for test contract deployment. It’s built around the py.test framework, which makes it easy to implement.
Truffle is a household name for Ethereum developers, with many great testing features in place, such as automated contract testing. It is a robust framework beyond just the testing functionality, so definitely check it out as your starting option for development.
Embark is a framework that’s focused on development of dApps (decentralized applications) that run on multiple nodes orcomputers. Embark has integrations with Ethereum blockchain, IPFS, and a couple of decentralized communication platforms (Whisper and Orbit).
IBM Hyperledger is an open source tool that allows you to model and test your blockchain network with a minimal set of tools: Docker and a browser. It’s done through Hyperledger Composer, which is a framework for facilitating blockchain app development consisting of a modeling language, a UI (Composer), and a command-line interface. It supports automated system tests, interactive testing, and automated unit tests.
It’s also important to mention that there are enterprise-scale BaaS (blockchain-as-a-service) vendors that offer testing capabilities as part of their service package. There are decent options available, but some of them may be quite taxing on your budget. So just be aware of that. In this category, it’s worth mentioning SAP Blockchain, Blocko, Blockstream, and Peer Ledger.
Standard testing types for blockchain
Now that you might have a basic idea about the types of environments that are used for blockchain testing, it’s crucial to learn more about the actual tests and some of the testing standards.
Below are the most basic types of tests to be performed on any blockchain application. These apply to testing applications in general, but we’ll try to elaborate on why they’re especially crucial for blockchain apps.
Functional tests: it’s highly likely that your blockchain product is entirely unique in some regards, given the limited scope of today’s applications for blockchain technology. It’s possible that you’re doing something that hasn’t been fully implemented in blockchain before. Here, functional testing will be your ‘sanity check’ to make sure that everything works properly.
Security tests: blockchain truly shines in financial and banking applications. For them, it’s important to test authentication and authorization methods. Their ability to withstand attacks of various malicious origins is crucial for their stability and security.
Integration tests: your blockchain app will work in multiple environments with various systems integrated, for example, a customer-facing UI. So it’s essential to test the performance and solidity of these inter-system connections.
Contract tests: making sure that the automation behind smart contracts works flawlessly is another thing that can make or break your blockchain application.
Performance tests: testing the size of the network and its ability to process transactions is critical, as it allows you to identify hardware and software bottlenecks in advance. This can also help you figure out the potential costs of running the application in the cloud or other environments.
Peer & node tests: verifying that there’s a consensus between nodes and that transactions are correctly sequenced within the network will ensure its stability and productivity for the end user.
Some of these testing scenarios can be summed up by simple questions or user stories that you can apply in the process. What happens after an invalid input? How does the application processes a large stream of varied (valid/invalid) inputs? How does it handle erroneous behavior or execution faults? How does it maintain and verify access?
None of the testing in the world matters if you can’t replicate real-world conditions in the process. That’s why, apart from all the testing routines and technology, you have to engage subject-matter experts during the testing phase. This could be your business people or front-end engineers who are essentially customer-facing developers. They know the expectations from the user experience perspective.
Don’t be shy to look for outside help. It’s unreasonable to rely solely on your resources with such complex technology, especially if you’re making something ambitious. This might be your first blockchain application, but there are QA consultants that have extensive experience in testing, blockchain development, and blockchain testing specifically. Their existing domain expertise may be the crucial ingredient for the project’s success.
To a certain extent, you’re making a leap of faith by venturing into the blockchain world. And we salute you for that because it offers immense capabilities that aren’t even fully explored yet. While the technology is relatively new, the theoretical foundation for testing it is the same as for any other software product. So don’t be afraid to make mistakes. That’s what testing is for.