46 lines
2.4 KiB
Rust
46 lines
2.4 KiB
Rust
// file: crates/ksp-app-backfill-desk/unit_tests/dto_backfill.rs
|
|
// version: 2
|
|
|
|
#[test]
|
|
fn request_limits_are_derived_from_job_owned_public_bounds() {
|
|
let limits = crate::backfill_request_limits();
|
|
assert!(limits.is_ok());
|
|
let limits = match limits {
|
|
std::result::Result::Ok(value) => value,
|
|
std::result::Result::Err(_) => return,
|
|
};
|
|
assert_eq!(usize::try_from(limits.max_page_size), std::result::Result::Ok(ksp_job_backfill_lib::MAX_BACKFILL_PAGE_SIZE));
|
|
assert_eq!(usize::try_from(limits.max_pages), std::result::Result::Ok(ksp_job_backfill_lib::MAX_BACKFILL_PAGES));
|
|
assert_eq!(usize::try_from(limits.max_candidates), std::result::Result::Ok(ksp_job_backfill_lib::MAX_BACKFILL_CANDIDATES));
|
|
assert_eq!(usize::try_from(limits.max_hydration_concurrency), std::result::Result::Ok(ksp_job_backfill_lib::MAX_BACKFILL_HYDRATION_CONCURRENCY));
|
|
assert_eq!(usize::try_from(limits.min_signature_text_bytes), std::result::Result::Ok(ksp_job_backfill_lib::MIN_BACKFILL_SIGNATURE_TEXT_BYTES));
|
|
assert_eq!(usize::try_from(limits.max_signature_text_bytes), std::result::Result::Ok(ksp_job_backfill_lib::MAX_BACKFILL_SIGNATURE_TEXT_BYTES));
|
|
assert!(limits.default_page_size <= limits.max_page_size);
|
|
assert!(limits.default_max_pages <= limits.max_pages);
|
|
assert!(limits.default_max_candidates <= limits.max_candidates);
|
|
assert!(limits.default_hydration_concurrency <= limits.max_hydration_concurrency);
|
|
}
|
|
|
|
#[test]
|
|
fn request_options_expose_exact_current_commitments_and_http_scopes() {
|
|
assert_eq!(crate::backfill_commitment_codes(), vec!["finalized".to_owned(), "confirmed".to_owned()]);
|
|
assert_eq!(
|
|
crate::backfill_scope_kind_codes(),
|
|
vec!["latest_address".to_owned(), "before_address".to_owned(), "after_address".to_owned(), "explicit_signatures".to_owned()]
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn start_acknowledgement_contains_only_backend_job_identity_and_initial_state() {
|
|
let response = crate::BackfillStartResponseDto { job_id: "backfill-desk-1".to_owned(), state: "created".to_owned() };
|
|
let serialized = serde_json::to_string(&response);
|
|
assert!(serialized.is_ok());
|
|
if let std::result::Result::Ok(serialized) = serialized {
|
|
assert!(serialized.contains("backfill-desk-1"));
|
|
assert!(serialized.contains("created"));
|
|
for forbidden in ["address", "signature", "provider", "endpoint", "credential", "token"] {
|
|
assert!(!serialized.contains(forbidden));
|
|
}
|
|
}
|
|
}
|