-
Notifications
You must be signed in to change notification settings - Fork 22
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
Correctly omit transactionData
field when transaction simulation fails
#271
Conversation
c926dd7
to
83571a1
Compare
83571a1
to
2dddd45
Compare
that approach of sanitizing the json lower in conversion to empty string seems to be a bit cleaner, results in less conditionals in upper code, I would 👍 for that. |
2dddd45
to
c74de5d
Compare
@sreuland agreed! Done ✔️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add few tests? overall looks good to me just one question on rust code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, for consideration, echo the same as other reviewer commented, about adding unit test on conversion.go if feasible.
What
Correctly handle the case where transaction data is empty. Also, add a bit of verbosity (the type name) to error messages coming from the conversion layer.
Why
Previously, the handler would unconditionally try to encode an empty byte array (since
result.TransactionData
was empty) and fail with an internal panic:Obviously this is not ideal. It was occurring because the simulation failed, but the code would still try to JSONify results. In the base64 case,
EncodeToString
will just return an empty string on an empty buffer.This code modifies
xdr2json.ConvertBytes
to check its inputs like so:to behave akin to
EncodeToString
and handle this case "in general."