fix(network): handle end of list in tx monitor response (#305)
This commit is contained in:
parent
604b492dee
commit
9011a2e078
1 changed files with 24 additions and 8 deletions
|
|
@ -80,14 +80,19 @@ impl<'b> Decode<'b, ()> for Message {
|
||||||
// find the specs
|
// find the specs
|
||||||
4 => Ok(Message::AwaitAcquire),
|
4 => Ok(Message::AwaitAcquire),
|
||||||
5 => Ok(Message::RequestNextTx),
|
5 => Ok(Message::RequestNextTx),
|
||||||
6 => match d.datatype()? {
|
6 => match d.datatype() {
|
||||||
pallas_codec::minicbor::data::Type::Array
|
Ok(datatype) => {
|
||||||
| pallas_codec::minicbor::data::Type::ArrayIndef => {
|
match datatype {
|
||||||
let tx = d.decode()?;
|
pallas_codec::minicbor::data::Type::Array
|
||||||
Ok(Message::ResponseNextTx(Some(tx)))
|
| pallas_codec::minicbor::data::Type::ArrayIndef => {
|
||||||
}
|
let tx = d.decode()?;
|
||||||
_ => Ok(Message::ResponseNextTx(None)),
|
Ok(Message::ResponseNextTx(Some(tx)))
|
||||||
},
|
}
|
||||||
|
_ => Ok(Message::ResponseNextTx(None))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(_) => Ok(Message::ResponseNextTx(None))
|
||||||
|
}
|
||||||
7 => {
|
7 => {
|
||||||
let id = d.decode()?;
|
let id = d.decode()?;
|
||||||
Ok(Message::RequestHasTx(id))
|
Ok(Message::RequestHasTx(id))
|
||||||
|
|
@ -130,4 +135,15 @@ pub mod tests {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[test]
|
||||||
|
fn test_empty_next_tx_response() {
|
||||||
|
let bytes = vec![129, 6];
|
||||||
|
let msg: super::Message = pallas_codec::minicbor::decode(&bytes).unwrap();
|
||||||
|
|
||||||
|
if let super::Message::ResponseNextTx(None) = msg {
|
||||||
|
assert_eq!(0u64, 0u64);
|
||||||
|
} else {
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue