Skip to content

Commit

Permalink
fix cumulus runtime_upgrade_events test
Browse files Browse the repository at this point in the history
  • Loading branch information
ordian committed Jan 7, 2025
1 parent b4fea58 commit c7aab54
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions cumulus/pallets/parachain-system/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ impl BlockTests {
}

// clean up
System::maybe_apply_pending_code_upgrade();
let header = System::finalize();
let head_data = relay_chain::HeadData(header.encode());
parent_head_data = head_data.clone();
Expand Down
23 changes: 18 additions & 5 deletions cumulus/pallets/parachain-system/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ fn hrmp_outbound_respects_used_bandwidth() {
fn runtime_upgrade_events() {
BlockTests::new()
.with_relay_sproof_builder(|_, block_number, builder| {
if block_number > 123 {
if block_number == 1234 {
builder.upgrade_go_ahead = Some(relay_chain::UpgradeGoAhead::GoAhead);
}
})
Expand All @@ -466,21 +466,34 @@ fn runtime_upgrade_events() {
|| {
let events = System::events();

assert_eq!(events[0].event, RuntimeEvent::System(frame_system::Event::CodeUpdated));

assert_eq!(
events[1].event,
events[0].event,
RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionApplied {
relay_chain_block_num: 1234
})
);

assert!(System::digest()
.logs()
.iter()
.all(|d| *d != sp_runtime::generic::DigestItem::RuntimeEnvironmentUpdated));
},
)
.add_with_post_test(
1235,
|| {},
|| {
let events = System::events();

assert_eq!(events[0].event, RuntimeEvent::System(frame_system::Event::CodeUpdated));

assert!(System::digest()
.logs()
.iter()
.any(|d| *d == sp_runtime::generic::DigestItem::RuntimeEnvironmentUpdated));
},
);
)
;
}

#[test]
Expand Down

0 comments on commit c7aab54

Please sign in to comment.