Reviewed Aug 2026
DE
BA-14 · LESSON 03

Functional and unit testing

KEY DEFINITIONS

Terms used in this lesson

RPC
Remote procedure call: the command interface applications use to ask a Bitcoin node to perform operations or return state.
Oracle
A system that reports outside information, such as a market price, for use by a protocol.
P2P
Peer-to-peer: nodes communicate directly with other nodes rather than through one central server.
UTXO
Unspent transaction output: one discrete chunk of bitcoin that can be used as a transaction input.
Regtest
A private Bitcoin test network where the operator can create blocks instantly for repeatable experiments.

Good tests isolate consensus logic, RPC behavior, wallet state, serialization, and end-to-end node interactions.

55 min Difficulty 3/5 Not started

Loading lesson visuals...

01

Learn the idea

A unit test checks a small function with controlled dependencies. A functional test runs components through public interfaces such as RPC and P2P. An integration test checks components together, while an end-to-end test follows the complete user workflow. A test oracle is the independently specified expected result, not the same code path under test.

GUIDED EXPLANATION1/5 ideas inspected
1

State one invariant

Define an exact rule such as input value equals outputs plus fee, invalid signature leaves state unchanged, or reorg replay restores the same UTXO root.

Inspect each idea before the worked example.
The worked example follows the explanation

Inspect every idea above to open it.

Important distinctionEnd-to-end tests are always better because they exercise more code.

They catch integration failures but are slower and harder to diagnose. Focused unit and functional tests provide precision, while end-to-end tests cover selected complete workflows.

02
FINISH LEARNING FIRST

The questions unlock after every required learning activity

Inspect every guided idea, open the worked example, rebuild its mechanism, and complete the deterministic lesson tool. Your progress is saved automatically.