Skip to content

Commit eaaf4ad

Browse files
authored
feat(distributed-storage): add ChallengeStore, SQL-like queries, and comprehensive tests (#3)
* test: add comprehensive SudoAction tests Add tests for: - Challenge management (AddChallenge, UpdateChallenge, RemoveChallenge) - Emergency controls (EmergencyPause, Resume) - Signature verification for sudo operations - ChallengeContainerConfig validation - All SudoAction variants signing/serialization * feat(distributed-storage): add ChallengeStore for per-challenge namespaced storage - Create challenge_store.rs with ChallengeStore struct wrapping DistributedStore - Implement namespace isolation via challenge_id prefixing - Add merkle proof generation for all store/retrieve operations - Include MerkleProof, MerkleNode types for verifiable data inclusion - Add ChallengeStorage async trait for abstraction - Add ChallengeStoreRegistry for managing multiple challenge stores - Implement state root computation via compute_state_root() - Add comprehensive tests for all operations * feat(bittensor-integration): add MockMetagraph for testing - Add mock.rs module with MockMetagraphBuilder and MockNeuronBuilder - Provide helpers: hotkey_from_seed, create_validators, create_test_metagraph - Add test-utils feature for exposing mocks to other crates - Add comprehensive tests for mock functionality and validator sync logic * feat(distributed-storage): add SQL-like query capabilities with block indexing - Add query.rs with QueryBuilder, QueryFilter, QueryResult, QueryCursor types - Add block-indexed secondary storage for efficient range queries - Add DistributedStore trait methods: list_before_block, list_after_block, list_range, count_by_namespace, query, put_with_block - Implement all query methods for LocalStorage and DhtStorage - Add comprehensive tests for all new functionality - Support pagination via cursors and fluent query building * test(challenge-sdk): add comprehensive ServerChallenge async tests * test: add comprehensive blockchain state verification tests Implements 28 tests for: - Bittensor block linking (5 tests) - Merkle proof computation and verification (8 tests) - State hash integrity and verification (7 tests) - Integration tests including full lifecycle (8 tests)
1 parent 7a9ecec commit eaaf4ad

File tree

16 files changed

+6222
-3
lines changed

16 files changed

+6222
-3
lines changed

Cargo.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bittensor-integration/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ version.workspace = true
44
edition.workspace = true
55
description = "Bittensor integration for Platform Chain validators"
66

7+
[features]
8+
default = []
9+
# Enable test utilities (mock types) for integration tests in other crates
10+
test-utils = []
11+
712
[dependencies]
813
platform-core = { path = "../core" }
914
platform-challenge-sdk = { path = "../challenge-sdk" }
@@ -30,3 +35,6 @@ parking_lot = { workspace = true }
3035
chrono = { workspace = true }
3136
futures = { workspace = true }
3237
reqwest = { version = "0.11", features = ["json"] }
38+
39+
# For mock module (hash-based hotkey generation)
40+
sha2 = { workspace = true }

crates/bittensor-integration/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ mod config;
2020
mod validator_sync;
2121
mod weights;
2222

23+
// Mock module for testing - available in tests and to other crates for integration tests
24+
#[cfg(any(test, feature = "test-utils"))]
25+
pub mod mock;
26+
2327
#[cfg(test)]
2428
mod tests;
2529

0 commit comments

Comments
 (0)