mirror of
https://github.com/bybrooklyn/openbitdo.git
synced 2026-03-19 04:12:56 -04:00
Bootstrap OpenBitdo clean-room SDK and reliability milestone
This commit is contained in:
23
sdk/tests/frame_roundtrip.rs
Normal file
23
sdk/tests/frame_roundtrip.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use bitdo_proto::{command_registry, CommandFrame, CommandId, Report64};
|
||||
|
||||
#[test]
|
||||
fn frame_encode_decode_roundtrip_for_all_commands() {
|
||||
assert_eq!(command_registry().len(), CommandId::all().len());
|
||||
|
||||
for row in command_registry() {
|
||||
let frame = CommandFrame {
|
||||
id: row.id,
|
||||
payload: row.request.to_vec(),
|
||||
report_id: row.report_id,
|
||||
expected_response: row.expected_response,
|
||||
};
|
||||
|
||||
let encoded = frame.encode();
|
||||
if encoded.len() == 64 {
|
||||
let parsed = Report64::try_from(encoded.as_slice()).expect("64-byte frame parses");
|
||||
assert_eq!(parsed.as_slice(), encoded.as_slice());
|
||||
} else {
|
||||
assert!(!encoded.is_empty());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user