Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make liquid staking pallet mocks compile successfully .ready to cover lsd with unit tests #4273

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/Cargo.lock

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

1 change: 1 addition & 0 deletions code/parachain/frame/liquid-staking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ orml-unknown-tokens = { workspace = true, default-features = false }
pallet-assets = { path = "../assets" }
orml-tokens = { workspace = true }
composable-support = { path = "../composable-support", default-features = false }
pallet-message-queue = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" }

# pallet-currency-adapter = { workspace = true, features = ['std'] }

Expand Down
4 changes: 2 additions & 2 deletions code/parachain/frame/liquid-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ use pallet_xcm_helper::ump::RewardDestination;

// mod benchmarking;

// #[cfg(test)]
// mod mock;
#[cfg(test)]
mod mock;
// #[cfg(test)]
// mod tests;

Expand Down
231 changes: 119 additions & 112 deletions code/parachain/frame/liquid-staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,68 +742,68 @@ pub(crate) fn new_test_ext() -> sp_io::TestExternalities {

let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(|| {
Assets::force_create(RuntimeOrigin::root(), KSM.into(), Id(ALICE), true, 1).unwrap();
Assets::force_set_metadata(
RuntimeOrigin::root(),
KSM.into(),
b"Kusama".to_vec(),
b"KSM".to_vec(),
12,
false,
)
.unwrap();
Assets::force_create(RuntimeOrigin::root(), SKSM.into(), Id(ALICE), true, 1).unwrap();
Assets::force_set_metadata(
RuntimeOrigin::root(),
SKSM.into(),
b"Parallel Kusama".to_vec(),
b"sKSM".to_vec(),
12,
false,
)
.unwrap();
Assets::force_create(RuntimeOrigin::root(), KSM_U.into(), Id(ALICE), true, 1).unwrap();
Assets::force_set_metadata(
RuntimeOrigin::root(),
KSM_U.into(),
b"Kusama Ubonding".to_vec(),
b"KSM_U".to_vec(),
12,
false,
)
.unwrap();

Assets::mint(
RuntimeOrigin::signed(ALICE),
KSM.into(),
Id(ALICE),
ksm(100f64),
)
.unwrap();
Assets::mint(
RuntimeOrigin::signed(ALICE),
SKSM.into(),
Id(ALICE),
ksm(100f64),
)
.unwrap();
Assets::mint(
RuntimeOrigin::signed(ALICE),
KSM.into(),
Id(BOB),
ksm(20000f64),
)
.unwrap();
// Assets::force_create(RuntimeOrigin::root(), KSM.into(), Id(ALICE), true, 1).unwrap();
// Assets::force_set_metadata(
// RuntimeOrigin::root(),
// KSM.into(),
// b"Kusama".to_vec(),
// b"KSM".to_vec(),
// 12,
// false,
// )
// .unwrap();
// Assets::force_create(RuntimeOrigin::root(), SKSM.into(), Id(ALICE), true, 1).unwrap();
// Assets::force_set_metadata(
// RuntimeOrigin::root(),
// SKSM.into(),
// b"Parallel Kusama".to_vec(),
// b"sKSM".to_vec(),
// 12,
// false,
// )
// .unwrap();
// Assets::force_create(RuntimeOrigin::root(), KSM_U.into(), Id(ALICE), true, 1).unwrap();
// Assets::force_set_metadata(
// RuntimeOrigin::root(),
// KSM_U.into(),
// b"Kusama Ubonding".to_vec(),
// b"KSM_U".to_vec(),
// 12,
// false,
// )
// .unwrap();

// Assets::mint(
// RuntimeOrigin::signed(ALICE),
// KSM.into(),
// Id(ALICE),
// ksm(100f64),
// )
// .unwrap();
// Assets::mint(
// RuntimeOrigin::signed(ALICE),
// SKSM.into(),
// Id(ALICE),
// ksm(100f64),
// )
// .unwrap();
// Assets::mint(
// RuntimeOrigin::signed(ALICE),
// KSM.into(),
// Id(BOB),
// ksm(20000f64),
// )
// .unwrap();
LiquidStaking::update_staking_ledger_cap(RuntimeOrigin::signed(BOB), ksm(10000f64))
.unwrap();

Assets::mint(
RuntimeOrigin::signed(ALICE),
KSM.into(),
Id(XcmHelper::account_id()),
ksm(100f64),
)
.unwrap();
// Assets::mint(
// RuntimeOrigin::signed(ALICE),
// KSM.into(),
// Id(XcmHelper::account_id()),
// ksm(100f64),
// )
// .unwrap();

// Loans::add_market(RuntimeOrigin::root(), KSM, market_mock(PKSM)).unwrap();
// Loans::activate_market(RuntimeOrigin::root(), KSM).unwrap();
Expand All @@ -827,10 +827,17 @@ decl_test_parachain! {
}
}

use pallet_message_queue;
use xcm_simulator::TestExt;

decl_test_relay_chain! {
pub struct Relay {
Runtime = kusama_runtime::Runtime,
XcmConfig = kusama_runtime::xcm_config::XcmConfig,
RuntimeCall = kusama_runtime::RuntimeCall,
RuntimeEvent = kusama_runtime::RuntimeEvent,
XcmConfig = kusama_runtime::xcm_config::XcmConfig,
MessageQueue = kusama_runtime::MessageQueue,
System = kusama_runtime::System,
new_ext = relay_ext(),
}
}
Expand Down Expand Up @@ -881,58 +888,58 @@ pub fn para_ext(para_id: u32) -> sp_io::TestExternalities {

let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(|| {
Assets::force_create(RuntimeOrigin::root(), KSM.into(), Id(ALICE), true, 1).unwrap();
Assets::force_set_metadata(
RuntimeOrigin::root(),
KSM.into(),
b"Kusama".to_vec(),
b"KSM".to_vec(),
12,
false,
)
.unwrap();
Assets::force_create(RuntimeOrigin::root(), SKSM.into(), Id(ALICE), true, 1).unwrap();
Assets::force_set_metadata(
RuntimeOrigin::root(),
SKSM.into(),
b"Parallel Kusama".to_vec(),
b"sKSM".to_vec(),
12,
false,
)
.unwrap();
Assets::force_create(RuntimeOrigin::root(), KSM_U.into(), Id(ALICE), true, 1).unwrap();
Assets::force_set_metadata(
RuntimeOrigin::root(),
KSM_U.into(),
b"Kusama Ubonding".to_vec(),
b"KSM_U".to_vec(),
12,
false,
)
.unwrap();

Assets::mint(
RuntimeOrigin::signed(ALICE),
KSM.into(),
Id(ALICE),
ksm(10000f64),
)
.unwrap();
Assets::mint(
RuntimeOrigin::signed(ALICE),
KSM.into(),
Id(BOB),
ksm(20000f64),
)
.unwrap();
Assets::mint(
RuntimeOrigin::signed(ALICE),
KSM.into(),
Id(XcmHelper::account_id()),
ksm(30f64),
)
.unwrap();
// Assets::force_create(RuntimeOrigin::root(), KSM.into(), Id(ALICE), true, 1).unwrap();
// Assets::force_set_metadata(
// RuntimeOrigin::root(),
// KSM.into(),
// b"Kusama".to_vec(),
// b"KSM".to_vec(),
// 12,
// false,
// )
// .unwrap();
// Assets::force_create(RuntimeOrigin::root(), SKSM.into(), Id(ALICE), true, 1).unwrap();
// Assets::force_set_metadata(
// RuntimeOrigin::root(),
// SKSM.into(),
// b"Parallel Kusama".to_vec(),
// b"sKSM".to_vec(),
// 12,
// false,
// )
// .unwrap();
// Assets::force_create(RuntimeOrigin::root(), KSM_U.into(), Id(ALICE), true, 1).unwrap();
// Assets::force_set_metadata(
// RuntimeOrigin::root(),
// KSM_U.into(),
// b"Kusama Ubonding".to_vec(),
// b"KSM_U".to_vec(),
// 12,
// false,
// )
// .unwrap();

// Assets::mint(
// RuntimeOrigin::signed(ALICE),
// KSM.into(),
// Id(ALICE),
// ksm(10000f64),
// )
// .unwrap();
// Assets::mint(
// RuntimeOrigin::signed(ALICE),
// KSM.into(),
// Id(BOB),
// ksm(20000f64),
// )
// .unwrap();
// Assets::mint(
// RuntimeOrigin::signed(ALICE),
// KSM.into(),
// Id(XcmHelper::account_id()),
// ksm(30f64),
// )
// .unwrap();

// Loans::add_market(RuntimeOrigin::root(), KSM, market_mock(PKSM)).unwrap();
// Loans::activate_market(RuntimeOrigin::root(), KSM).unwrap();
Expand Down
Loading