Skip to content

Multi Node Testing

O edited this page Dec 23, 2025 · 1 revision

Multi-Node Deployment Testing Guide

This guide explains how to test O Blockchain features across multiple nodes to verify network synchronization, transaction propagation, and distributed consensus.

Overview

Multi-node testing is essential to verify that:

  • O Blockchain transactions propagate correctly across the network
  • All nodes maintain consistent blockchain state
  • Measurement data is synchronized across nodes
  • User verification data is shared across the network
  • Invites and measurements are queryable on all nodes

Test Scripts

1. Python Functional Test (Recommended)

The Python test uses the Bitcoin test framework for comprehensive automated testing:

# Run the multi-node test
python3 test/functional/test_o_multi_node.py

# Or via test runner (if registered)
./test/functional/test_runner.py test_o_multi_node

What it tests:

  • βœ… User verification transaction propagation
  • βœ… Measurement invite creation and propagation
  • βœ… Block propagation and synchronization
  • βœ… Measurement system status across nodes
  • βœ… Currency system consistency
  • βœ… Chain consistency (same best block hash)
  • βœ… Network connectivity

2. Bash Manual Test Script

For quick manual testing and debugging:

# Run the bash test script
./test_multi_node_deployment.sh

What it does:

  • Sets up 3 nodes with separate data directories
  • Connects them in a network topology
  • Tests basic O Blockchain features
  • Keeps nodes running for interactive testing

Node Configuration:

  • Node 1: RPC port 18443, Network port 18444
  • Node 2: RPC port 18444, Network port 18445
  • Node 3: RPC port 18445, Network port 18446

Interacting with nodes:

# Node 1
./build/bin/bitcoin-cli -regtest -conf=/tmp/o_blockchain_test/node1/bitcoin.conf \
  -rpcuser=node1 -rpcpassword=node1pass -rpcwallet=wallet1 <command>

# Node 2
./build/bin/bitcoin-cli -regtest -conf=/tmp/o_blockchain_test/node2/bitcoin.conf \
  -rpcuser=node2 -rpcpassword=node2pass -rpcwallet=wallet2 <command>

# Node 3
./build/bin/bitcoin-cli -regtest -conf=/tmp/o_blockchain_test/node3/bitcoin.conf \
  -rpcuser=node3 -rpcpassword=node3pass -rpcwallet=wallet3 <command>

Manual Multi-Node Setup

If you want to set up nodes manually:

Step 1: Create Node Directories

mkdir -p /tmp/o_test/node1 /tmp/o_test/node2 /tmp/o_test/node3

Step 2: Create Configuration Files

Node 1 (/tmp/o_test/node1/bitcoin.conf):

regtest=1
server=1
listen=1
port=18444
rpcport=18443
rpcuser=node1
rpcpassword=node1pass
rpcallowip=127.0.0.1
datadir=/tmp/o_test/node1

Node 2 (/tmp/o_test/node2/bitcoin.conf):

regtest=1
server=1
listen=1
port=18445
rpcport=18444
rpcuser=node2
rpcpassword=node2pass
rpcallowip=127.0.0.1
datadir=/tmp/o_test/node2
addnode=127.0.0.1:18444

Node 3 (/tmp/o_test/node3/bitcoin.conf):

regtest=1
server=1
listen=1
port=18446
rpcport=18445
rpcuser=node3
rpcpassword=node3pass
rpcallowip=127.0.0.1
datadir=/tmp/o_test/node3
addnode=127.0.0.1:18444

Step 3: Start Nodes

# Terminal 1 - Node 1
./build/bin/bitcoind -conf=/tmp/o_test/node1/bitcoin.conf

# Terminal 2 - Node 2
./build/bin/bitcoind -conf=/tmp/o_test/node2/bitcoin.conf

# Terminal 3 - Node 3
./build/bin/bitcoind -conf=/tmp/o_test/node3/bitcoin.conf

Step 4: Create Wallets

# On each node
./build/bin/bitcoin-cli -regtest -conf=/tmp/o_test/node1/bitcoin.conf -rpcuser=node1 -rpcpassword=node1pass createwallet wallet1
./build/bin/bitcoin-cli -regtest -conf=/tmp/o_test/node2/bitcoin.conf -rpcuser=node2 -rpcpassword=node2pass createwallet wallet2
./build/bin/bitcoin-cli -regtest -conf=/tmp/o_test/node3/bitcoin.conf -rpcuser=node3 -rpcpassword=node3pass createwallet wallet3

Step 5: Generate Initial Blocks

# Generate blocks on node 1
./build/bin/bitcoin-cli -regtest -conf=/tmp/o_test/node1/bitcoin.conf -rpcuser=node1 -rpcpassword=node1pass -rpcwallet=wallet1 -generate 101

Step 6: Verify Synchronization

# Check block heights on all nodes
./build/bin/bitcoin-cli -regtest -conf=/tmp/o_test/node1/bitcoin.conf -rpcuser=node1 -rpcpassword=node1pass getblockcount
./build/bin/bitcoin-cli -regtest -conf=/tmp/o_test/node2/bitcoin.conf -rpcuser=node2 -rpcpassword=node2pass getblockcount
./build/bin/bitcoin-cli -regtest -conf=/tmp/o_test/node3/bitcoin.conf -rpcuser=node3 -rpcpassword=node3pass getblockcount

# Should all show the same height

Testing O Blockchain Features

Test 1: User Verification Propagation

Create a user verification on one node and verify it's queryable on others:

# On Node 1
./build/bin/bitcoin-cli -regtest -conf=/tmp/o_test/node1/bitcoin.conf \
  -rpcuser=node1 -rpcpassword=node1pass -rpcwallet=wallet1 \
  submituserverificationtx "user123" "brightid" "USA" "OUSD" '{"score":95}' "0102030405060708090a0b0c0d0e0f" 0

# Generate block to include transaction
./build/bin/bitcoin-cli -regtest -conf=/tmp/o_test/node1/bitcoin.conf \
  -rpcuser=node1 -rpcpassword=node1pass -rpcwallet=wallet1 -generate 1

# Wait for sync, then verify on Node 2
# (User verification queries would be available here)

Test 2: Measurement Invite Propagation

# Create invite on Node 1
./build/bin/bitcoin-cli -regtest -conf=/tmp/o_test/node1/bitcoin.conf \
  -rpcuser=node1 -rpcpassword=node1pass -rpcwallet=wallet1 \
  submitinvitetx "invite_id" "<pubkey>" "water_price" "USD" 1734900000

# Generate block
./build/bin/bitcoin-cli -regtest -conf=/tmp/o_test/node1/bitcoin.conf \
  -rpcuser=node1 -rpcpassword=node1pass -rpcwallet=wallet1 -generate 1

# Verify invite is queryable on Node 2
./build/bin/bitcoin-cli -regtest -conf=/tmp/o_test/node2/bitcoin.conf \
  -rpcuser=node2 -rpcpassword=node2pass -rpcwallet=wallet2 \
  getactiveinvites

Test 3: Block Propagation

# Generate blocks on different nodes
./build/bin/bitcoin-cli -regtest -conf=/tmp/o_test/node1/bitcoin.conf \
  -rpcuser=node1 -rpcpassword=node1pass -rpcwallet=wallet1 -generate 5

# Wait a few seconds, then verify all nodes have same height
./build/bin/bitcoin-cli -regtest -conf=/tmp/o_test/node1/bitcoin.conf -rpcuser=node1 -rpcpassword=node1pass getblockcount
./build/bin/bitcoin-cli -regtest -conf=/tmp/o_test/node2/bitcoin.conf -rpcuser=node2 -rpcpassword=node2pass getblockcount
./build/bin/bitcoin-cli -regtest -conf=/tmp/o_test/node3/bitcoin.conf -rpcuser=node3 -rpcpassword=node3pass getblockcount

Test 4: Measurement System Consistency

# Check measurement readiness on all nodes
for i in 1 2 3; do
  echo "Node $i:"
  ./build/bin/bitcoin-cli -regtest -conf=/tmp/o_test/node$i/bitcoin.conf \
    -rpcuser=node$i -rpcpassword=node${i}pass -rpcwallet=wallet$i \
    getmeasurementreadinessstatistics
done

Test 5: Currency System Consistency

# List currencies on all nodes (should be identical)
for i in 1 2 3; do
  echo "Node $i currencies:"
  ./build/bin/bitcoin-cli -regtest -conf=/tmp/o_test/node$i/bitcoin.conf \
    -rpcuser=node$i -rpcpassword=node${i}pass -rpcwallet=wallet$i \
    listcurrencies | head -20
done

Verification Checklist

After running tests, verify:

  • All nodes have the same block height
  • All nodes have the same best block hash
  • Transactions created on one node appear in mempool/blocks of other nodes
  • O Blockchain transactions (user verification, invites, measurements) propagate correctly
  • Measurement data is queryable on all nodes
  • Currency listings are consistent across nodes
  • Network connectivity is maintained (each node has >= 1 peer)

Troubleshooting

Nodes Not Connecting

  • Check firewall settings
  • Verify ports are not in use: lsof -i :18444
  • Check node logs for connection errors
  • Manually add peers: addnode 127.0.0.1:18444 add

Blocks Not Syncing

  • Check getconnectioncount on each node
  • Verify network connectivity: getpeerinfo
  • Force sync: syncwithvalidationinterfacequeue (if available)

O Blockchain Features Not Working

  • Ensure wallets are loaded: loadwallet wallet1
  • Check wallet balance: getbalance
  • Verify RPC commands are registered: help submituserverificationtx
  • Check logs for errors related to O Blockchain features

Cleanup

To clean up test directories:

# Stop all nodes
pkill -f "bitcoind.*regtest"

# Remove test directories
rm -rf /tmp/o_blockchain_test
rm -rf /tmp/o_test

Next Steps

  1. Run the Python functional test for comprehensive automated testing
  2. Use the bash script for quick manual verification
  3. Test with more nodes (4, 5, 10+) to stress test network propagation
  4. Test with network partitions and reconnections
  5. Verify measurement averaging works correctly across nodes
  6. Test stability mining rewards distribution

Clone this wiki locally