As blockchain technology continues to transform industries with its promise of decentralization and transparency, the foundational layer of this technology, known as Layer 1 (L1) blockchains, plays a critical role. L1 blockchains provide the necessary infrastructure to build and operate decentralized applications, hosting the protocol and consensus layer fundamental to the entire network. Here, we describe for developers and QA testers how we approach testing Layer 1 blockchains built with EVM and Cosmos to reduce immutability, financial exposure, systemic risks, boundary complexity, cryptoeconomic attacks, and adversarial environments.
Layer 1 blockchains, like any software, always need to be tested before deployment. But testing a Layer 1 blockchain requires a very different mindset to approach QA strategy and test plans since bugs can't simply be patched after deployment and these bugs can cause catastrophic outages and significant investment loss. Here, we describe the best practices we use to approach Layer 1 blockchain testing to reduce immutability, financial exposure, systemic risks, boundary complexity, cryptoeconomic attacks, and adversarial environments.
This article is a comprehensive guide tailored for developers and QA testers aiming to master the intricacies of testing L1 blockchains built with EVM and Cosmos. We will delve into the necessity of testing these foundational systems, exploring various types of testing including functional, performance, and smart contract testing. Additionally, we will provide a step-by-step guide on conducting efficient L1 blockchain testing, from setting up the testing environment to implementing automation and leveraging modern test frameworks. By the end of this guide, you will gain a deeper understanding of strategies and tools essential for ensuring that you have robust, secure, and scalable blockchain solutions.
A Layer 1 (L1) blockchain is the base layer of a blockchain network that provides the fundamental infrastructure for decentralized transactions and applications. It handles transaction validation, consensus, and security directly on its protocol.
Examples:
Layer 1 blockchains serve as the foundational networks upon which other layers and applications rely. These blockchains maintain the protocol rules, consensus algorithms, and network architecture essential for transaction validation and data recording. EVM-based blockchains, such as Ethereum, offer robust environments for decentralized application (dApp) development through smart contracts, enabling automated and trustless transactions. In contrast, Cosmos leverages a modular approach with its SDK, facilitating the creation of sovereign blockchains interoperable within a wider ecosystem via the Inter-Blockchain Communication (IBC) protocol.
EVM and Cosmos represent different approaches to blockchain architecture, but have developed significant interconnectivity. While EVM-based chains like Ethereum use a single shared execution environment where all applications compete for resources, Cosmos creates specialized, sovereign blockchains optimized for specific applications. However, Cosmos bridges this architectural gap through EVM-compatible zones like Evmos and Cronos, allowing developers to deploy Ethereum-compatible smart contracts within the Cosmos ecosystem. These zones benefit from Cosmos's scalability and interoperability while maintaining compatibility with EVM tooling and libraries. Through IBC, Ethereum assets and data can flow between Cosmos chains, and solutions like Gravity Bridge facilitate direct communication between Cosmos and Ethereum mainnet. This relationship provides developers flexibility to leverage the security and network effects of Ethereum while accessing Cosmos's sovereignty and interconnection capabilities.
The complexity and security demands of L1 blockchains necessitate rigorous testing to ensure their functionality, security, and resilience. Testing is vital for identifying and mitigating vulnerabilities, ensuring that the consensus mechanisms operate flawlessly, while optimizing performance under various conditions. With financial transactions and critical data processing at stake, any flaw can lead to significant economic losses, data breaches, or network outages. Thus, comprehensive testing not only safeguards the blockchain's integrity but also builds trust among users and developers and is vital to prevent catastrophic failures. For instance:
Solana Network Outages (2022): Repeated crashes under high traffic highlighted the consequences of insufficient stress testing. Simulating real-world transaction loads pre-launch could have improved network resilience.
The DAO Hack (2016): A reentrancy vulnerability in Ethereum’s DAO smart contract, undetected due to inadequate adversarial testing, led to a $50M theft and forced a chain split. Rigorous audits could have identified the flaw.
BSV 100-Block Reorganization (2021): Bitcoin SV (BSV) experienced a massive 100-block reorganization attack when an attacker took advantage of its increased block size. This protocol-level vulnerability showed inadequate testing of consensus security with larger blocks, a fundamental parameter of the blockchain.
Polygon's Heimdall Bridge Critical Bug (2021): A vulnerability in Polygon's Heimdall bridge (core infrastructure for the Polygon blockchain) could have allowed an attacker to drain all funds. This was a critical bug in the consensus mechanism of a Layer-2 solution, showing inadequate formal verification of bridge consensus.
Solana's Durable Nonce Bug (2022): A protocol-level bug in Solana's transaction processing caused inconsistent behavior between validators when handling durable nonce transactions. Some validators accepted resubmitted transactions while others rejected them, creating a network fork and 4.5-hour outage. This was a fundamental consensus-level issue that better transaction edge case testing would have caught.
These cases demonstrate that comprehensive testing at the blockchain protocol level is critically important, far exceeding the significance in traditional software development. Addressing six key factors in a test strategy and plan could identify bugs early and prevent outages and attacks described in the cases above:
These factors collectively create an urgent need for rigorous, comprehensive testing of blockchain protocols.
Depending on the development stage of the L1 blockchain, various tests will be carried out step by step.
This type of testing ensures every feature of the blockchain works as intended, including negative and positive tests. It covers several critical aspects.
Verify that the consensus protocols are functioning correctly in maintaining agreement across the network. Also be sure to test for common scenarios where nodes might deviate due to bugs or malicious attempts.
Node sync testing ensures that nodes in the network can synchronize and share data without errors. Further, this testing evaluates how efficiently and accurately a node can sync with the rest of the network, from the initial block to the current state. It involves validating the complete download and verification of blockchain data, assessing the time taken for a node to sync under various network conditions, and ensuring that the node remains fully operational and accurate throughout the process. Additionally, node sync tests should cover scenarios involving network interruptions or bandwidth limitations, examining how well nodes can recover from or adapt to such disruptions.
Ensure that the RPC module is working as expected for EVM and consensus layer endpoints of all genesis validator nodes, including request and response schema validation as well as response status code validation.
Be sure to test the blockchain’s ability to recover from node downtime or failure. You can do this by simulating node crashes and examining recovery procedures, ensuring that the network sustains its integrity and performance after such events.
Staking is the process by which validators lock up a certain amount of cryptocurrency to secure the network and validate transactions. Test the staking mechanism by validating that users can stake and un-stake their assets correctly, verifying that the staking balance updates accurately, and ensuring that the staking process respects consensus rules.
Slashing serves as a deterrent for malicious actions, such as double signing or prolonged downtime by validators. When you test slashing mechanisms, you’ll want to simulate scenarios where validators engage in unauthorized activities or fail to meet performance criteria. It’s important to ensure that penalties are transparent, proportionate, and deter harmful behavior without affecting network reliability. To do this, you’ll need to test the accuracy of slashing scripts and their ability to execute penalties precisely under different conditions.
Validators and stakers are incentivized through rewards, which must be distributed fairly and accurately. To test rewards distribution, validate the calculations for reward payouts based on network contributions and ensure that transaction fees and newly minted tokens are allocated correctly. Testers need to simulate various stake distributions and network activity scenarios to ensure reward mechanisms function as expected, even during forks or network upgrades.
WebSocket is commonly used to facilitate real-time communication between clients and blockchain nodes. Usually the WebSocket method is called periodically to monitor whether the communication is connected.
Testing the Cosmos API is particularly relevant for blockchains that are built on the Cosmos SDK or are part of the Cosmos ecosystem. Functional testing, in particular, verifies that the API behaves as expected and meets the requirements stipulated in its design. Similar to regular API testing, it covers all possible combinations of required and optional parameters, the limits of data inputs, especially the API related to staking, which may be customized or modified by different L1 chains.
Upgrade testing ensures the blockchain can handle new software updates without disruption. The test focuses on validating both soft fork and hard fork upgrades, each presenting unique challenges. A soft fork, which is backward-compatible, requires testing to ensure that nodes running older versions continue to operate correctly with upgraded peers, maintaining consensus without disruption. Conversely, a hard fork necessitates a complete protocol change, where nodes must adopt the new rules to remain part of the network. Testing involves simulating the upgrade process to ensure that nodes transition smoothly from the old protocol to the new one, without data loss or service interruption.
For Ethereum, upgrades typically involve a coordinated approach where nodes are incrementally updated using a rolling upgrade strategy. This strategy enables gradual adoption of new protocol changes, minimizing disruption by upgrading subsets of nodes one at a time. This process allows for verification and testing of each updated node, ensuring stability and consensus across the network. Rolling upgrades are particularly effective in large decentralized networks like Ethereum, as they prevent network-wide outages and facilitate smoother transitions.
In contrast, Cosmos employs Cosmovisor for its upgrade process. Cosmovisor is a lightweight process manager designed to automate the upgrade of blockchain applications built using the Cosmos SDK. It efficiently manages and transitions between different versions of node binaries. By using Cosmovisor, node operators can reduce downtime and error risk during upgrades, as it automates key aspects of the upgrade process. Cosmovisor is particularly beneficial for managing upgrades within the diverse and multi-chain environment of Cosmos, ensuring seamless transitions and maintaining network stability.
This type of testing focuses on key metrics such as throughput, typically measured in transactions per second (TPS), as well as transaction latency and overall resource utilization including CPU, memory, and network bandwidth. The objective is to assess the blockchain's scalability, reliability, and robustness under various load conditions.
Load testing is an essential process for understanding how a L1 blockchain handles a large volume of transactions and interactions under normal and peak operating conditions. Simulate continuous real-time batch transaction concurrency, monitor CPU and memory, and analyze and evaluate test results to determine the network's capacity and bottlenecks in real scenarios.
Since smart contracts automate processes within the blockchain, testing ensures they operate flawlessly and securely. (Learn more about smart contract testing.)
This section serves as your starting point in the blockchain testing journey, offering detailed guidelines and methodologies to help you understand the intricacies of testing within a blockchain environment. You can expect to learn how to set up a realistic test environment, formulate a robust testing strategy, and implement automation tools effectively. Our aim is to equip you with the knowledge needed to perform thorough assessments of your blockchain's performance, security, and stability, ensuring a reliable and efficient deployment.
The diagram below illustrates a streamlined workflow for testing and deploying blockchain networks using GitHub Actions and CI/CD integration. It consists of two key loops and five distinct stages. The five distinct stages are:
The two loops represent automated workflows for managing dev networks during release creation and pull request (PR) merges, ensuring efficient testing and validation processes.
The test framework is designed to validate and analyze blockchain-related functionalities, integrating multiple components to enable a comprehensive testing workflow.
Prerequisites:
Modules:
package.json
to define and manage the project's dependencies, ensuring that the testing environment is consistent and reproducible across different setups.The blockchain industry has learned expensive lessons from failures like the DAO hack and Solana's outages. These incidents highlight a fundamental truth: traditional software testing approaches are insufficient for blockchain systems where bugs can't simply be patched after deployment.
Testing L1 blockchains requires a fundamentally different mindset. You're not just testing code–you're validating economic models, consensus mechanisms, and systems that handle real financial value. The six-factor risk model we described earlier (immutability, financial exposure, systemic risks, boundary complexity, cryptoeconomic attacks, and adversarial environments) makes comprehensive testing non-negotiable.
The testing pyramid we've outlined–from functional testing of consensus algorithms to performance testing under load–provides a practical roadmap for any L1 blockchain project. Whether you're working with EVM-based chains or Cosmos SDK implementations, the core principles remain: test early, test thoroughly, and automate everything possible.
Your testing environment should mirror production conditions as closely as possible. Use CI/CD pipelines to catch issues before they reach mainnet. Simulate network failures, test upgrade mechanisms, and validate economic incentives under stress.
Blockchain testing isn't just about preventing bugs–it's about protecting user funds and maintaining network integrity. The cost of comprehensive testing is always less than the cost of a single major failure. As the industry matures, robust testing practices will separate successful projects from cautionary tales.
To help teams put these principles into practice, in coming months, we will be releasing an open source blockchain testing framework, ChainSmith. ChainSmith is 57Blocks’ new open-source framework and managed-service offering for chain-layer reliability testing. It lets us and our clients describe complex, real-world failure scenarios and run them automatically on L1 devnet/testnet.
https://docs.cosmos.network/
https://docs.cosmos.network/main/build/tooling/cosmovisor
https://docs.cometbft.com/v0.38/
https://geth.ethereum.org/docs
https://docs.ethers.org/v6/
https://web3js.org/
https://viem.sh/
https://mochajs.org/
https://www.chaijs.com/
https://www.foundry.com/
https://hardhat.org/hardhat-runner/docs/getting-started#overview