All Projects

๐Ÿงช Substrate Pallet Test Framework (CC3 Protocol)

Comprehensive test framework for validating Substrate blockchain pallets on the Creditcoin 3 network. Covers staking lifecycle, Grandpa migration, precompile testing (BN128, signature verifier), and dynamic extrinsic calling across testnet, devnet, and dryrun environments with Allure structured test reporting.

QA / Blockchain EngineerGluwa / 2022โ€“2024

Stack

TypeScriptPolkadot.js APIJestMochaAllureNode.js

Substrate Pallet Test Framework (CC3 Protocol)

๐Ÿ”ญ Overview

A purpose-built test framework for validating Substrate blockchain pallets on the Creditcoin 3 network. Testing a custom blockchain runtime is fundamentally different from testing a REST API โ€” there's no existing framework, no easy mocking, and bugs can mean irreversible on-chain state changes. This framework was built from first principles to cover the full pallet surface.

๐Ÿ› ๏ธ What I Built

๐Ÿ—๏ธ Framework Architecture

  • โ›“๏ธ Polkadot.js API integration: connects to live Substrate nodes (testnet, devnet, dryrun) and submits extrinsics programmatically
  • ๐Ÿ”ง Dynamic extrinsic calling: generic helpers for calling any pallet extrinsic by name, enabling tests to be written at a high level without hard-coding ABI knowledge
  • ๐ŸŒ Multi-environment support: single test suite runs against testnet, devnet, or dryrun via environment variable configuration
  • ๐Ÿ“Š Allure integration: structured test reporting with step-level annotations, screenshots on failure, and test history tracking

๐Ÿ“‹ Staking Lifecycle Coverage

  • ๐Ÿ”„ Full staking lifecycle: bond โ†’ nominate โ†’ unbond โ†’ withdraw_unbonded โ†’ payout_stakers
  • โš ๏ธ Edge cases: bonding with insufficient funds, nominating non-validators, unbonding during active era
  • ๐Ÿ’ฐ Reward payout correctness: validates payout amounts against expected era points and commission rates

๐Ÿ”€ Grandpa Migration Tests

  • ๐Ÿ”€ Validates the Grandpa consensus migration path from the legacy chain to CC3
  • โœ… State correctness assertions: account balances, staking positions, and validator sets post-migration
  • ๐Ÿงช Run against devnet fork to verify migration scripts before mainnet execution

๐Ÿ” Precompile Testing

  • ๐Ÿ“ BN128 curve precompile: validates elliptic curve operations (add, mul, pairing) at the EVM precompile address
  • โœ๏ธ Signature verifier precompile: validates ECDSA signature recovery for Ethereum-compatible address derivation
  • โœ… Cross-validates precompile outputs against reference implementations

๐Ÿ“ฆ Test Data Management

  • ๐Ÿ‘ค Nomination account fixtures for deterministic test environments
  • ๐Ÿ“Š CSV-based test vector loading for parameterized tests across multiple account states
  • ๐Ÿงน On-chain state cleanup helpers for test isolation

โญ Key Highlights

  • ๐Ÿงช Testing a custom blockchain runtime from scratch โ€” no existing framework to extend
  • ๐Ÿ”ง Dynamic extrinsic calling covers any pallet without per-extrinsic boilerplate
  • ๐Ÿ“Š Allure reporting provides structured observability for QA team and stakeholders
  • ๐ŸŒ Multi-environment: same test suite validates testnet, devnet, and dryrun environments
  • ๐Ÿ› Caught 3 critical staking edge-case bugs before mainnet deployment