Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/src/messages/discard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ mod tests {
assert_eq!(&*marker_signature, &[0xB1, 0x2F]);
let extra: BoltMap = BoltMap::parse(Version::V4_1, &mut bytes).unwrap();

assert_eq!(extra.get::<i64>("n").unwrap(), 255);
assert_eq!(extra.get::<i64>("qid").unwrap(), 255);
assert_eq!(extra.get::<i64>("n").unwrap(), -1);
assert_eq!(extra.get::<i64>("qid").unwrap(), -1);
}
}
4 changes: 2 additions & 2 deletions lib/src/messages/pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ mod tests {
assert_eq!(&*marker_signature, &[0xB1, 0x3F]);
let extra: BoltMap = BoltMap::parse(Version::V4_1, &mut bytes).unwrap();

assert_eq!(extra.get::<i64>("n").unwrap(), 255);
assert_eq!(extra.get::<i64>("qid").unwrap(), 255);
assert_eq!(extra.get::<i64>("n").unwrap(), -1);
assert_eq!(extra.get::<i64>("qid").unwrap(), -1);
}
}
14 changes: 13 additions & 1 deletion lib/src/types/integer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl BoltWireFormat for BoltInteger {

fn parse(_version: Version, input: &mut Bytes) -> Result<Self> {
let value: i64 = match input.get_u8() {
marker if (-16..=127).contains(&(marker as i8)) => marker as i64,
marker if (-16..=127).contains(&(marker as i8)) => (marker as i8) as i64,
INT_8 => input.get_i8() as i64,
INT_16 => input.get_i16() as i64,
INT_32 => input.get_i32() as i64,
Expand Down Expand Up @@ -145,6 +145,18 @@ mod tests {

#[test]
fn should_deserialize_integer() {
let mut b = Bytes::from_static(&[0x00]);
let bolt_int: BoltInteger = BoltInteger::parse(Version::V4_1, &mut b).unwrap();
assert_eq!(bolt_int.value, 0);

let mut b = Bytes::from_static(&[0xF0]);
let bolt_int: BoltInteger = BoltInteger::parse(Version::V4_1, &mut b).unwrap();
assert_eq!(bolt_int.value, -16);

let mut b = Bytes::from_static(&[0x7F]);
let bolt_int: BoltInteger = BoltInteger::parse(Version::V4_1, &mut b).unwrap();
assert_eq!(bolt_int.value, 127);

let mut b = Bytes::from_static(&[0x2A]);
let bolt_int: BoltInteger = BoltInteger::parse(Version::V4_1, &mut b).unwrap();
assert_eq!(bolt_int.value, 42);
Expand Down
Loading