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

feat: Add auto deserialization of reply data (#445) #448

Merged
merged 3 commits into from
Oct 31, 2024

Conversation

jawoznia
Copy link
Collaborator

No description provided.

@jawoznia jawoznia force-pushed the jawoznia/feat/data_deserialization branch from 8c509ad to e42fc9e Compare October 18, 2024 14:07
@jawoznia jawoznia force-pushed the jawoznia/feat/data_deserialization branch from e42fc9e to c580365 Compare October 21, 2024 14:00
Copy link

codecov bot commented Oct 21, 2024

Codecov Report

Attention: Patch coverage is 84.09091% with 28 lines in your changes missing coverage. Please review.

Project coverage is 72.49%. Comparing base (b043037) to head (30da5ec).
Report is 3 commits behind head on feat/replies.

Files with missing lines Patch % Lines
sylvia-derive/src/parser/attributes/data.rs 62.96% 10 Missing ⚠️
sylvia-derive/src/parser/attributes/payload.rs 50.00% 8 Missing ⚠️
sylvia/tests/reply_data.rs 90.00% 4 Missing ⚠️
sylvia-derive/src/parser/attributes/mod.rs 72.72% 3 Missing ⚠️
sylvia-derive/src/contract/communication/reply.rs 97.50% 2 Missing ⚠️
sylvia/tests/reply_generation.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           feat/replies     #448      +/-   ##
================================================
+ Coverage         71.95%   72.49%   +0.53%     
================================================
  Files                59       62       +3     
  Lines              3634     3795     +161     
================================================
+ Hits               2615     2751     +136     
- Misses             1019     1044      +25     

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

@jawoznia jawoznia marked this pull request as ready for review October 21, 2024 14:32
@jawoznia jawoznia linked an issue Oct 22, 2024 that may be closed by this pull request
Copy link
Collaborator

@hashedone hashedone left a comment

Choose a reason for hiding this comment

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

LGTM, but with some comments - mostly to briefly talk through before merging. Most of them might be wontfix, but let's at least consider them.

Comment on lines 25 to 26
// If the `data` attribute is missing, the data field should be omitted.
_data: Option<Binary>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't really get i t - why exactly the _data is not now interpreted as a part of a payload? I am not sure about this being wrong in any way. Maybe we could warn here that this looks like a missing attribute, but I don't think it's an error.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right. I missed test for missing sv::data parameter. It is impossible to consistently detect missing sv::data attribute.

}
}

mod tests {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm wondering if there is point to have additional module here? Not a strong opinion, but seems obsolete.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not needed. It's mostly to separate the imports, but it doesn't benefit us really,

fn data(
&self,
_ctx: ReplyCtx,
#[sv::data] _data: String,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm wondering about one test with a bit more complex type than a String that goes through serialization process.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will add that

// MultiTest version is released.
// Payload is not currently forwarded in the MultiTest.
// _instantiate_payload: InstantiatePayload,
#[sv::payload] _payload: Binary,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it was supposed to be #[sv::payload(raw)], right? Or is it a part of different PR (that would make sense as this is the data, not payload one).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It should be done as part of this PR. Thank you for pointing this out.

};
},
_ => {
emit_error!(self.name().span(), "Invalid data usage.";
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am wondering if there is a way to include the error testing we have in ui to the cov report... We could technically do the #[tarpaulin(ingore)] here but this then doesn't check if the path is ever tested... Just leaving as an idea, maybe we could create issue for this, idk.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We have an issue for this #339. Unfortunately I don't see a way to do that since trybuild runs its own compilations. If we would figure out something there is an issue to track that though.

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.

Interesting feature, good job!

sylvia/tests/ui/attributes/data/missing_attribute.rs Outdated Show resolved Hide resolved
Expect `(raw)` parameter in the `sv::payload` attribute.
@jawoznia jawoznia force-pushed the jawoznia/feat/data_deserialization branch from 36e3267 to 30da5ec Compare October 31, 2024 11:08
@jawoznia jawoznia merged commit 3c89bcc into feat/replies Oct 31, 2024
9 checks passed
@jawoznia jawoznia deleted the jawoznia/feat/data_deserialization branch October 31, 2024 11:30
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.

Auto deserialize data
3 participants