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 revert with reason functionality for mock contracts #349

Merged
merged 2 commits into from
Aug 31, 2020
Merged

Add revert with reason functionality for mock contracts #349

merged 2 commits into from
Aug 31, 2020

Conversation

PaulRBerg
Copy link
Contributor

@PaulRBerg PaulRBerg commented Aug 24, 2020

Not being able to revert with a reason on a mock contract is prohibitively limiting.

Say you have contract A and contract B. The latter depends on the former. Say that the former throws specific errors depending on the state of the properties in the two contracts. If I mock contract A, I have to modify a lot of tests to revert with "Mock revert" instead of my bespoke error messages.

This PR does the following:

  • Adds a new revertReason property in the MockCall struct
  • Changes the signature of the __waffle__mockReverts function, by adding a second parameter revertReason
  • Adds a new function revertWithReason in the object returned by the stub function - which makes my change backwards-compatible!
  • Modifies the tests so that they work with the updated __waffle__mockReverts function

@marekkirejczyk marekkirejczyk merged commit f676bfe into TrueFiEng:master Aug 31, 2020
@marekkirejczyk
Copy link
Contributor

@PaulRBerg Good stuff, merging. Would add a PR with docs?

@marekkirejczyk
Copy link
Contributor

Released in 3.0.3

@PaulRBerg PaulRBerg deleted the revertWithReason branch August 31, 2020 21:09
@PaulRBerg
Copy link
Contributor Author

Thanks for merging, Marek!

Would add a PR with docs?

I could do this, in case you haven't done it in the meantime?

PaulRBerg added a commit to hifi-finance/hifi-protocol that referenced this pull request Sep 1, 2020
@marekkirejczyk
Copy link
Contributor

Released in Waffle 3.1.0. Didn't have a chance to work on docs yet. Would love to get some help :)

@PaulRBerg
Copy link
Contributor Author

PaulRBerg commented Sep 22, 2020

Released in Waffle 3.1.0. Didn't have a chance to work on docs yet. Would love to get some help :)

Done: #366.

PaulRBerg added a commit to hifi-finance/hifi that referenced this pull request Aug 7, 2021
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.

2 participants