Regtest Network Simulation

Three b3chain nodes connected in a regtest network, mining a full 2 016-block difficulty retarget period and verifying every aspect of block propagation, mining, wallet sends, and chain consistency. End-to-end runtime: about 70 seconds on a modern CPU.

Script: regtest-simulation.sh Nodes: 3 Blocks: 2 016 Status: 19 / 19 PASS

1. What it tests

#CheckVerifies
1–3Node startupAll 3 nodes start at height 0
4Address prefixRegtest addresses use b3rt1
5Peer connectivityNodes discover and connect
6Mining (2 016 blocks)BLAKE3 PoW works via generatetoaddress
7–8Block syncBlocks propagate to all nodes
9–10Tip consensusAll 3 nodes agree on the chain tip
11Miner balanceCoinbase rewards (50 B3C/block)
12Block subsidyBlock 1 coinbase pays exactly 50.00000000 B3C
13–14Wallet sendNode 0 sends to nodes 1 and 2
15Cross-node sendNode 1 sends to node 2 (full P2P relay)
16Chain workCumulative chain work identical across nodes
17Genesis hashGenesis matches expected
18Mid-chain hashBlock 1008 hash identical across nodes
19UTXO setUTXO set hash identical across nodes

2. Prerequisites

OS
Linux or WSL2
b3chaind
built; expected at build/bin/b3chaind
Free ports
29100–29105 on 127.0.0.1

3. Run it

git clone https://github.com/b3chain/b3chain.git
cd b3chain
mkdir build && cd build
cmake ..
cmake --build . -j$(nproc)
cd ..
bash contrib/testing/regtest-simulation.sh

4. Expected output

============================================================
 B3Chain Regtest Simulation (2016 blocks, 3 nodes)
============================================================
[1/8] Setting up test environment...
  PASS: Node 0 started at height 0
  PASS: Node 1 started at height 0
  PASS: Node 2 started at height 0
[2/8] Creating wallets...
  Node 0 (miner):  b3rt1q...
  Node 1 (wallet): b3rt1q...
  Node 2 (wallet): b3rt1q...
  PASS: Address uses b3rt prefix
[3/8] Testing peer connectivity...
  PASS: Node 0 has 2 peer(s)
[4/8] Mining 2016 blocks (full retarget period)...
  Mined 500 / 2016 blocks...
  Mined 1000 / 2016 blocks...
  Mined 1500 / 2016 blocks...
  Mined 2000 / 2016 blocks...
  Mined 2016 / 2016 blocks...
  Mining took 65s
  PASS: Node 0 at height 2016
  PASS: Node 1 synced to 2016
  PASS: Node 2 synced to 2016
  PASS: All nodes agree on tip
  PASS: All nodes agree on tip (node2)
[5/8] ...
============================================================
 RESULTS: 19 passed, 0 failed
============================================================
 All tests passed!

5. Common pitfalls

  • Port conflict: if 29100–29105 are already in use, edit the NODE*_P2P / NODE*_RPC variables at the top of the script.
  • WSL crash on stop: cleanup trap calls pkill -f "b3chaind.*regtest_sim"; if you ran a node by hand against the same datadir it may also be killed.
  • Slow disk: mining 2 016 blocks writes ~10 MB. If your /tmp is on a slow filesystem, set TESTDIR=/some/fast/path at the top.

6. Source files