feat(provenance): v0.0.18 mock runtime integration tests E2E — 9 scenarios canonical own fixtures

Phase 2.1 PROVENANCE pallet — 9 integration tests E2E via FRAME mock runtime
composition (`construct_runtime!` macro + derive_impl + sp_io::TestExternalities).
Cierra honest disclosure sesión 2 ("real chain runtime aún NO arranca"). Pallet
end-to-end validado canonical sin esperar Slice 2e WASM resolution structural.

## 9 integration tests canonical PROV-3 flow

5 scenarios:
- scenario_1_passed_info_anchored_canonical (PROV-2/3/7) ✅
- scenario_2_warning_anchored_canonical (PROV-2/3/6/7) ✅
- scenario_3_failed_critical_rejected_canonical (PROV-6) ❌ NotAnchorable
- scenario_4_passed_block_security_rejected_canonical (PROV-6) ❌ NotAnchorable
- scenario_5_anonymous_level_0_rejected_canonical (PROV-5) ❌ ValidatorTierInsufficient

4 additional:
- additional_idempotency_already_attested_rejected_canonical (PROV-2) ❌ AlreadyAttested
- additional_tampered_signature_rejected_canonical (PROV-4) ❌ InvalidSignature
- additional_tampered_payload_rejected_canonical (PROV-4) ❌ InvalidSignature
- additional_6_step_prov_3_walkthrough_canonical (PROV-3 full) ✅ Pre/post assertions

## Own fixtures canonical

Per audit canonical sesión 3+ (docs/L7_roadmaps/AUDIT_CHARON_SESION_3_STATE_V1.md),
Ergon E2E fixture diary claim aspirational sin shipped commit verified — filesystem
+ git history confirma no source file canonical. Charon construye own fixtures
basados en vendor copy ValidationAttestation real existente. Pattern análogo
Slice 3 mock-WASM + v0.0.16 Ed25519 interim encoding.

## Files canonical

- NEW: crates/origin-chain-provenance/src/mock.rs (75 LOC mock runtime)
- NEW: crates/origin-chain-provenance/src/tests_integration.rs (270 LOC, 9 tests)
- EDIT: crates/origin-chain-provenance/Cargo.toml (sp-core+sp-io+sp-runtime dev-deps)
- EDIT: crates/origin-chain-provenance/src/lib.rs (mod mock + mod tests_integration + docstring v0.0.18)
- EDIT: CHANGELOG.md (v0.0.18 entry canonical pattern Phase 2.1)

## Verification

- cargo test -p origin-chain-provenance — 17 tests verde, 0 failures
  (9 integration + 6 standalone Ed25519 + 2 auto-generated)
- Workspace tests no regressions
- Cero warnings críticos

🎉 Phase 2.1 PROVENANCE pallet validated E2E via mock runtime canonical.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
davidherranandClaude Opus 4.7 committed 2026-05-24 22:40:04 -05:00
1 parent f928935989
commit 654cffdf31
6 files changed
+523 -4

No files matched your search

