Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hansieodendaal committed May 22, 2024
1 parent 5d64cd3 commit cc3258d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions comms/core/src/protocol/rpc/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,10 @@ impl RpcResponse {
}

pub fn exceeded_message_size(self) -> RpcResponse {
const BYTES_PER_MB: f32 = 1024.0 * 1024.0;
// Precision loss is acceptable because this is for display purposes only
let msg = format!(
"The response size exceeded the maximum allowed payload size. Max = {:.4} MiB, Got = {:.4} MiB",
rpc::max_response_payload_size() as f32 / BYTES_PER_MB,
self.payload.len() as f32 / BYTES_PER_MB,
"The response size exceeded the maximum allowed payload size. Max = {} bytes, Got = {} bytes",
rpc::max_response_payload_size() as f32,
self.payload.len() as f32,
);
warn!(target: LOG_TARGET, "{}", msg);
RpcResponse {
Expand Down
4 changes: 2 additions & 2 deletions comms/core/src/protocol/rpc/test/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,15 @@ async fn response_too_big() {

// RPC_MAX_FRAME_SIZE bytes will always be too large because of the overhead of the RpcResponse proto message
let err = client
.reply_with_msg_of_size(rpc::max_response_payload_size() as u64 + 1)
.reply_with_msg_of_size(rpc::max_response_payload_size() as u64 - 4)
.await
.unwrap_err();
unpack_enum!(RpcError::RequestFailed(status) = err);
unpack_enum!(RpcStatusCode::MalformedResponse = status.as_status_code());

// Check that the exact frame size boundary works and that the session is still going
let _string = client
.reply_with_msg_of_size(rpc::max_response_payload_size() as u64 - 9)
.reply_with_msg_of_size(rpc::max_response_payload_size() as u64 - 5)
.await
.unwrap();
}
Expand Down

0 comments on commit cc3258d

Please sign in to comment.