📚
Open Polkadot Bootcamp
  • 📚 About the Bootcamp
    • 📖 Additional Resources
    • 👐 Ask For Support
  • 📖 Curriculum
  • 📕Rust Programming Language
    • Basic Rust
      • Introduction to Rust
        • 🧑‍💻 Excercises
      • Common Programming Concepts
        • 🧑‍💻 Excercises
      • Program Life Cycle
        • 🧑‍💻 Excercises
      • Ownership & Borrow Checker
      • Common Data Structures
    • Advanced Rust
      • Generic types, Trait extension and Advanced types
      • Lifetime Notation
      • Smart pointers & Macros
      • Common design patterns in Rust
      • Package management & How to structure your Rust project
      • Overview of the Rust ecosystem
  • 📘Building a blockchain with Polkadot SDK
    • Polkadot
      • Additional Reads
        • Why do you want to build a blockchain on Polkadot?
        • Understanding the sharded network design of Polkadot
      • Development on Polkadot
    • Polkadot SDK
      • Substrate
        • Create a new blockchain
          • 🧑‍💻 Exercise: Clone the minimal template
          • Understanding the architecture
          • Break down the node architecture
          • Introducing to Pop CLI tool
        • Adding a custom logic to runtime
          • 🧑‍💻 Exercise: Rust State Machine
          • Components of a Pallet
          • Hooks
          • Weights & Benchmarking
          • Extensions
            • Signed Extensions
            • Transaction Extensions
        • Common runtime modules
          • 📕Example: System Pallet
          • 📕Example: Contracts Pallet
          • 📕Example: Assets Pallet
          • 📕Example: Utility Pallet
        • Runtime API and RPC
        • Runtime upgrade
        • Bump Polkadot SDK versions
      • Cumulus
        • Introduction to Cumulus
          • Parachain from scratch
          • 🧑‍💻 Exercise: Build a parachain from scratch
        • Running a local relaychain network
          • Register & reserve a parachain
          • Launch the network & run a collator node
          • Launch the network with Pop CLI
        • Agile Coretime
    • Polkadot Hub
  • 📒Smart Contract Development
    • Introduction
      • Introduction to PolkaVM
      • Getting started with Solidity development
      • Solidity File Structure
      • Contract Structure
    • Basic Solidity
      • Value types
      • Reference Types
      • Mapping Types
      • Simple Storage
    • Advanced Solidity
      • Units
      • Global Variables
      • Expression and Control Structures
      • Advanced Storage
      • Contract Tests
      • Contracts
Powered by GitBook
On this page
  1. Smart Contract Development
  2. Advanced Solidity

Contract Tests

Thorough testing of Solidity files plays an important role in ensuring the quality, reliability, and security of your blockchain project.

Here are some main reasons:

  • Error detection: Testing helps you identify and fix errors in your Solidity code. Code errors can lead to unwanted behavior and even loss of assets. Testing helps you detect these errors early and fix them before they cause serious problems.

  • Ensure security: Testing helps you identify security vulnerabilities in your Solidity code. Security vulnerabilities can leave your project vulnerable to hackers. Testing helps you identify these vulnerabilities and take measures to patch them.

  • Increase reliability: Testing helps you increase the reliability of your blockchain project. When users know that your project has been thoroughly tested, they will have more trust in the project and be more likely to use it.

  • Save time and money: Testing helps you save time and money in the long term. Fixing errors sooner will help you avoid more serious and costly problems later.

There are many different testing methods that can be used to test Solidity files. Some popular methods include:

  1. Unit test: is a method of testing each individual unit of code.

  2. Integration test: is a method of testing how different units of code work together.

  3. Forked test: is a method of testing code in an environment that simulates the real environment.

  4. Staging test: is a method of testing code in a real environment but not in prod. Choosing the right testing method will depend on the specific needs of your project.

Here are some tips for effectively testing Solidity files:

  • Write test code that is easy to understand and maintain.

  • Use many different testing methods.

  • Automate testing.

  • Consider using specialized testing tools.

How to test?

Remix, or Hardhat, or Foundry have their own options for testing smart contracts. You can refer to the in-depth docs below:

PreviousAdvanced StorageNextContracts

Last updated 5 months ago

📒
Remix test
Hardhat test
Foundry forge test