Skip to content

Commit

Permalink
backup
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 7, 2024
1 parent 22c2d0d commit 51400d9
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 2 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.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,12 @@ inherits = "release"
lto = true
codegen-units = 1

[profile.testnet]
inherits = "release"
debug = 1 # debug symbols are useful for profilers
debug-assertions = true
overflow-checks = true

[patch.crates-io]
assert_matches = { path = "../vendor/assert_matches" }
asset-test-utils = { path = "../vendor/asset-test-utils" }
Expand Down Expand Up @@ -511,4 +517,4 @@ subxt = { path = "../vendor/subxt" }
tracing-subscriber = { path = "../vendor/tracing-subscriber-0.2.25" }
zombienet-sdk = { path = "../vendor/zombienet-sdk" }
tuplex = { path = "../vendor/tuplex" }
ss58-registry = { path = "../vendor/ss58-registry" }
ss58-registry = { path = "../vendor/ss58-registry" }
2 changes: 1 addition & 1 deletion ahm-controller/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ pub mod pallet {
})?
}

fn migrate_indices() -> Result<bool, ()> {
pub fn migrate_indices() -> Result<bool, ()> {
frame_support::storage::transactional::with_transaction_opaque_err::<bool, (), _>(|| {
let Some((call, weight)) = pallet_indices::Pallet::<T>::migrate_next(1000) else {
return TransactionOutcome::Commit(Ok(false));
Expand Down
84 changes: 84 additions & 0 deletions relay/polkadot/tests/ahm_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Polkadot.

// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

//! Asset hub migration tests.

use frame_support::traits::tokens::ConversionFromAssetBalance;
use polkadot_runtime::AssetRateWithNative;
use polkadot_runtime_common::impls::VersionedLocatableAsset;
use xcm::prelude::*;
use remote_externalities::OfflineConfig;
use remote_externalities::Builder;
use polkadot_runtime::Block;
use remote_externalities::RemoteExternalities;
use remote_externalities::Mode;
use polkadot_runtime::Runtime as T;
use polkadot_runtime::AhmController;
use polkadot_runtime::System;
use frame_support::sp_runtime::traits::Dispatchable;

#[tokio::test]
async fn ahm_indices_out() {
let Some(mut ext) = remote_ext_test_setup().await else { return; };
let mut calls = Vec::new();

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

loop {
let Some((call, weight)) = pallet_indices::Pallet::<T>::migrate_next(1000) else {
break;
};
calls.push(call);

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

for call in calls {
let runtime_call: polkadot_runtime::RuntimeCall = call.into();
runtime_call.dispatch(frame_system::RawOrigin::Root.into()).unwrap();
}

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

async fn remote_ext_test_setup() -> Option<RemoteExternalities<Block>> {
sp_tracing::try_init_simple();
let Some(snap) = std::env::var("SNAP").ok() else{
return None;
};
let abs = std::path::absolute(snap.clone());

let ext = Builder::<Block>::default()
.mode(Mode::Offline(
OfflineConfig { state_snapshot: snap.clone().into() },
))
.build()
.await
.map_err(|e| {
eprintln!("Could not load from snapshot: {:?}: {:?}", abs, e);
})
.unwrap();

Some(ext)
}

0 comments on commit 51400d9

Please sign in to comment.