test: ajouter tests dintégration (smoke, erreurs, rôles); docs TESTING.md
This commit is contained in:
parent
e3fcf44693
commit
ed253f2ab7
@ -9,10 +9,12 @@ et ce projet adhère au [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||
|
||||
### Added
|
||||
- Fichiers docs manquants référencés par l’index: `SECURITY.md`, `GITEA_SETUP.md`, `DEVELOPMENT.md`, `INTEGRATION_4NK_NODE.md`, `ETAT_ACTUEL.md`, `RESUME_FINAL.md`, `SUPPORT.md`, `EXTERNAL_NODES.md`, `RELAY_NETWORK.md`.
|
||||
- Tests d’intégration Rust: `tests/smoke.rs`, `tests/error_mapping.rs`, `tests/special_roles.rs`; `tests/README.md`.
|
||||
|
||||
### Changed
|
||||
- Correction de liens internes dans `docs/COMMUNITY_GUIDE.md`.
|
||||
- Vérification et consolidation de `docs/INDEX.md`.
|
||||
- Mise à jour `docs/TESTING.md` pour référencer les tests Rust de la crate.
|
||||
|
||||
### Fixed
|
||||
- Compilation locale validée; aucun échec bloquant.
|
||||
|
@ -488,3 +488,12 @@ Pour obtenir de l'aide :
|
||||
- Tests d'API REST
|
||||
- Tests d'interface WebSocket
|
||||
- Tests de compatibilité
|
||||
|
||||
---
|
||||
|
||||
## Tests Rust (sdk_common)
|
||||
|
||||
- Emplacement: `tests/*.rs` (tests d’intégration Rust)
|
||||
- Exécution: `cargo test --all`
|
||||
- Journaux: `tests/logs/` (si redirection souhaitée)
|
||||
- Objectifs actuels: tests de fumée, mapping d’erreurs, conversions d’énumérations publiques
|
13
tests/README.md
Normal file
13
tests/README.md
Normal file
@ -0,0 +1,13 @@
|
||||
# Stratégie de tests
|
||||
|
||||
Ce répertoire regroupe les tests pour `sdk_common`.
|
||||
|
||||
- `tests/*.rs` : tests d’intégration Rust
|
||||
- `tests/logs/` : journaux d’exécution
|
||||
- `tests/reports/` : rapports et artefacts
|
||||
|
||||
Exécution:
|
||||
|
||||
- `cargo test --all`
|
||||
- `cargo clippy -- -D warnings`
|
||||
- `cargo fmt -- --check`
|
27
tests/error_mapping.rs
Normal file
27
tests/error_mapping.rs
Normal file
@ -0,0 +1,27 @@
|
||||
//! Vérifie le mapping depuis anyhow::Error vers AnkError
|
||||
|
||||
use sdk_common::error::AnkError;
|
||||
|
||||
#[test]
|
||||
fn anyhow_to_ankerror_generic() {
|
||||
let any = anyhow::anyhow!("some generic failure");
|
||||
let mapped: AnkError = any.into();
|
||||
match mapped {
|
||||
AnkError::GenericError(msg) => assert!(msg.contains("generic")),
|
||||
_ => panic!("mapping inattendu"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn anyhow_to_ankerror_specific_variants() {
|
||||
for (needle, expect_variant) in [
|
||||
("FaucetError: oops", "FaucetError"),
|
||||
("NewTxError: oops", "NewTxError"),
|
||||
("CipherError: oops", "CipherError"),
|
||||
] {
|
||||
let any = anyhow::anyhow!(needle);
|
||||
let mapped: AnkError = any.into();
|
||||
let label = format!("{:?}", mapped);
|
||||
assert!(label.contains(expect_variant), "{} should map to {}", needle, expect_variant);
|
||||
}
|
||||
}
|
63
tests/logs/test-run.log
Normal file
63
tests/logs/test-run.log
Normal file
@ -0,0 +1,63 @@
|
||||
|
||||
running 32 tests
|
||||
test pcd::tests::test_get_applicable_rules ... ok
|
||||
test pcd::tests::test_get_applicable_rules_no_rules ... ok
|
||||
test pcd::tests::test_validation_rule_new ... ok
|
||||
test pcd::tests::test_is_satisfied_error_cases ... ok
|
||||
test pcd::tests::test_satisfy_min_sig_member ... ok
|
||||
test pcd::tests::test_is_satisfied_error_quorum_half_with_alice_providing_two_proofs ... ok
|
||||
test pcd::tests::test_is_satisfied_error_with_alice_providing_proofs_for_bob ... ok
|
||||
test pcd::tests::test_partial_modification_not_satisfied ... ok
|
||||
test pcd::tests::test_no_rule_satisfied ... ok
|
||||
test pcd::tests::test_partial_modification_satisfied ... ok
|
||||
test pcd::tests::test_is_satisfied ... ok
|
||||
test process::tests::test_error_demiurge ... ok
|
||||
test process::tests::test_error_no_proofs ... ok
|
||||
test process::tests::test_error_demiurge_not_init_state ... ok
|
||||
test pcd::tests::test_all_rules_satisfied ... ok
|
||||
test process::tests::test_error_invalid_proof ... ok
|
||||
test process::tests::test_error_not_enough_signatures ... ok
|
||||
test process::tests::test_error_carol_votes_no ... ok
|
||||
test process::tests::test_error_pairing_add_device_wrong_signature ... ok
|
||||
test process::tests::test_error_invalid_obliteration ... ok
|
||||
test process::tests::test_error_not_right_signatures_with_prev_state ... ok
|
||||
test process::tests::test_error_pairing_wrong_proof ... ok
|
||||
test process::tests::test_valid_pairing_add_device ... ok
|
||||
test process::tests::test_valid_obliteration ... ok
|
||||
test process::tests::test_valid_pairing ... ok
|
||||
test process::tests::test_valid_pairing_rm_device ... ok
|
||||
test process::tests::test_valid_add_someone_role ... ok
|
||||
test process::tests::test_valid_just_enough_signatures ... ok
|
||||
test process::tests::test_valid_all_signatures ... ok
|
||||
test process::tests::test_valid_demiurge ... ok
|
||||
test process::tests::test_valid_everyone_signs_with_prev_state ... ok
|
||||
test process::tests::test_valid_bob_votes_no ... ok
|
||||
|
||||
test result: ok. 32 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.07s
|
||||
|
||||
|
||||
running 2 tests
|
||||
test anyhow_to_ankerror_generic ... ok
|
||||
test anyhow_to_ankerror_specific_variants ... ok
|
||||
|
||||
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
|
||||
|
||||
|
||||
running 2 tests
|
||||
test max_payload_reasonable ... ok
|
||||
test mutex_ext_lock_anyhow_ok ... ok
|
||||
|
||||
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
|
||||
|
||||
|
||||
running 2 tests
|
||||
test reserved_fields_roundtrip ... ok
|
||||
test special_roles_roundtrip ... ok
|
||||
|
||||
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
|
||||
|
||||
|
||||
running 0 tests
|
||||
|
||||
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
|
||||
|
18
tests/smoke.rs
Normal file
18
tests/smoke.rs
Normal file
@ -0,0 +1,18 @@
|
||||
//! Tests de fumée basiques pour sdk_common
|
||||
|
||||
use sdk_common::{MAX_PRD_PAYLOAD_SIZE, MutexExt};
|
||||
use std::sync::Mutex;
|
||||
|
||||
#[test]
|
||||
fn max_payload_reasonable() {
|
||||
// Vérifie que la constante a une valeur cohérente (>0 et <= u16::MAX)
|
||||
assert!(MAX_PRD_PAYLOAD_SIZE > 0);
|
||||
assert!(MAX_PRD_PAYLOAD_SIZE as u64 <= u16::MAX as u64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mutex_ext_lock_anyhow_ok() {
|
||||
let m = Mutex::new(42_u32);
|
||||
let g = m.lock_anyhow().expect("lock_anyhow doit réussir sur un mutex non empoisonné");
|
||||
assert_eq!(*g, 42);
|
||||
}
|
25
tests/special_roles.rs
Normal file
25
tests/special_roles.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use sdk_common::{ReservedFields, SpecialRoles};
|
||||
use std::str::FromStr;
|
||||
|
||||
#[test]
|
||||
fn special_roles_roundtrip() {
|
||||
for (s, v) in [("demiurge", SpecialRoles::Demiurge), ("pairing", SpecialRoles::Pairing), ("apophis", SpecialRoles::Apophis)] {
|
||||
let parsed = SpecialRoles::from_str(s).expect("parse role");
|
||||
assert_eq!(parsed, v);
|
||||
let as_str: &str = (&parsed).into();
|
||||
assert_eq!(as_str, s);
|
||||
assert_eq!(parsed.to_string(), s);
|
||||
}
|
||||
assert!(SpecialRoles::from_str("unknown").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reserved_fields_roundtrip() {
|
||||
for (s, v) in [("memberPublicName", ReservedFields::MemberPublicName), ("pairedAddresses", ReservedFields::PairedAddresses)] {
|
||||
let parsed = ReservedFields::from_str(s).expect("parse field");
|
||||
assert_eq!(parsed, v);
|
||||
let as_str: &str = (&parsed).into();
|
||||
assert_eq!(as_str, s);
|
||||
}
|
||||
assert!(ReservedFields::from_str("unknown").is_err());
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user