Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Review fixes #458

Merged
merged 3 commits into from
Nov 19, 2024
Merged

Conversation

jawoznia
Copy link
Collaborator

No description provided.

Copy link

codecov bot commented Nov 13, 2024

Codecov Report

Attention: Patch coverage is 53.48837% with 20 lines in your changes missing coverage. Please review.

Project coverage is 72.12%. Comparing base (4f09075) to head (ceb476c).
Report is 3 commits behind head on feat/replies.

Files with missing lines Patch % Lines
sylvia-derive/src/contract/communication/reply.rs 53.48% 20 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           feat/replies     #458      +/-   ##
================================================
- Coverage         72.37%   72.12%   -0.26%     
================================================
  Files                63       63              
  Lines              3823     3860      +37     
================================================
+ Hits               2767     2784      +17     
- Misses             1056     1076      +20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Copy link
Contributor

@kulikthebird kulikthebird left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good to have that check. There are some more examples to be checked as well

@@ -11,7 +11,36 @@ use crate::types::msg_field::MsgField;
use crate::types::msg_variant::{MsgVariant, MsgVariants};
use crate::utils::emit_turbofish;

const NUMBER_OF_DATA_FIELDS: usize = 1;
const NO_ALLOWED_DATA_FIELDS: usize = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO stands for number here? If so it's quite misleading in this context

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ye, number of. It is a bit if you don't check the type. I will revert this change.

fn first_reply(
&self,
_ctx: ReplyCtx,
#[sv::data(opt, raw)] _data: Option<Binary>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add few more combinations:

  1. What would happen if there is an additional argument before sv::data?
  2. What happen if we use #[sv::data(opt, raw)] on ctx: ReplyCtx?
  3. What happen if we use #[sv::payload(raw)] on ctx: ReplyCtx?
  4. What if we skip ctx: ReplyCtx?
  5. Can we use #[sv::data(raw)] after #[sv::payload(raw)]?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Missing payload parameter. - This might cause some weird behavior due to deserialization to empty tuple.

Good points.
For 2 and 3 nothing would happen as context types are skipped during parsing.
For 4 as in case of every message type it would fail with Rust compile error that context types couldn't be converted to whatever parameter is defined first. We are unable to check if the second parameter in the method signature is ReplyCtx as this would make usage of aliases impossible or very restricted and in the end wrong type could still be passed there.

Added test cases for the rest.

Copy link
Contributor

@kulikthebird kulikthebird left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for the new testcases and checks. Only one extra comment from me

@@ -0,0 +1,8 @@
error: Missing payload parameter.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not 100% accurate - there is a payload parameter

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually there is a payload attribute, not parameter ^^
But yeah, it's not 100% obvious, but it's such a niche error, I believe, that I thought it would be sufficient.
I will add check that no sv attributes were used on the self and ctx parameters.

@jawoznia jawoznia merged commit a7af42b into feat/replies Nov 19, 2024
7 of 9 checks passed
@jawoznia jawoznia deleted the jawoznia/replies/review-changes-2 branch November 19, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants