This repository contains a comprehensive testing framework for the Nervos CKB (Common Knowledge Base) blockchain's Rust SDK.
The CKB Rust Integration Test Framework provides automated tests for CKB's RPC interfaces, ensuring that the SDK correctly interacts with CKB nodes. It supports testing both standard CKB RPC and Light Client RPC interfaces.
- Rust (nightly toolchain recommended)
- Cargo
- Git
git clone https://github.com/cryptape/ckb-rust-integration-test.git
cd ckb-rust-integration-test
sh prepare.sh
This script prepares all necessary dependencies and mock data for testing.
cd feature
cargo +nightly test -- --nocapture
Use the --nocapture
flag to display output during test execution, which is helpful for debugging.
The test framework uses rstest
to create parameterized tests with mock RPC server responses.
feature/tests/
- Contains all test codemockrpc/
- Tests for CKB RPC interfacesmock_light_rpc/
- Tests for CKB Light Client RPC interfacescommon/
- Shared utilities and helper functions
- Create a new test file in the appropriate directory
- Use the
rstest
macro withmock_rpc_data
to create parameterized tests - Add corresponding test data JSON files in the
data
directory
Example:
use rstest::rstest;
use crate::mockrpc::{mock_rpc_data, MockRpcData};
#[rstest(mock_rpc_data("method_name", "params"))]
fn test_function(mock_rpc_data: MockRpcData) {
let client = mock_rpc_data.client();
// Test implementation
assert_eq!(expected_result, actual_result);
}
This project uses GitHub Actions for continuous integration testing. Tests run automatically on pushes to the main
branch and on pull requests.
- Check out code
- Set up the test environment
- Run tests and generate a JSON format test report
- If tests fail:
- Convert the JSON report to Markdown format
- Upload the report to Qiniu cloud storage
- Provide a download link for the test report
If tests fail, a detailed report is generated and can be accessed at:
https://github-test-logs.ckbapp.dev/ckb-rust-integration-test/test-report.md
The test report includes:
- Test summary (total, passed, failed)
- Detailed information about failed tests
- Test name
- Failure reason
- Error stack trace
- Test execution time
Contributions are welcome! Please feel free to submit a Pull Request or create an Issue to improve this testing framework.
Before submitting a PR, please ensure:
- All tests pass
- New code has appropriate test coverage
- Code follows the project's style guidelines
MIT