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

Added serde feature #413

Merged
merged 1 commit into from
Dec 17, 2024
Merged

Added serde feature #413

merged 1 commit into from
Dec 17, 2024

Conversation

d-sonuga
Copy link
Contributor

@d-sonuga d-sonuga commented Dec 6, 2024

@d-sonuga d-sonuga force-pushed the add-serde-feature branch 4 times, most recently from f54f6c7 to ad61992 Compare December 6, 2024 09:48
Copy link
Member

@Neotamandua Neotamandua left a comment

Choose a reason for hiding this comment

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

Looks good too. I just have the same comment as in another PR, whether we want to introduce so many custom error strings or just pass the underlying error through where applicable.

piecrust-uplink/src/serde_support.rs Outdated Show resolved Hide resolved
piecrust-uplink/tests/serde.rs Outdated Show resolved Hide resolved
@Neotamandua Neotamandua requested a review from miloszm December 6, 2024 15:11
@d-sonuga d-sonuga force-pushed the add-serde-feature branch 6 times, most recently from de3dffc to a8a3c66 Compare December 10, 2024 13:42
Copy link
Member

@Neotamandua Neotamandua left a comment

Choose a reason for hiding this comment

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

Looks good in general. I would suggest using the same seed for randomness in the test cases.

Additionally, I think adding another test that checks the equality of a serialized struct against a serde_json string of an event is a good idea to make sure we have a test case that can catch if the attribute names of the struct ever change.

Example:

    #[test]
    fn event_fields() {
        let serde_json_string = "{\"source\":\"0000000000000000000000000000000000000000000000000000000000000000\",\"topic\":\"\",\"data\":\"\"}";
        let event = Event {
            source: ContractId::from_bytes([0; CONTRACT_ID_BYTES]),
            topic: String::new(),
            data: Vec::new(),
        };
        let ser = serde_json::to_string(&event).unwrap();
        assert_eq!(serde_json_string, ser);
    }

piecrust-uplink/src/serde_support.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@miloszm miloszm left a comment

Choose a reason for hiding this comment

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

Overall looks very good, just test fun rename seems important to me
for practical test usability

piecrust-uplink/tests/serde.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@miloszm miloszm left a comment

Choose a reason for hiding this comment

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

LGTM

@Neotamandua Neotamandua linked an issue Dec 12, 2024 that may be closed by this pull request
@d-sonuga d-sonuga merged commit be4c8a0 into main Dec 17, 2024
6 checks passed
@d-sonuga d-sonuga deleted the add-serde-feature branch December 17, 2024 15:37
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.

Add Serde Feature
3 participants