5 Top Techniques for Testing Blockchain Apps
Blockchain applications aren't going anywhere anytime soon.
Join the DZone community and get the full member experience.Join For Free
The global blockchain market is expected to grow from USD 212.12 million 2016 to USD 8,682.82 million by the end of 2024, at a Compound Annual Growth Rate (CAGR) of 59.04% - ResearchAndMarkets.com
90% of major North American and European banks are exploring blockchain solutions - Accenture survey
Brief About Blockchain
The world these days is about virtual, digital, and cryptocurrencies in different shapes and sizes (read as rates and valuation respectively) that heavily rely on technology. The most commonly heard buzz is "Bitcoin," whose size and shape has been going through the roof.
Fundamentally, blockchain is easy to understand, but things start to look different once you start digging deep. A simple way to understand blockchain is by looking at it as a "block," a real-time ledger record with encryption and timestamp, and "chain," increasing the list of records with a link to the previous block. A blockchain is, thus, a decentralized database of blocks within a huge network of the distributed ledger, which keeps a track of size and shape of the underlying currency along with real-time access for sharing, mining, and flow of payments through a supply chain.
Lest it gets complicated, here's a simple example:
- John wants to send some cryptocurrency to Susan.
- John makes a request for the same (here a block is created) through a wallet or other available means.
- This request is then broadcasted within the huge network (containing decentralized ledger) for approval.
- Network approves the transaction (after the essential checks).
- The approved transaction (block) gets appended in the "chain".
- Susan gets the cryptocurrency credited in her wallet.
This series of activities is not under the control of a single person or an organization. It is open, secure, transparent, and driven by everyone as everyone in the chain can see the associated details of a block in real-time. Only the owner of the block can access/edit the block through a unique private key (which is with the owner only). All the events in the process mentioned above are reflected, updated and synced in the entire network in real-time.
Why Testing Plays an Important Role in Blockchain
As of today, BFSI and Automotive sectors are making the most of blockchain because of the secure and encrypted structure that the technology offers — especially with the associated currencies such as Bitcoin, Ethereum, Dash, etc.
Considering the stats mentioned above, along with the basic nature of blockchain applications, it is evident that blockchain testing and testers are going to play a crucial role in the overall growth and sustenance of blockchain.
From a technology standpoint, the entire process of blockchain needs to be thoroughly tested as any discrepancies found in one block or in the supply chain can potentially disrupt the entire blockchain. When a block is added to a blockchain, it remains there forever. Any changes to a block in the chain will make the associated blocks in the chain unacceptable or invalid. On the same lines, any updates by the owner of the block to one or more blocks in the chain will have a significant impact on the associated blocks in the chain, which needs a simultaneous update or fix. Any such change can't be parked or done later, which makes it even more complex in terms of testing.
Testing the applications built on blockchain can be complicated as not all blockchain technologies are open source. Some banking sector companies use private blockchain, which offers more privacy controls at the detriment of security and a hybrid of cloud computing and blockchain rolled into one.
5 Top Techniques for Testing in Blockchain Apps
With rapid changes to the technology suite, the idea of "specialized testing" is gaining more popularity. This kind of testing requires specific skills and a blend of technical and domain understanding. Having said that, the traditional or the most used common testing techniques still hold true to blockchain testing.
Let's look at the top 5 testing techniques.
Functional testing plays a crucial role in blockchain testing as it helps to assess the business circumstances, processes, and effectiveness of use-case scenarios. Some of the important components that tested as a part of functional testing are:
Block Size: as stated earlier, a block contains real-time ledger record with encryption and timestamp. These are groups of transactions which are confirmed and are then shared on bitcoin's public ledger (which is the blockchain). There is a lot of debate happening over the size of the block as the more size/transactions get attached to a block, the complexity of testing goes up. Most miners would love to have bigger block sizes (for obvious reasons) while the users and developers, on the other hand, are looking for better compression algorithms to fit the contents in the defined block size. Traditionally, blocks could carry up to 36MB (each) of transaction data but this soon introduced threats of spam and other service denial issues on the internet. The block size was thus reduced and fixed (apparently unanimously) to 1 MB apiece.
With changing complexities, underlying technologies and the ability to have multiple transactions inside a single block are pushing this limit to the maximum. The testers are now focusing on multiple questions such as "what if the transaction size goes over 1MB," "what tests should be considered if there are multiple transactions in a block," "what are the encryption rules associated and many more of such complex scenarios?"
Chain size: The chain size practically can be many blocks as the chain lengthens. Testers ensure that chains are not broken at the time of testing and complete record of every value transfer that has happened is tested under possible scenarios.
Data transmission: Testing around data loss during transmission is carried out in this phase as the peer-to-peer architecture of blockchain deals with data encryption at source and decryption at the receiving end. Testing for transmission ensures minimum data loss, improved process workflows between peers, and provides a scope for identifying integration possibilities.
Adding a block: Testers validate all the blocks that get added to the chain post authentication of every transaction. Since the chain cannot be altered and the block, which gets added can never be changed, testing at this juncture is very crucial.
Integration testing is important from the perspective of needing different systems to be cohesive. The deployment could be across several environments/systems running in parallel and ensuring that several component interfaces talk to each other seamlessly becomes important. A detailed view of all the touchpoints and the Application Programming Interfaces (APIs) are tested by the testing team to ensure that appropriate interfaces can be exercised during the validation phases.
Non-Functional Testing (Performance)
Performance testing in blockchain is important because of the number of transactions and transaction size being tested for the performance of a block, or an application to be deployed to production. The testing team also focuses on other important and dependent parameters, such as network latency, performance bottlenecks, the sequence of transactions at every node, dependency on the production environment, transaction processing speed, client/user and system interface, along with the responses required from the smart contracts. Since there could be multiple endpoints with compound testing, the end-to-end scenarios are considered for overall performance, which, in most of the cases, leads to an automated performance testing for the overall scalability of the blockchain ecosystem.
Non-Functional Testing (Security)
The primary focus here is to ensure that blockchain applications are tested thoroughly and to check if they are vulnerable to attacks (malicious, virus, etc.). If the authorization systems are robust and the authentications (including the accesses) are genuine, security testing considers the other important aspects, such as confidentiality, integrity, non-denial of services, Consistency/Availability, and collisions. Security testing becomes important in the event of hacking of identity layer, which may lead to transitions being exposed. A transaction, which is in progress, can't be stopped immediately, hence security testing needs to be effective to uncover all such potential identity layer hacks. Some of the other challenges associated with security testing include wallet signature methods, private keys, secure hash, consensus algorithm, application platform dependencies, etc. A defined verification and validation approach helps to deal with most of such inconsistencies.
Application Programming Interface (API) Testing
This type of testing reports about the communication and interactions of applications that happen to and fro within the system. Testers here validate the external responses that the application receives and ensures that the formats for the API request are correct and valid. Within blockchain, there is also a similar type of technology to APIs that allows a similar approach for testing APIs called smart contracts. Some of the popular API testing tools are Postman and SoapUI.
In one of the conversations between Bill Gates, Charlie Munger (Vice chairman of Berkshire Hathaway), and Warren Buffett (American business magnate, investor, and Chairman and CEO of Berkshire Hathaway), spectators got the mix of the uncertainty and potential surrounding Bitcoin and blockchain:
Bill Gates: "Bitcoin is a techno tour de force."
Charlie Munger: "I think it's rat poison."
Warren Buffett: "I think either Charlie or Bill is right."
Understanding the current application and implementation of blockchain is important, as it will help determine the growth path and probable challenges with the technology.
Published at DZone with permission of Hiren Tanna, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.