Skip to content

Commit 90765a3

Browse files
committed
test: add into_versioned V0/V1 dispatch coverage
Guard the conditional wire-format dispatch from regressions: - V1-only events must stay on the V0/SCALE path (backward compat). - Any V2 event must force the V1 msgpack path so the `version` field round-trips through the cert/RPC boundary.
1 parent ca0f577 commit 90765a3

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

dstack-attest/src/attestation.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,4 +1399,39 @@ mod tests {
13991399
_ => panic!("expected dstack stack"),
14001400
}
14011401
}
1402+
1403+
#[test]
1404+
fn into_versioned_uses_v0_when_all_events_are_v1() {
1405+
let mut att = dummy_tdx_attestation([7u8; 64]);
1406+
att.runtime_events.push(cc_eventlog::RuntimeEvent::new(
1407+
"app-id".into(),
1408+
vec![1, 2, 3],
1409+
cc_eventlog::EventLogVersion::V1,
1410+
));
1411+
let versioned = att.into_versioned();
1412+
assert!(
1413+
matches!(versioned, VersionedAttestation::V0 { .. }),
1414+
"V1-only events should stay on the V0/SCALE wire format"
1415+
);
1416+
}
1417+
1418+
#[test]
1419+
fn into_versioned_upgrades_to_v1_when_any_event_is_v2() {
1420+
let mut att = dummy_tdx_attestation([8u8; 64]);
1421+
att.runtime_events.push(cc_eventlog::RuntimeEvent::new(
1422+
"app-id".into(),
1423+
vec![1, 2, 3],
1424+
cc_eventlog::EventLogVersion::V1,
1425+
));
1426+
att.runtime_events.push(cc_eventlog::RuntimeEvent::new(
1427+
"compose-hash".into(),
1428+
vec![4, 5, 6],
1429+
cc_eventlog::EventLogVersion::V2,
1430+
));
1431+
let versioned = att.into_versioned();
1432+
assert!(
1433+
matches!(versioned, VersionedAttestation::V1 { .. }),
1434+
"presence of a V2 event must force the V1 msgpack wire format to preserve `version`"
1435+
);
1436+
}
14021437
}

0 commit comments

Comments
 (0)