Skip to content

Commit c59318f

Browse files
committed
Website: add testing framework section
1 parent 19c6f80 commit c59318f

File tree

9 files changed

+1203
-10
lines changed

9 files changed

+1203
-10
lines changed

CLAUDE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,17 @@ import ScriptName from "!!raw-loader!./path/to/script.sh";
234234
This ensures scripts are displayed accurately and stay in sync with the actual
235235
files.
236236

237+
### Documentation Style Guidelines
238+
239+
**Capitalization in headings and bullet points:**
240+
241+
- Use lowercase for section headings (e.g., "Test design", "Resource
242+
management")
243+
- Use lowercase for bullet point labels (e.g., "**Connection policies**",
244+
"**State inspection**")
245+
- Maintain proper capitalization for proper nouns and technical terms
246+
- Apply this style consistently across all documentation files
247+
237248
### Documentation Script Testing
238249

239250
When modifying developer setup scripts in `website/docs/developers/scripts/`,

website/docs/developers/getting-started.mdx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ make postgres-setup
225225
make run-archive
226226
```
227227

228-
### Development Server
228+
### Building documentation
229229

230230
For web development with the frontend:
231231

@@ -261,28 +261,37 @@ npm install
261261
npm start
262262
```
263263

264-
### Testing Framework
264+
### Testing
265265

266-
The Mina Rust Node includes a comprehensive testing framework:
266+
The Mina Rust Node includes a comprehensive testing framework with unit tests,
267+
integration tests, and scenario-based testing. For detailed information on
268+
running specific types of tests, see the
269+
[Testing Framework](testing/testing-framework) documentation.
270+
271+
Quick test commands:
267272

268273
```bash
269-
# Build testing binary
270-
make build-testing
274+
# Run basic unit tests
275+
make test
271276

272-
# Run specific test scenarios
273-
./target/release/mina-node-testing --help
277+
# Verify your setup works
278+
make test-p2p
274279
```
275280

276281
## Next Steps
277282

278283
1. **Explore the Codebase**: Start with
279284
[Architecture Documentation](./architecture.md)
280-
2. **Run Tests**: Ensure your setup works by running `make test`
281-
3. **Join the Community**: Connect with other developers on
285+
2. **Learn the Testing Framework**: Familiarize yourself with our comprehensive
286+
[Testing Framework](testing/testing-framework) including unit tests, scenario
287+
tests, and debugging tools
288+
3. **Run Tests**: Ensure your setup works by running tests as described in the
289+
testing documentation
290+
4. **Join the Community**: Connect with other developers on
282291
[Discord](https://discord.com/channels/484437221055922177/1290662938734231552)
283292
and participate in discussions on the
284293
[Mina Protocol Forums](https://forums.minaprotocol.com/)
285-
4. **Read CLAUDE.md**: Check the project-specific development guide in the root
294+
5. **Read CLAUDE.md**: Check the project-specific development guide in the root
286295
directory
287296

288297
## Getting Help
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
---
2+
sidebar_position: 3
3+
title: Ledger Tests
4+
description: Comprehensive ledger functionality testing
5+
slug: /developers/testing/ledger-tests
6+
---
7+
8+
# Ledger Tests
9+
10+
## Overview
11+
12+
Comprehensive ledger functionality testing covers transaction processing, state
13+
management, and ledger operations. These tests require nightly Rust due to
14+
advanced features and dependencies.
15+
16+
## Running Ledger Tests
17+
18+
### Basic Ledger Testing
19+
20+
```bash
21+
# Build ledger tests
22+
make build-ledger
23+
24+
# Run ledger tests
25+
make test-ledger
26+
27+
# Run with cargo-nextest
28+
make nextest-ledger
29+
```
30+
31+
**Note**: Ledger tests require nightly Rust toolchain.
32+
33+
## VRF Tests
34+
35+
```bash
36+
# Run VRF tests
37+
make test-vrf
38+
39+
# Run with cargo-nextest
40+
make nextest-vrf
41+
```
42+
43+
**Note**: VRF tests also require nightly Rust toolchain.
44+
45+
## Block Replayer Tool
46+
47+
### Purpose
48+
49+
The block replayer validates transaction and ledger logic by replaying
50+
historical blockchain data:
51+
52+
- **Transaction Validation**: Verify transaction processing correctness
53+
- **Ledger State**: Ensure ledger state transitions are accurate
54+
- **Protocol Compliance**: Check adherence to protocol rules
55+
- **Performance Analysis**: Measure processing speeds and resource usage
56+
57+
### Usage
58+
59+
```bash
60+
# Replay blocks from chain data
61+
./target/release/mina replay --blocks-file chain.json
62+
63+
# Validate specific block range
64+
./target/release/mina replay --start-block 1000 --end-block 2000
65+
```
66+
67+
### Future development
68+
69+
Continued development of the block replayer is recommended for:
70+
71+
- **Enhanced validation**: More comprehensive transaction validation
72+
- **Performance testing**: Benchmark ledger operation performance
73+
- **Protocol evolution**: Test new protocol features against historical data
74+
- **Regression testing**: Ensure changes don't break existing functionality
75+
76+
## Ledger testing components
77+
78+
### Transaction processing
79+
80+
Tests cover:
81+
82+
- **User commands**: Payment and delegation transactions
83+
- **Fee transfers**: Block producer rewards and fees
84+
- **Coinbase**: Block reward distribution
85+
- **Account creation**: New account initialization
86+
87+
### State management
88+
89+
Validation includes:
90+
91+
- **Account updates**: Balance and nonce changes
92+
- **Merkle tree operations**: Ledger tree consistency
93+
- **State transitions**: Valid state progression
94+
- **Rollback handling**: Proper state restoration
95+
96+
### Scan state testing
97+
98+
The scan state manages pending transactions:
99+
100+
- **Transaction queuing**: Proper ordering and batching
101+
- **SNARK work integration**: Proof generation coordination
102+
- **Staged ledger**: Intermediate state management
103+
- **Fork resolution**: Handling competing chains
104+
105+
## Performance Considerations
106+
107+
### Resource management
108+
109+
1. **Memory usage**: Ledger tests can be memory intensive
110+
2. **Disk I/O**: State persistence operations
111+
3. **CPU usage**: Cryptographic operations and proof verification
112+
4. **Test duration**: Comprehensive tests may take significant time
113+
114+
### Optimization strategies
115+
116+
1. **Parallel execution**: Use cargo-nextest for faster test runs
117+
2. **Test filtering**: Run specific test subsets during development
118+
3. **Mock services**: Use lightweight mocks where appropriate
119+
4. **Resource cleanup**: Ensure proper cleanup after tests
120+
121+
## Best practices
122+
123+
### Test design
124+
125+
1. **Isolation**: Use fresh ledger state for each test
126+
2. **Deterministic**: Tests should produce consistent results
127+
3. **Coverage**: Test both success and failure scenarios
128+
4. **Edge cases**: Include boundary conditions and error cases
129+
130+
### Debugging ledger tests
131+
132+
1. **State inspection**: Examine ledger state at test failure points
133+
2. **Transaction tracing**: Track transaction processing steps
134+
3. **Merkle tree validation**: Verify tree consistency
135+
4. **Account state**: Check individual account changes
136+
137+
## Integration with other components
138+
139+
### Connection to P2P tests
140+
141+
Ledger tests integrate with P2P testing for:
142+
143+
- **Transaction propagation**: Ensuring transactions spread correctly
144+
- **Block validation**: Verifying received blocks
145+
- **Consensus integration**: Coordinating with consensus mechanisms
146+
147+
### Scenario test integration
148+
149+
Ledger functionality is tested within broader scenarios:
150+
151+
- **Multi-node synchronization**: Consistent ledger state across nodes
152+
- **Fork resolution**: Proper handling of competing ledgers
153+
- **Performance testing**: Ledger operations under load
154+
155+
## Related Documentation
156+
157+
- [Testing Framework Overview](testing-framework): Main testing documentation
158+
- [Unit Tests](unit-tests): Basic component testing
159+
- [Scenario Tests](scenario-tests): Integration testing scenarios
160+
- [Architecture](../architecture): Overall system architecture including ledger

0 commit comments

Comments
 (0)