diff --git a/src/api/rpc_api/author.rs b/src/api/rpc_api/author.rs index eb7399f5e..1f1471bad 100644 --- a/src/api/rpc_api/author.rs +++ b/src/api/rpc_api/author.rs @@ -289,6 +289,9 @@ where &self, mut report: ExtrinsicReport, ) -> Result> { + 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?; diff --git a/testing/async/examples/author_tests.rs b/testing/async/examples/author_tests.rs index 585495af5..0757c6164 100644 --- a/testing/async/examples/author_tests.rs +++ b/testing/async/examples/author_tests.rs @@ -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>) {