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

Add JSON marshalling to Result #1627

Merged
merged 1 commit into from
Oct 3, 2024
Merged

Add JSON marshalling to Result #1627

merged 1 commit into from
Oct 3, 2024

Conversation

aaronbuchwald
Copy link
Collaborator

This PR adds JSON marshalling support for chain.Result to improve JSON output per #1606 (comment)

resultJSON, err := json.Marshal(result)
require.NoError(err)

expectedJSON := fmt.Sprintf(`{"error":%q,"fee":4,"outputs":[%q],"success":true,"units":%s}`, codec.Bytes(errStrBytes), codec.Bytes(outputBytes), string(unitsJSON))
Copy link
Contributor

Choose a reason for hiding this comment

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

(No action required) Maybe just round trip the Result type and compare the original and the unmarshaled values?

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'd prefer to include the expectedJSON check as well to make sure it's clear that it's returning reasonable JSON output. THis makes it more explicit that we don't have any unexpected values like JSON keys that start with capital letters because there are no annotations.

Certainly may remove this at some point, but I think this is reasonable to include as we are cleaning up the JSON output.

@aaronbuchwald aaronbuchwald merged commit f1bcc59 into main Oct 3, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants