Skip to content

Testing Guide

O edited this page Dec 23, 2025 · 3 revisions

O Blockchain Testing Guide

This guide provides comprehensive information about testing the O Blockchain codebase, ensuring features are present, and validating performance.

πŸ“‹ Table of Contents

πŸ§ͺ Test Suite Overview

The O Blockchain testing infrastructure includes:

Existing Tests

  1. test/functional/test_o_blockchain_sync.py

    • Tests blockchain-to-database synchronization
    • Multi-node consistency
    • Database persistence across restarts
    • Measurement statistics sync
  2. test/functional/test_o_databases.py

    • Database initialization and structure
    • LevelDB file presence
    • Database persistence
    • Initialization logs verification
  3. simulation/comprehensive_test.py

    • Basic functionality checks
    • PoW/PoB system tests
    • Measurement system tests
    • Stabilization system tests
    • Currency exchange tests

New Tests

  1. test/functional/test_o_features_and_performance.py ⭐ NEW

    • Feature Completeness: Verifies all O Blockchain features are present
    • Currency Support: Tests 142 currency support
    • Database Performance: Benchmarks database queries
    • Blockchain Integration: Tests O features with block generation
    • Measurement System: Validates measurement functionality
    • Stabilization System: Tests stabilization mining
    • Performance Benchmarks: RPC latency and block generation rates
  2. test_o_performance.py ⭐ NEW

    • Standalone performance testing script
    • RPC command benchmarking
    • Database scalability tests
    • Concurrent operation tests
    • Performance reports

πŸš€ Quick Start

Prerequisites

  1. Build the O Blockchain:

    cd /Users/o/bitcoin
    mkdir -p build && cd build
    cmake ..
    make -j$(nproc)
  2. Start a regtest node (in one terminal):

    ./build/bin/bitcoind -regtest -daemon
  3. Wait for node to be ready:

    ./build/bin/bitcoin-cli -regtest getblockchaininfo

Run Quick Feature & Performance Test

# Run the comprehensive functional test
./build/test/functional/test_runner.py test_o_features_and_performance

# Or run the standalone performance test
python3 test_o_performance.py

πŸ“š Functional Tests

Running Individual Tests

# Run database tests
./build/test/functional/test_runner.py test_o_databases

# Run blockchain sync tests
./build/test/functional/test_runner.py test_o_blockchain_sync

# Run features and performance tests
./build/test/functional/test_runner.py test_o_features_and_performance

# Run all O-specific tests
./build/test/functional/test_runner.py test_o_*

Test Coverage

Feature Completeness Test (test_o_features_and_performance.py)

Tests that all expected features are present:

  • βœ… O Transaction Types (6 types)

    • USER_VERIFY
    • WATER_PRICE
    • EXCHANGE_RATE
    • BUSINESS_REGISTER
    • MEASUREMENT_VALIDATION
    • MEASUREMENT_INVITE
  • βœ… Measurement System RPC Commands

    • getmeasurementstatistics
    • getmeasurementreadinessstatistics
    • getmeasurementvolatility
    • getmeasurementtargetstatistics
    • getmeasurementgap
    • getactiveinvites
    • getaveragewaterpricewithconfidence
    • getmeasurementtrend
  • βœ… Stabilization System RPC Commands

    • getstabilizationstats
    • getstabilizationhistory
    • getstabilizationintegrationstatus
    • getstabilizationconsensusstats
    • getstabilizationcoinstats
    • getstabilizationconsensushash
  • βœ… Currency Exchange RPC Commands

    • getsupportedpairs
    • getexchangerate
    • listocurrencies
  • βœ… PoW/PoB System RPC Commands

    • getpowpobstats
    • getbusinessratio
    • getbusinessminerstats
  • βœ… Transaction Submission RPC Commands

    • submituserverificationtx
    • submitwaterpricetx
    • submitexchangeratetx
    • submitvalidationtx
    • submitinvitetx
  • βœ… Database Presence

    • BrightID User Registry database
    • Measurement Database
    • Business Miner Database

Currency Support Test

  • Lists all supported currencies
  • Verifies major currencies (USD, EUR, JPY, GBP, CNY)
  • Tests exchange pair support

Database Performance Test

  • Measures query latency (< 100ms target)
  • Tests cache effectiveness
  • Multiple rapid queries benchmark

Blockchain Integration Test

  • Block generation with O features
  • Automatic invitation creation (every 10 blocks)
  • Database-blockchain synchronization
  • Multi-block consistency

Measurement System Test

  • Measurement statistics availability
  • Measurement readiness checking
  • Invitation system functionality

Stabilization System Test

  • Stabilization statistics
  • Integration status
  • Consensus statistics

Performance Benchmarks

  • RPC call latency (target: < 100ms)
  • Block generation rate
  • Cache performance
  • Concurrent operation handling

⚑ Performance Tests

Standalone Performance Script

The test_o_performance.py script provides detailed performance metrics:

# Basic usage
python3 test_o_performance.py

# With custom paths
python3 test_o_performance.py --cli-path ./build/bin/bitcoin-cli --datadir regtest

