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

Implement state handling for Retracted status #807

Merged
merged 12 commits into from
Oct 28, 2024
Prev Previous commit
Next Next commit
Improve testing and error handling
Niederb committed Oct 9, 2024
commit 6191cb8e6918fbcd76916d76e314518fa5f3db19
3 changes: 3 additions & 0 deletions src/api/rpc_api/author.rs
Original file line number Diff line number Diff line change
@@ -289,6 +289,9 @@ where
&self,
mut report: ExtrinsicReport<Self::Hash>,
) -> Result<ExtrinsicReport<Self::Hash>> {
if report.events.is_some() {
return Err(Error::Other("Report already contains events".into()))
}
let block_hash = report.block_hash.ok_or(Error::BlockHashNotFound)?;
let extrinsic_events =
self.fetch_events_for_extrinsic(block_hash, report.extrinsic_hash).await?;
7 changes: 7 additions & 0 deletions testing/async/examples/author_tests.rs
Original file line number Diff line number Diff line change
@@ -174,6 +174,13 @@ async fn test_submit_and_watch_extrinsic_until_in_block_without_events(
println!("Extrinsic got successfully included in Block!");
assert!(report.block_hash.is_some());
assert!(report.events.is_none());

// Now we fetch the events separately
let report = api.populate_events(report).await.unwrap();
assert!(report.events.is_some());

// Can populate events only once
assert!(api.populate_events(report).await.is_err());
}

fn assert_associated_events_match_expected(events: Vec<RawEventDetails<Hash>>) {