+96
View File
@@ -6,6 +6,102 @@ by [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versions follow
## [Unreleased]
## [0.0.18] — 2026-05-24 — Phase 2.1 mock runtime integration tests E2E (own fixtures, sesión 3+)
**Mock runtime canonical + 9 integration tests E2E PROV-3 flow** — Cierra honest disclosure
sesión 2 ("real chain runtime aún NO arranca por Slice 2e WASM blocker structural").
Pallet end-to-end validado via FRAME mock runtime composition (`construct_runtime!` macro
+ derive_impl + `sp_io::TestExternalities`), demostrando dispatchable + storage + events
funcionan correctamente sin esperar Slice 2e WASM resolution.
### Deliverables v0.0.18
**Mock runtime canonical (NEW file)**:
- `crates/origin-chain-provenance/src/mock.rs` — 75 LOC canonical
- `construct_runtime!` macro composition: `System` + `Provenance` (mínimo testing)
- `frame_system::Config` impl via `derive_impl(TestDefaultConfig)` + `AccountId32` canonical
- `new_test_ext()` helper canonical (`sp_io::TestExternalities` con `block_number=1` set)
- `alice_origin()` + `bob_origin()` helpers para testing dispatchables
- `TEST_SIGNING_SEED = [7u8; 32]` deterministic Ed25519 keypair canonical
**Integration tests canonical E2E (NEW file)**:
- `crates/origin-chain-provenance/src/tests_integration.rs` — 270 LOC canonical, 9 tests verde
**9 integration tests canonical PROV-3 flow** (5 scenarios + 4 additional):
| # | Test canonical | PROV | Expected outcome |
|---|----------------|------|------------------|
| 1 | `scenario_1_passed_info_anchored_canonical` | PROV-2/3/7 | ✅ AssetAttested event + storage insert |
| 2 | `scenario_2_warning_anchored_canonical` | PROV-2/3/6/7 | ✅ Warning verdict canonical anchorable |
| 3 | `scenario_3_failed_critical_rejected_canonical` | PROV-6 | ❌ NotAnchorable error |
| 4 | `scenario_4_passed_block_security_rejected_canonical` | PROV-6 | ❌ NotAnchorable (Block severity override) |
| 5 | `scenario_5_anonymous_level_0_rejected_canonical` | PROV-5 | ❌ ValidatorTierInsufficient |
| 6 | `additional_idempotency_already_attested_rejected_canonical` | PROV-2 | ❌ AlreadyAttested (idempotency) |
| 7 | `additional_tampered_signature_rejected_canonical` | PROV-4 | ❌ InvalidSignature (bit flip) |
| 8 | `additional_tampered_payload_rejected_canonical` | PROV-4 | ❌ InvalidSignature (payload mismatch) |
| 9 | `additional_6_step_prov_3_walkthrough_canonical` | PROV-3 full | ✅ Pre/post flight assertions |
**Cargo.toml dev-deps canonical (NEW)**:
- `sp-core` workspace default-features (AccountId32 + crypto canonical)
- `sp-io` workspace default-features (TestExternalities canonical)
- `sp-runtime` workspace default-features (BuildStorage + traits canonical)
**lib.rs canonical updates**:
- Docstring header updated v0.0.14 → v0.0.18 (status + v0.0.18 section added)
- `#[cfg(test)] pub mod mock;` declaration canonical
- `#[cfg(test)] mod tests_integration;` declaration canonical
### Own fixtures pattern canonical
Per audit canonical sesión 3+ (`docs/L7_roadmaps/AUDIT_CHARON_SESION_3_STATE_V1.md`),
Ergon E2E fixture diary claim 2026-05-24T14:11Z (`slice_7_0r_attestation_e2e_fixture.rs`
~520 LOC + JSON 90 LOC) **aspirational sin shipped commit verified** — filesystem +
git history + cross-branch search confirma no source file canonical existe.
Charon construye own fixtures canonical basados en vendor copy `ValidationAttestation`
real existente en `origin-chain-types/src/attestation.rs`. Builder canonical:
```rust
fn build_signed_attestation(asset_seed, verdict, severity, oit_level) -> ValidationAttestation {
let signing_key = SigningKey::from_bytes(&TEST_SIGNING_SEED);
let mut att = ValidationAttestation { ... };
let signature = signing_key.sign(&att.signing_payload());
att.signature = signature.to_bytes();
att
}
```
Pattern análogo Slice 3 mock-WASM canonical + v0.0.16 Ed25519 con interim encoding —
"avanza work conceptual mientras real (Ergon sub-crate Cap 42+) waits".
### Verification end-to-end canonical
- ✅ `cargo test -p origin-chain-provenance` — **17 tests verde, 0 failures**:
- 9 integration tests (`tests_integration` module)
- 6 standalone Ed25519 tests (`tests` module)
- 2 auto-generated (mock genesis + runtime integrity)
- ✅ Workspace tests no regressions
- ✅ Cero new warnings críticos (solo cosmetic missing_docs en construct_runtime macro-generated items)
### Roadmap canonical post-v0.0.18
| Version | Trigger |
|---------|---------|
| v0.0.19 | Swap canonical SCALE → postcard encoding cuando Ergon arkhe-noesis-attestation-types Cap 42+ ship (2026-05-30 → 06-05) |
| **v0.0.20** | **Phase 2.4 pallet-origin-fees scaffold (sesión 3+ shipping ahora)** |
| v0.0.21 | Phase 2.4 fees pallet wired runtime composition Index 8 |
| v0.0.22 | Phase 2.4 fees pallet impl complete + mock runtime integration tests E2E |
| v0.0.23 | Phase 2.4 Runtime API FeesApi canonical → Phase 2.4 COMPLETE |
| v0.1.0 | Slice 2e WASM resolved + full testnet Q3 2026 launch |
### Filosofía canonical sesión 3+ aplicada
David canon ratificado 2026-05-14 + lessons sesión 2 internalized: pattern audit-first
comparative (verify Ergon fixture claim → aspirational confirmed → build own) + notify-and-continue
(diary Ergon notify sin requires_ack, sin esperar response) + completeness over speed
(9 scenarios canonical exhaustivos vs minimal demo). "El barquero estudia el río antes
de cruzar — y avanza paralelo cuando el cauce principal espera."
## [0.0.17] — 2026-05-24 — Phase 2.1 COMPLETE — Runtime API verify_provenance (PROV-8 + 8/8 sub-decisions)
**🎉 Phase 2.1 PROVENANCE pallet COMPLETE end-to-end** — 8/8 PROV sub-decisions