Performance Metrics

  1. Node Connectivity

    • Verifies node is accessible
    • Checks blockchain info
  2. Core Operations

    • Block generation rate
    • Address generation
  3. O RPC Performance

    • Individual RPC command benchmarks
    • Average, min, max latencies
    • Success rates
  4. Database Scalability

    • Query performance
    • Cache effectiveness
  5. Concurrent Operations

    • Multiple RPC calls in sequence
    • Overall throughput

Performance Targets

  • RPC Calls: < 100ms average (excellent), < 500ms (acceptable)
  • Block Generation: > 0.1 blocks/second
  • Database Queries: < 100ms (cached), < 500ms (uncached)
  • Cache Hit Rate: > 50% improvement on subsequent queries

βœ… Feature Verification

Manual Feature Check

You can manually verify features using RPC commands:

# Check if node is running
./build/bin/bitcoin-cli -regtest getblockchaininfo

# List all O currencies
./build/bin/bitcoin-cli -regtest listocurrencies

# Get measurement statistics
./build/bin/bitcoin-cli -regtest getmeasurementstatistics

# Get stabilization stats
./build/bin/bitcoin-cli -regtest getstabilizationstats

# Get PoW/PoB stats
./build/bin/bitcoin-cli -regtest getpowpobstats

# Check supported exchange pairs
./build/bin/bitcoin-cli -regtest getsupportedpairs

# Get active invitations
./build/bin/bitcoin-cli -regtest getactiveinvites

Feature Checklist

Use this checklist to verify all features are present:

  • All 6 O transaction types are defined
  • Measurement system RPC commands work
  • Stabilization system RPC commands work
  • Currency exchange RPC commands work
  • PoW/PoB system RPC commands work
  • Transaction submission RPC commands are available
  • All 3 databases are initialized
  • 142 currencies are supported
  • Exchange pairs are available
  • Block generation works with O features
  • Automatic invitations are created
  • Database queries are fast (< 500ms)

πŸ”§ Running Tests

Full Test Suite

Run all O Blockchain tests:

cd /Users/o/bitcoin
./build/test/functional/test_runner.py test_o_*

Specific Test Categories

# Database tests only
./build/test/functional/test_runner.py test_o_databases

# Sync tests only
./build/test/functional/test_runner.py test_o_blockchain_sync

# Features and performance
./build/test/functional/test_runner.py test_o_features_and_performance

With Verbose Output

./build/test/functional/test_runner.py --loglevel=DEBUG test_o_features_and_performance

Performance Test Only

# Make sure node is running first
./build/bin/bitcoind -regtest -daemon

# Run performance test
python3 test_o_performance.py

πŸ“Š Interpreting Results

Test Output

Tests provide clear indicators:

  • βœ… Green checkmark: Feature present and working
  • ⚠️ Warning: Feature present but may have issues
  • ❌ Red X: Feature missing or broken

Performance Ratings

  • Excellent: < 50ms average
  • Very Good: < 100ms average
  • Good: < 500ms average
  • Needs Improvement: > 500ms average

Common Issues

  1. "Cannot connect to node"

    • Make sure bitcoind is running: ./build/bin/bitcoind -regtest -daemon
    • Check with: ./build/bin/bitcoin-cli -regtest getblockchaininfo
  2. "Database not initialized"

    • Generate some blocks: ./build/bin/bitcoin-cli -regtest generatetoaddress 101 $(./build/bin/bitcoin-cli -regtest getnewaddress)
  3. "RPC command not found"

    • Check if command is registered in src/rpc/register.h
    • Rebuild if needed: cd build && make
  4. "Performance slow"

    • Check system resources
    • Verify database files exist
    • Consider using cached queries

πŸ” Debugging Failed Tests

Enable Debug Logging

# Start node with debug logging
./build/bin/bitcoind -regtest -debug=o -daemon

# Check logs
tail -f ~/.bitcoin/regtest/debug.log

Common Debug Commands

# Check node status
./build/bin/bitcoin-cli -regtest getblockchaininfo

# Check database files
ls -la ~/.bitcoin/regtest/brightid_users/
ls -la ~/.bitcoin/regtest/measurements/
ls -la ~/.bitcoin/regtest/business_miners/

# Check RPC help for a command
./build/bin/bitcoin-cli -regtest help getmeasurementstatistics

πŸ“ˆ Next Steps

After running tests:

  1. Review Results: Check which features pass/fail
  2. Performance Analysis: Identify slow operations
  3. Fix Issues: Address any failing tests
  4. Re-run Tests: Verify fixes work
  5. Document Findings: Update this guide if needed

🀝 Contributing Tests

When adding new features, also add tests:

  1. Add functional test in test/functional/test_o_*.py
  2. Add unit tests in src/test/ if applicable
  3. Update this guide with new test information
  4. Run full test suite to ensure nothing breaks

πŸ“š Additional Resources

  • Bitcoin Core Test Framework: See test/functional/test_framework/
  • Test README: test/README.md
  • Simulation Tests: simulation/ directory
  • Build Results: simulation/BUILD_AND_TEST_RESULTS.md

Last Updated: 2025-01-06
Test Coverage: Features, Performance, Integration, Databases

Clone this wiki locally