mirror of
https://github.com/bybrooklyn/openbitdo.git
synced 2026-03-19 12:12:57 -04:00
Bootstrap OpenBitdo clean-room SDK and reliability milestone
This commit is contained in:
29
sdk/tests/parser_rejection.rs
Normal file
29
sdk/tests/parser_rejection.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use bitdo_proto::{validate_response, CommandId, ResponseStatus};
|
||||
|
||||
#[test]
|
||||
fn malformed_response_is_rejected() {
|
||||
let status = validate_response(CommandId::GetPid, &[0x02]);
|
||||
assert_eq!(status, ResponseStatus::Malformed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_signature_is_rejected() {
|
||||
let mut bad = vec![0u8; 64];
|
||||
bad[0] = 0x00;
|
||||
bad[1] = 0x05;
|
||||
bad[4] = 0xC1;
|
||||
let status = validate_response(CommandId::GetPid, &bad);
|
||||
assert_eq!(status, ResponseStatus::Invalid);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valid_signature_is_accepted() {
|
||||
let mut good = vec![0u8; 64];
|
||||
good[0] = 0x02;
|
||||
good[1] = 0x05;
|
||||
good[4] = 0xC1;
|
||||
good[22] = 0x09;
|
||||
good[23] = 0x60;
|
||||
let status = validate_response(CommandId::GetPid, &good);
|
||||
assert_eq!(status, ResponseStatus::Ok);
|
||||
}
|
||||
Reference in New Issue
Block a user