-
Notifications
You must be signed in to change notification settings - Fork 52
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
feat: ExecutionOutcome.status should be public #288
base: main
Are you sure you want to change the base?
Conversation
We didn't expose |
But the breaking changes are only related to tests. If you are strongly against it, then could you propose an alternative (other than formatting into a string) |
UP, any chance we can merge this? |
@robert-zaremba Have you tried if let Some(err) = f.into_result().unwrap_err().source().unwrap().downcast_ref::<near_primitives::errors::TxExecutionError>() {
dbg!(err);
} |
@robert-zaremba Did my snippet help? Should we close this for now (until we are ready to create an API-stable version of the outcome status)? |
I tried using your snippet, but I'm getting this error:
I added these two lines of code: use std::error::Error;
use near_primitives; And these are my dev-dependencies:
After testing some smart contracts, I noticed that checking the result of a call using the In Hardhat, there is a convenient function Thanks! |
UPDATE Not the most elegant solution, but it works. If anybody arrives here with the same issue I had, this piece of code might work for you. let result = alice.call(protocol.borrow_verde_contract.id(), "withdraw_collateral")
.args_json(json!({
"collateral_id": protocol.st_near_contract.id(),
"collat_amount": U128::from(0),
}))
.deposit(NearToken::from_yoctonear(1))
.max_gas()
.transact()
.await?;
assert!(result.is_failure() && result.into_result().unwrap_err().to_string().contains("InvalidZeroWithdraw")); |
Today, the only way to check the transaction error content is to serialize it with JSON or format it with default display formatter.
Moreover it's hard to check an error in a particular receipt.
Example: https://github.com/near-ndc/voting-v1/blob/8f1c14a/elections/tests/iah.rs#L169
Potential workaround would be to make
Error.repr
public. But the flow will be even more complicated: