-
Notifications
You must be signed in to change notification settings - Fork 432
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
[ink_e2e]
resolve DispatchError
error details for dry-runs
#1994
Conversation
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! Just some nits
crates/e2e/src/contract_results.rs
Outdated
/// Returns the return value as raw bytes of the message from the dry-run. | ||
/// | ||
/// Panics if the dry-run message call failed to execute. | ||
pub fn return_data(&self) -> &[u8] { |
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't we decode the data?
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.
This can already be done constructor_result
above. That said I copied this from the CallDryRunResult
, and I don't think this is super useful for constructors, so have deleted it.
|
||
/// Transforms a [`ContractResult`] from a dry run into a [`Result`] type, containing | ||
/// details of the [`DispatchError`] if the dry run failed. | ||
fn contract_result_to_result<V>( |
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't this be more generically be implemented with From
trait?
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.
In this case we need the &self
to get the metadata for decoding the DispatchError
🦑 📈 ink! Example Contracts ‒ Changes Report 📉 🦑These are the results when building the
Link to the run | Last update: Thu Nov 16 17:30:11 CET 2023 |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1994 +/- ##
==========================================
+ Coverage 53.24% 53.25% +0.01%
==========================================
Files 219 220 +1
Lines 6838 6846 +8
==========================================
+ Hits 3641 3646 +5
- Misses 3197 3200 +3 ☔ View full report in Codecov by Sentry. |
Currently for dry runs we only get raw dispatch errors e.g.
ModuleError { index: 21, error: [22, 0, 0, 0],
. This PR will resolve the error message to a more useful e.g.InstantiateDryRun(DryRunError { debug_message: "", error: Module(ModuleError(<Contracts::StorageDepositNotEnoughFunds>)) })
The API for executing dry runs will be aligned with the transaction execution methods by returning a top level
Result
. The signatures for thedry_run
methods are now:InstantiateDryRunResult
has been added in this PR to encapsulate the returned result, similar to the existingCallDryRunResult
.