Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
  • Loading branch information
ggwpez committed Nov 13, 2024
1 parent 51400d9 commit 5ba11de
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion relay/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ impl pallet_indices::Config for Runtime {
type Deposit = IndexDeposit;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_indices::WeightInfo<Runtime>;
type AhReserveMigrator = frame_support::ahm::NoopMigrator<Self::AccountId, Balance>;
type AhReserveMigrator = frame_support::ahm::NoopMigrator<(), Self::AccountId, Balance>;
}

parameter_types! {
Expand Down
24 changes: 22 additions & 2 deletions relay/polkadot/tests/ahm_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ async fn ahm_indices_out() {

ext.execute_with(|| {
frame_system::Pallet::<T>::set_block_number(1);
total_issuance_correct();
let ti = pallet_balances::TotalIssuance::<T>::get();

loop {
Expand All @@ -45,23 +46,42 @@ async fn ahm_indices_out() {
};
calls.push(call);

/*log::error!("Number of events: {:?}", System::events().len());
log::error!("Number of events: {:?}", System::events().len());
for event in System::events() {
log::error!("Event: {:?}", event);
}
System::reset_events();*/
System::reset_events();
}

log::error!("Dispatched {} calls", calls.len());
for call in calls {
let runtime_call: polkadot_runtime::RuntimeCall = call.into();
runtime_call.dispatch(frame_system::RawOrigin::Root.into()).unwrap();
}

log::error!("Number of events: {:?}", System::events().len());
for event in System::events() {
log::error!("Event: {:?}", event);
}

total_issuance_correct();
let ti2 = pallet_balances::TotalIssuance::<T>::get();
assert_eq!(ti, ti2, "Total issuance must be the same after migration");
});
}

fn total_issuance_correct() {
println!("Checkig TI");
let mut total = 0;
for acc in frame_system::Account::<T>::iter_values() {
total += acc.data.free + acc.data.reserved;
}

let known_bad_diff = 15153004468955758308u128 - 15152788105929904271u128;
let ti = pallet_balances::TotalIssuance::<T>::get();
assert_eq!(total + known_bad_diff, ti, "Total issuance must be the same as sum of all account balances");
}

async fn remote_ext_test_setup() -> Option<RemoteExternalities<Block>> {
sp_tracing::try_init_simple();
let Some(snap) = std::env::var("SNAP").ok() else{
Expand Down

0 comments on commit 5ba11de

Please sign in to comment.