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:
1 parent
f928935989
commit
654cffdf31
6 files changed
+523
-4
No files matched your search
@@ -0,0 +1,77 @@
|
||||
//! # Mock runtime canonical para integration tests v0.0.18
|
||||
//!
|
||||
//! Provee mock minimal `Test` runtime composition (`System` + `Provenance` solo)
|
||||
//! para E2E tests dispatchable + storage + event assertions per PROV-3 flow
|
||||
//! 6-step canonical:
|
||||
//!
|
||||
//! 1. PROV-4 Ed25519 signature verification
|
||||
//! 2. PROV-5 validator OIT level >= 3 institutional
|
||||
//! 3. PROV-6 is_anchorable check (verdict + severity)
|
||||
//! 4. PROV-2 ValidationAttestation → AssetAttestation conversion
|
||||
//! 5. PROV-2 StorageMap insert
|
||||
//! 6. PROV-7 AssetAttested event emission
|
||||
//!
|
||||
//! ## Cross-reference canonical
|
||||
//!
|
||||
//! - DC `ORIGIN_PROVENANCE_PALLET_V1` PROV-1..8 sub-decisions
|
||||
//! - `tests_integration.rs` 5 scenarios canonical E2E
|
||||
//! - `lib.rs::pallet::attest_asset` dispatchable impl real
|
||||
|
||||
#![cfg(test)]
|
||||
|
||||
use crate as origin_chain_provenance;
|
||||
use frame_support::derive_impl;
|
||||
use sp_runtime::BuildStorage;
|
||||
|
||||
/// Mock block type canonical para tests.
|
||||
type Block = frame_system::mocking::MockBlock<Test>;
|
||||
|
||||
frame_support::construct_runtime!(
|
||||
pub enum Test {
|
||||
System: frame_system,
|
||||
Provenance: origin_chain_provenance,
|
||||
}
|
||||
);
|
||||
|
||||
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
|
||||
impl frame_system::Config for Test {
|
||||
type Block = Block;
|
||||
type AccountId = sp_runtime::AccountId32;
|
||||
type Lookup = sp_runtime::traits::IdentityLookup<Self::AccountId>;
|
||||
}
|
||||
|
||||
impl origin_chain_provenance::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
}
|
||||
|
||||
/// Test externalities builder canonical.
|
||||
///
|
||||
/// Returns new `sp_io::TestExternalities` con frame_system genesis configurado
|
||||
/// y block_number set to 1 (PROV-7 events requieren block_number > 0 para
|
||||
/// proper testing canonical).
|
||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
let mut ext: sp_io::TestExternalities = frame_system::GenesisConfig::<Test>::default()
|
||||
.build_storage()
|
||||
.expect("genesis canonical builds")
|
||||
.into();
|
||||
ext.execute_with(|| {
|
||||
System::set_block_number(1);
|
||||
});
|
||||
ext
|
||||
}
|
||||
|
||||
/// Test signing key seed canonical (deterministic Ed25519 keypair).
|
||||
///
|
||||
/// Per ed25519-dalek pattern: seed [7u8; 32] produces deterministic verifying_key.
|
||||
/// Used across integration tests para reproducible signing.
|
||||
pub const TEST_SIGNING_SEED: [u8; 32] = [7u8; 32];
|
||||
|
||||
/// Test origin account canonical (32-byte zero pattern).
|
||||
pub fn alice_origin() -> RuntimeOrigin {
|
||||
RuntimeOrigin::signed(sp_runtime::AccountId32::new([1u8; 32]))
|
||||
}
|
||||
|
||||
/// Test origin account canonical (BOB pattern).
|
||||
pub fn bob_origin() -> RuntimeOrigin {
|
||||
RuntimeOrigin::signed(sp_runtime::AccountId32::new([2u8; 32]))
|
||||
}
|
||||
Reference in new issue
Block a user