Skip to content

Commit 5e09ab9

Browse files
authored
Fix update topic serialization (#1400)
1 parent 96e8df5 commit 5e09ab9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

sdk/src/topics/update_topic.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl BytesSerializable for UpdateTopic {
8989
let stream_id_bytes = self.stream_id.to_bytes();
9090
let topic_id_bytes = self.topic_id.to_bytes();
9191
let mut bytes = BytesMut::with_capacity(
92-
14 + stream_id_bytes.len() + topic_id_bytes.len() + self.name.len(),
92+
19 + stream_id_bytes.len() + topic_id_bytes.len() + self.name.len(),
9393
);
9494
bytes.put_slice(&stream_id_bytes.clone());
9595
bytes.put_slice(&topic_id_bytes.clone());
@@ -107,7 +107,7 @@ impl BytesSerializable for UpdateTopic {
107107
}
108108

109109
fn from_bytes(bytes: Bytes) -> Result<UpdateTopic, IggyError> {
110-
if bytes.len() < 16 {
110+
if bytes.len() < 21 {
111111
return Err(IggyError::InvalidCommand);
112112
}
113113
let mut position = 0;
@@ -229,7 +229,7 @@ mod tests {
229229
let stream_id_bytes = stream_id.to_bytes();
230230
let topic_id_bytes = topic_id.to_bytes();
231231
let mut bytes =
232-
BytesMut::with_capacity(5 + stream_id_bytes.len() + topic_id_bytes.len() + name.len());
232+
BytesMut::with_capacity(19 + stream_id_bytes.len() + topic_id_bytes.len() + name.len());
233233
bytes.put_slice(&stream_id_bytes);
234234
bytes.put_slice(&topic_id_bytes);
235235
bytes.put_u8(compression_algorithm.as_code());
@@ -247,8 +247,10 @@ mod tests {
247247
let command = command.unwrap();
248248
assert_eq!(command.stream_id, stream_id);
249249
assert_eq!(command.topic_id, topic_id);
250+
assert_eq!(command.compression_algorithm, compression_algorithm);
250251
assert_eq!(command.message_expiry, message_expiry);
251-
assert_eq!(command.stream_id, stream_id);
252-
assert_eq!(command.topic_id, topic_id);
252+
assert_eq!(command.max_topic_size, max_topic_size);
253+
assert_eq!(command.replication_factor, Some(replication_factor));
254+
assert_eq!(command.name, name);
253255
}
254256
}

0 commit comments

Comments
 (0)