-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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 comprehensive tests to adapter_tests #260
Conversation
let package_id = match generate_package_id(&mut modules, ctx) { | ||
Ok(ok) => ok, | ||
Err(err) => exec_failure!(gas::MIN_MOVE_PUBLISH_GAS, err), | ||
}; |
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.
So, if you change the exec_failure!
macro to not return something but instead just construct the result, this can become:
let package_id = match generate_package_id(&mut modules, ctx).unwrap_or_else(|e| exec_failure!(..., e))?;
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.
Not really, note that exec_failure!
actually returns Ok
instead of Err
.
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.
Fair enough.
let package_id = generate_package_id(&mut modules, ctx).or_else(|e| exec_failure!(..., e))?;
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.
That's not going to work either. What I want here is when a user error occurred, the entire function still returns an Ok
, but inside that Ok
there is an ExecutionStatus::Failure
. So any mechanism that chains into ?
will not work.
Also exec_failure!
needs to be in the outer function scope, not in lambda scope, otherwise it just returns from within the lambda instead of returns the outer function.
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.
Yes, understood, finally. You're right, there's nothing relevant to do from within the lambda scope.
.unwrap() | ||
.unwrap(); |
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.
I'm thinking we may want to provide a convenience method (perhaps an impl TryFrom
?) to unpack results wrapping execution statuses.
This PR adds more tests to adapter_tests.
In doing so, also found a few issues and fixed them: