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

lang: add support for logging expected and actual values and pubkeys #1572

Merged
merged 21 commits into from
Mar 15, 2022

Conversation

paul-schaaf
Copy link
Contributor

@paul-schaaf paul-schaaf commented Mar 7, 2022

closes #1586

closes #1464

Future PRs should add more require statements that abstract away the implementation details

macros added in this PR:

  • require_eq macro that is meant to be used with non-pubkey values and results in the following output:
'Program log: AnchorError thrown in programs/errors/src/lib.rs:68. Error Code: ValueMismatch. Error Number: 6126. Error Message: ValueMismatch.',
'Program log: Left: 5241',
'Program log: Right: 124124124'
  • require_keys_eq macro that is meant to be used with pubkey values and results in the following output:
'Program log: AnchorError thrown in programs/errors/src/lib.rs:73. Error Code: ValueMismatch. Error Number: 6126. Error Message: ValueMismatch.',
'Program log: Left:',
'Program log: HCGsxsDZEKWnaS5t7JBct6cyyLS6Jcx7Mmn4KjUQokZY',
'Program log: Right:',
'Program log: Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS'

These macros can be used like this require_eq(value1, value2) in which case they return an error defined by us or with a custom error require_eq(value1,value2,MyError:SomeError). The require macro has also been changed to work the same way

Log statement are intentionally Left and Right and not Expected and Actual because future require macros would not fit those descriptions (e.g. require_gt)

@paul-schaaf paul-schaaf marked this pull request as ready for review March 8, 2022 19:50
@paul-schaaf paul-schaaf marked this pull request as draft March 8, 2022 19:55
@paul-schaaf paul-schaaf marked this pull request as ready for review March 8, 2022 20:24
@armaniferrante
Copy link
Member

merge conflicts

@paul-schaaf paul-schaaf merged commit 721fe66 into coral-xyz:master Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants