Skip to content

Commit

Permalink
panic if event is not found in the expected blocks (#1880)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm authored Jun 25, 2024
1 parent 1cc426c commit cbf8691
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
15 changes: 3 additions & 12 deletions runtime/integration-tests/src/generic/cases/routers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,8 @@ fn environment_for_evm<T: Runtime + FudgeSupport>() -> FudgeEnv<T> {
env.parachain_state_mut(|| {
pallet_evm::AccountCodes::<T>::insert(AXELAR_CONTRACT_ADDRESS, AXELAR_CONTRACT_CODE);

utils::evm::mint_balance_into_derived_account::<T>(
AXELAR_CONTRACT_ADDRESS,
cfg(1_000_000_000),
);
utils::evm::mint_balance_into_derived_account::<T>(
get_gateway_h160_account::<T>(),
cfg(1_000_000),
);
utils::evm::mint_balance_into_derived_account::<T>(AXELAR_CONTRACT_ADDRESS, cfg(1));
utils::evm::mint_balance_into_derived_account::<T>(get_gateway_h160_account::<T>(), cfg(1));
});

env
Expand Down Expand Up @@ -140,12 +134,9 @@ fn check_submission<T: Runtime>(mut env: impl Env<T>, domain_router: DomainRoute
});

env.pass(Blocks::UntilEvent {
event: expected_event.clone().into(),
event: expected_event.into(),
limit: 3,
});

env.check_event(expected_event)
.expect("expected OutboundMessageExecutionSuccess event");
}

#[test_runtimes(all)]
Expand Down
8 changes: 8 additions & 0 deletions runtime/integration-tests/src/generic/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,23 @@ pub trait Env<T: Runtime>: Default {
)
});

let mut found_event = false;
for i in blocks.range_for(current, slot) {
self.__priv_build_block(i);

if let Blocks::UntilEvent { event, .. } = blocks.clone() {
if self.check_event(event).is_some() {
found_event = true;
break;
}
}
}

if let Blocks::UntilEvent { event, limit } = blocks.clone() {
if !found_event {
panic!("Event {event:?} was not found producing {limit} blocks");
}
}
}

/// Allows to mutate the relay storage state through the closure.
Expand Down

0 comments on commit cbf8691

Please sign in to comment.