Decode packed event records for runtime import
This commit is contained in:
parent
83f55fa26e
commit
09b6514dbf
13 changed files with 1801 additions and 50 deletions
|
|
@ -4152,7 +4152,38 @@ mod tests {
|
|||
"packed_state_version_hex": "0x000003e9",
|
||||
"live_id_bound": 5,
|
||||
"live_record_count": 3,
|
||||
"live_entry_ids": [1, 3, 5]
|
||||
"live_entry_ids": [1, 3, 5],
|
||||
"decoded_record_count": 0,
|
||||
"imported_runtime_record_count": 0,
|
||||
"records": [
|
||||
{
|
||||
"record_index": 0,
|
||||
"live_entry_id": 1,
|
||||
"decode_status": "unsupported_framing",
|
||||
"grouped_effect_row_counts": [0, 0, 0, 0],
|
||||
"decoded_actions": [],
|
||||
"executable_import_ready": false,
|
||||
"notes": ["left fixture"]
|
||||
},
|
||||
{
|
||||
"record_index": 1,
|
||||
"live_entry_id": 3,
|
||||
"decode_status": "unsupported_framing",
|
||||
"grouped_effect_row_counts": [0, 0, 0, 0],
|
||||
"decoded_actions": [],
|
||||
"executable_import_ready": false,
|
||||
"notes": ["left fixture"]
|
||||
},
|
||||
{
|
||||
"record_index": 2,
|
||||
"live_entry_id": 5,
|
||||
"decode_status": "unsupported_framing",
|
||||
"grouped_effect_row_counts": [0, 0, 0, 0],
|
||||
"decoded_actions": [],
|
||||
"executable_import_ready": false,
|
||||
"notes": ["left fixture"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"event_runtime_records": []
|
||||
}
|
||||
|
|
@ -4178,7 +4209,29 @@ mod tests {
|
|||
"packed_state_version_hex": "0x000003e9",
|
||||
"live_id_bound": 5,
|
||||
"live_record_count": 2,
|
||||
"live_entry_ids": [1, 5]
|
||||
"live_entry_ids": [1, 5],
|
||||
"decoded_record_count": 0,
|
||||
"imported_runtime_record_count": 0,
|
||||
"records": [
|
||||
{
|
||||
"record_index": 0,
|
||||
"live_entry_id": 1,
|
||||
"decode_status": "unsupported_framing",
|
||||
"grouped_effect_row_counts": [0, 0, 0, 0],
|
||||
"decoded_actions": [],
|
||||
"executable_import_ready": false,
|
||||
"notes": ["right fixture"]
|
||||
},
|
||||
{
|
||||
"record_index": 1,
|
||||
"live_entry_id": 5,
|
||||
"decode_status": "unsupported_framing",
|
||||
"grouped_effect_row_counts": [0, 0, 0, 0],
|
||||
"decoded_actions": [],
|
||||
"executable_import_ready": false,
|
||||
"notes": ["right fixture"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"event_runtime_records": []
|
||||
}
|
||||
|
|
@ -4210,6 +4263,155 @@ mod tests {
|
|||
.expect("snapshot-backed packed-event fixture should summarize");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn summarizes_snapshot_backed_fixture_with_imported_packed_event_record() {
|
||||
let fixture_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../../fixtures/runtime/packed-event-record-import-from-snapshot.json");
|
||||
|
||||
run_runtime_summarize_fixture(&fixture_path)
|
||||
.expect("snapshot-backed imported packed-event fixture should summarize");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn diffs_runtime_states_with_packed_record_and_runtime_record_import_changes() {
|
||||
let left = serde_json::json!({
|
||||
"format_version": 1,
|
||||
"snapshot_id": "left-packed-import",
|
||||
"state": {
|
||||
"calendar": {
|
||||
"year": 1830,
|
||||
"month_slot": 0,
|
||||
"phase_slot": 0,
|
||||
"tick_slot": 0
|
||||
},
|
||||
"world_flags": {},
|
||||
"companies": [],
|
||||
"packed_event_collection": {
|
||||
"source_kind": "packed-event-runtime-collection",
|
||||
"mechanism_family": "classic-save-rehydrate-v1",
|
||||
"mechanism_confidence": "grounded",
|
||||
"container_profile_family": "rt3-classic-save-container-v1",
|
||||
"packed_state_version": 1001,
|
||||
"packed_state_version_hex": "0x000003e9",
|
||||
"live_id_bound": 7,
|
||||
"live_record_count": 1,
|
||||
"live_entry_ids": [7],
|
||||
"decoded_record_count": 0,
|
||||
"imported_runtime_record_count": 0,
|
||||
"records": [
|
||||
{
|
||||
"record_index": 0,
|
||||
"live_entry_id": 7,
|
||||
"decode_status": "unsupported_framing",
|
||||
"grouped_effect_row_counts": [0, 0, 0, 0],
|
||||
"decoded_actions": [],
|
||||
"executable_import_ready": false,
|
||||
"notes": ["left placeholder"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"event_runtime_records": []
|
||||
}
|
||||
});
|
||||
let right = serde_json::json!({
|
||||
"format_version": 1,
|
||||
"snapshot_id": "right-packed-import",
|
||||
"state": {
|
||||
"calendar": {
|
||||
"year": 1830,
|
||||
"month_slot": 0,
|
||||
"phase_slot": 0,
|
||||
"tick_slot": 0
|
||||
},
|
||||
"world_flags": {},
|
||||
"companies": [],
|
||||
"packed_event_collection": {
|
||||
"source_kind": "packed-event-runtime-collection",
|
||||
"mechanism_family": "classic-save-rehydrate-v1",
|
||||
"mechanism_confidence": "grounded",
|
||||
"container_profile_family": "rt3-classic-save-container-v1",
|
||||
"packed_state_version": 1001,
|
||||
"packed_state_version_hex": "0x000003e9",
|
||||
"live_id_bound": 7,
|
||||
"live_record_count": 1,
|
||||
"live_entry_ids": [7],
|
||||
"decoded_record_count": 1,
|
||||
"imported_runtime_record_count": 1,
|
||||
"records": [
|
||||
{
|
||||
"record_index": 0,
|
||||
"live_entry_id": 7,
|
||||
"payload_offset": 29186,
|
||||
"payload_len": 64,
|
||||
"decode_status": "executable",
|
||||
"trigger_kind": 7,
|
||||
"active": true,
|
||||
"marks_collection_dirty": false,
|
||||
"one_shot": false,
|
||||
"text_bands": [
|
||||
{
|
||||
"label": "primary_text_band",
|
||||
"packed_len": 5,
|
||||
"present": true,
|
||||
"preview": "Alpha"
|
||||
}
|
||||
],
|
||||
"standalone_condition_row_count": 1,
|
||||
"grouped_effect_row_counts": [0, 1, 0, 0],
|
||||
"decoded_actions": [
|
||||
{
|
||||
"kind": "set_world_flag",
|
||||
"key": "from_packed_root",
|
||||
"value": true
|
||||
}
|
||||
],
|
||||
"executable_import_ready": true,
|
||||
"notes": ["decoded test record"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"event_runtime_records": [
|
||||
{
|
||||
"record_id": 7,
|
||||
"trigger_kind": 7,
|
||||
"active": true,
|
||||
"marks_collection_dirty": false,
|
||||
"one_shot": false,
|
||||
"has_fired": false,
|
||||
"effects": [
|
||||
{
|
||||
"kind": "set_world_flag",
|
||||
"key": "from_packed_root",
|
||||
"value": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
let left_path = write_temp_json("runtime-diff-packed-import-left", &left);
|
||||
let right_path = write_temp_json("runtime-diff-packed-import-right", &right);
|
||||
|
||||
let left_state =
|
||||
load_normalized_runtime_state(&left_path).expect("left runtime state should load");
|
||||
let right_state =
|
||||
load_normalized_runtime_state(&right_path).expect("right runtime state should load");
|
||||
let differences = diff_json_values(&left_state, &right_state);
|
||||
|
||||
assert!(differences.iter().any(|entry| {
|
||||
entry.path == "$.packed_event_collection.records[0].decode_status"
|
||||
|| entry.path == "$.packed_event_collection.records[0].decoded_actions[0]"
|
||||
}));
|
||||
assert!(
|
||||
differences
|
||||
.iter()
|
||||
.any(|entry| entry.path == "$.event_runtime_records[0]")
|
||||
);
|
||||
|
||||
let _ = fs::remove_file(left_path);
|
||||
let _ = fs::remove_file(right_path);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn diffs_classic_profile_samples_across_multiple_files() {
|
||||
let sample_a = RuntimeClassicProfileSample {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue