Blockchain Testing Methodology
Tags: blockchain, testing
Published: 2021-05-31 12:47:25

### **What is 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. Blockchain is a distributed ledger, which is validated among different business peers. This ledger further acts like an immutable audit log.
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1622456729475/Dw-dG0_qL.png)
*Image courtesy of testingxperts.com*

### **Blockchain Feature**
|BLOCKCHAIN LEDGER|Value|
|:-:|:-:|
|![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1622454284233/2uX-tvT4f.png)| ![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1622454302175/8vjhlOEpD.png)|
|Decentralized| Trust |
| Immutability | Auditability |
| Consensus Mechanism | Security |
| Smart Contracts | Automation |
| Fault Tolerant | Availability |

### **Different Types of Blockchain**

| Public | Consortium | Private |
| --- | --- | --- |
| Public, Permission less Blockchain | Federated, Permissioned Blockchain(Single or Multi-Industry) | Private, Permissioned Blockchains |
| Allow access to any user at any time, ledger management is facilitated by the distributed network (e.g. Bitcoin, Ethereum) | Allow access to users based on the rules defined by the group of entities (consortium) participation in the network, ledger management is facilitated by the consortium (e.g., Ripple, R3, Corda | Allow access to users based on the permission set by the private network, ledger management is facilitated by single company for private use (e.g., Chain, Supplychain, Bankchain) |
| | Permissioned by many | Permissioned by one |
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1622452137569/KYwNP8gaR.png)

### **What does it mean for testing?**

Challenges in Testing the Blockchain

- **Understating the technology** <br>
Blockchain is a relatively new technology
- **Lack of Blockchain Testing Tools**<br>
Picking up the right tool as per the application is a crucial decision<br>
- **Lack of Best Practices**<br>
New Technology, lack of experience to test blockchain application
- **Defining the Test Strategy**<br>
Requires a deep understanding of the application
- **Addition of Blocks**<br>
Validate all the blocks that get added to the chain post authentication of every transaction
- **Block and Chain size** <br>
A block contains real-time ledger record with encryption and timestamp <br>
The chain size can be many blocks as the chain lengthens
- **Transmission of Crypto-Graphical Data**
- **Integration Testing**<br>
The key responsibility is to ensure that the response from all interfaces is consistent and there are no disconnects
- **Security Testing**<br>
Human-related risks<br>
Risks with private and public key<br>
Vendors Risks and Untested code<br>
Lack of Standards and Regulation
- **Performance and Load Testing**<br>
Focus on:<br>
Network latency<br>
Performance bottlenecks<br>
The sequence of transaction at every node<br>
Transaction processing speed<br>
Client/User and system interface<br>
The responses required from the smart contracts


### **Why existing Testing solutions are inadequate?**

**To the best of our knowledge** there is no defined process or approach used for testing Blokchain solutions that covers all the dimensions or complexities of Blockchain implementations.

**Adhoc testing methodologies** an processes are used that may leave Blockchain systems immune to defects and production failures. Our proprietary methodology covers all the aspect of testing requirement for a production grade implementation.

Testing approach should not be platform specific. Client&#39;s solutions which are built on existing blockchain platforms should not focus extensively on technical features which are applicable for the specific platform. For example, the way a DLT platform stores users&#39; credentials is not something that need to be tested. It&#39;s the platform&#39;s responsibility to provide these kind of warranties for their software. However, when using 100% open source platforms we do need to do this level of testing.

### **Testing Decentralized Solutions**<br>
**Traditional V-Model Test**
![v-model.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1622461603428/LE1KjvvGj.png)

**Adopted for Blockchain (Verification and Testing)**
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1622451907347/giMTrvAtE.png)

### **Blockchain Ecosystem**

Elements that should be considered while planning the QA approach:

**1.Standard Testing &amp; Validation**
- **Functional Testing**<br>
Testing of individual components and system including User Acceptance Testing
- **Integration Testing**<br>
Interfaces between components and different parts of the system which can be on different environment

**2.Non-Function Testing**
- **Security Testing**<br>
Testing for confidentiality, integrity, authentication, access, and authorization are critical components of security
- **Performance Testing**<br>
The performance and latency vary with the size of network and size of transactions

**3.Testing specific to Blockchain**
- **Peer/Node Testing**<br>
The strength of the blockchain lies in having the shared ledger be exactly the same at each and every node
- **Smart Contract Testing**<br>
Software modules on the blockchain that automatically execute transactions based on pre-defined conditions.


**Blockchain Testing Considered (Specific in the Blockchain solution testing to be considered.)**<br>
**Blockchain Transactions**
- **Transaction processing**<br>
Validation of transaction lifecycle through Apps / Vaults / Wallets
- **Transaction State / Event**<br>
Proof of distribution<br>
Basic data model for Blockchain<br>
Validation of event notification
- **Vault / Wallet** <br>
Validation of Transactions message verification (signing)<br>
Common trusted database<br>
Storage algorithm<br>
Extensive testing of wallets or hashing algorithms in enterprise blockchain would be more required on 100% open source / permission less solutions

### **Blockchain Governance**

- **History &amp; Audit**<br>
Validation of secure registry and audit of transaction<br>
Immutable record<br>
Secure Identifications of assets
- **Consensus Mechanism**<br>
Consolidated consistent dataset<br>
Various consensus models (PoW, PoS, Byzantine FT)<br>
Transaction timestamping
- **Smart Contract**<br>
Validation of business rules through Smart Contracts:<br>
Self-enforcing contracts<br>
Digitized analog contracts<br>
 Real-time auditing of transactions

### **Blockchain Platform**

- **Interaction with APIS**<br>
Validation of interface with API&#39;s for access control payments, track and trace and balances.
- ** Key &amp; Identify Services**<br>
Consortium or private blockchains<br>
Public blockchains<br>
Validation of tokenization of assets
- **Blockchain Applications**<br>
Web Application<br>
Native Application<br>
Wallet / Vault Applications

Blockchain testing part of a knowledge sharing platform to leverage up to date information about blockchain and QA. Leverage testing methods and techniques that has been generally accepted and proven in real project. Collaboration between business, developers and QA teams to achieve best possible result.

Reference: https://community-z.com/events/qa-z-days-2020/talks/3929