v0.3.8-pre.008
This commit is contained in:
56
crates/ksp-app-store-desk/unit_tests/dto_account.rs
Normal file
56
crates/ksp-app-store-desk/unit_tests/dto_account.rs
Normal file
@@ -0,0 +1,56 @@
|
||||
// file: crates/ksp-app-store-desk/unit_tests/dto_account.rs
|
||||
// version: 1
|
||||
|
||||
#[test]
|
||||
fn pre_008_account_rows_are_data_free_and_detail_preview_is_explicitly_bounded() {
|
||||
let row = crate::StoreAccountRowDto {
|
||||
data_length_decimal: "2048".to_owned(),
|
||||
executable: false,
|
||||
lamports_decimal: "12345678901234567890".to_owned(),
|
||||
owner: "11111111111111111111111111111111".to_owned(),
|
||||
pubkey: "SysvarRent111111111111111111111111111111111".to_owned(),
|
||||
rent_epoch_decimal: "18446744073709551615".to_owned(),
|
||||
slot_decimal: "987654321".to_owned(),
|
||||
state_hash: "11".repeat(32),
|
||||
};
|
||||
let serialized = serde_json::to_value(&row);
|
||||
assert!(serialized.is_ok());
|
||||
let serialized = match serialized {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
assert!(serialized.get("dataPreviewHex").is_none());
|
||||
assert!(serialized.get("data").is_none());
|
||||
assert_eq!(serialized["dataLengthDecimal"], "2048");
|
||||
let detail = crate::StoreAccountDetailDto {
|
||||
data_length_decimal: "8192".to_owned(),
|
||||
data_preview_hex: "abcd".to_owned(),
|
||||
data_preview_truncated: true,
|
||||
executable: true,
|
||||
lamports_decimal: "42".to_owned(),
|
||||
owner: "11111111111111111111111111111111".to_owned(),
|
||||
pubkey: "SysvarRent111111111111111111111111111111111".to_owned(),
|
||||
rent_epoch_decimal: "7".to_owned(),
|
||||
slot_decimal: "99".to_owned(),
|
||||
state_hash: "22".repeat(32),
|
||||
};
|
||||
let serialized = serde_json::to_value(&detail);
|
||||
assert!(serialized.is_ok());
|
||||
let serialized = match serialized {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
assert_eq!(serialized["dataPreviewHex"], "abcd");
|
||||
assert_eq!(serialized["dataPreviewTruncated"], true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_008_account_query_request_contains_only_random_access_and_explicit_store_filters() {
|
||||
let source = include_str!("../src/dto_account.rs");
|
||||
for required in ["direction", "limit", "offset", "pubkey", "slot_max", "slot_min"] {
|
||||
assert!(source.contains(required), "missing Store account query field: {required}");
|
||||
}
|
||||
for forbidden in ["draw", "columns", "search", "order", "cursor", "network", "connection_uri", "endpoint"] {
|
||||
assert!(!source.contains(&format!("pub(crate) {forbidden}")), "DataTables/physical field leaked into Store account query DTO: {forbidden}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user