Skip to content

cryptape/ckb-rust-integration-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CKB Rust Integration Test Framework

This repository contains a comprehensive testing framework for the Nervos CKB (Common Knowledge Base) blockchain's Rust SDK.

Overview

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.

Requirements

  • Rust (nightly toolchain recommended)
  • Cargo
  • Git

Getting Started

Clone the Repository

git clone https://github.com/cryptape/ckb-rust-integration-test.git
cd ckb-rust-integration-test

Setup Environment

sh prepare.sh

This script prepares all necessary dependencies and mock data for testing.

Run Tests

cd feature
cargo +nightly test -- --nocapture

Use the --nocapture flag to display output during test execution, which is helpful for debugging.

Framework Structure

The test framework uses rstest to create parameterized tests with mock RPC server responses.

Directory Structure

  • feature/tests/ - Contains all test code
    • mockrpc/ - Tests for CKB RPC interfaces
    • mock_light_rpc/ - Tests for CKB Light Client RPC interfaces
    • common/ - Shared utilities and helper functions

Adding New Tests

  1. Create a new test file in the appropriate directory
  2. Use the rstest macro with mock_rpc_data to create parameterized tests
  3. 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);
}

Continuous Integration

This project uses GitHub Actions for continuous integration testing. Tests run automatically on pushes to the main branch and on pull requests.

CI Workflow

  1. Check out code
  2. Set up the test environment
  3. Run tests and generate a JSON format test report
  4. 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

Test Reports

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

Contributing

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:

  1. All tests pass
  2. New code has appropriate test coverage
  3. Code follows the project's style guidelines

License

MIT

About

ckb-rust-integration-test

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •