v0.3.8-pre.003
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-store-api/tests/security_hardening.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
//! Adversarial and retention-race canaries for the Store API RAW foundation.
|
||||
|
||||
@@ -122,3 +122,47 @@ fn pre_007_retention_outcome_distinguishes_lost_compare_and_transition_race() {
|
||||
assert_ne!(ksp_store_api::RawRetentionWriteOutcome::AlreadyAtTarget, ksp_store_api::RawRetentionWriteOutcome::ExpectedStateMismatch);
|
||||
return;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v0_3_8_pre_003_inspection_summaries_and_counts_reject_payload_shaped_or_inconsistent_state() {
|
||||
let network = match ksp_store_api::RawNetworkId::new("mainnet-beta".to_owned()) {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
let format = match ksp_store_api::RawFormatId::new("ksp.solana.raw_transaction".to_owned()) {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
let transaction_reference = ksp_store_api::RawTransactionReference::new(network.clone(), ksp_store_api::RawTransactionSignature::new([0x61_u8; 64]));
|
||||
let summary = ksp_store_api::RawTransactionSummary::try_new(
|
||||
transaction_reference,
|
||||
42,
|
||||
std::option::Option::None,
|
||||
format,
|
||||
1,
|
||||
ksp_store_api::RawContentHash::new([0x62_u8; 32]),
|
||||
std::option::Option::Some(512),
|
||||
ksp_store_api::RawRetentionState::Full,
|
||||
);
|
||||
assert!(summary.is_ok());
|
||||
let summary = match summary {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
let debug = std::format!("{summary:?}");
|
||||
assert!(!debug.contains(HOSTILE_MARKER));
|
||||
assert!(!debug.contains("payload:"));
|
||||
let account_reference = ksp_store_api::RawAccountStateReference::new(
|
||||
network,
|
||||
ksp_store_api::Pubkey::new_from_array([0x63_u8; 32]),
|
||||
43,
|
||||
ksp_store_api::RawContentHash::new([0x64_u8; 32]),
|
||||
);
|
||||
assert!(
|
||||
ksp_store_api::RawAccountStateSummary::try_new(account_reference, 1, ksp_store_api::Pubkey::new_from_array([0x65_u8; 32]), false, 0, 16_777_217,)
|
||||
.is_err()
|
||||
);
|
||||
assert!(ksp_store_api::RawInspectionPage::<u64>::try_new(std::vec![1], 0, 0).is_err());
|
||||
assert!(ksp_store_api::RawInspectionPage::<u64>::try_new(std::vec::Vec::new(), 1, 2).is_err());
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user