Skip to content

Commit

Permalink
fix tests build
Browse files Browse the repository at this point in the history
  • Loading branch information
Roznovjak committed Dec 18, 2024
1 parent 0813bc7 commit b93aaef
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 18 deletions.
24 changes: 20 additions & 4 deletions integration-tests/src/kusama_test_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use frame_support::assert_ok;
use frame_support::traits::OnInitialize;
use pallet_transaction_multi_payment::Price;
pub use pallet_xyk::types::AssetPair;
use polkadot_primitives::v7::{BlockNumber, MAX_CODE_SIZE, MAX_POV_SIZE};
use polkadot_primitives::v8::{BlockNumber, MAX_CODE_SIZE, MAX_POV_SIZE};
use polkadot_runtime_parachains::configuration::HostConfiguration;
use pretty_assertions::assert_eq;
use primitives::{constants::time::SLOT_DURATION, AssetId, Balance};
Expand Down Expand Up @@ -167,13 +167,12 @@ pub mod rococo {
}

use polkadot_primitives::{AssignmentId, ValidatorId};
use polkadot_service::chain_spec::get_authority_keys_from_seed_no_beefy;
use polkadot_service::chain_spec::get_account_id_from_seed;
use sc_consensus_grandpa::AuthorityId as GrandpaId;
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_consensus_babe::AuthorityId as BabeId;
use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId;

use sp_core::{Pair, Public};
use sp_core::{Pair, Public, sr25519};

/// Helper function to generate a crypto pair from seed
fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
Expand All @@ -200,6 +199,20 @@ pub mod rococo {
}
}

pub fn get_authority_keys_from_seed_no_beefy(
seed: &str,
) -> (AccountId, AccountId, BabeId, GrandpaId, ValidatorId, AssignmentId, AuthorityDiscoveryId) {
(
get_account_id_from_seed::<sr25519::Public>(&format!("{}//stash", seed)),
get_account_id_from_seed::<sr25519::Public>(seed),
get_from_seed::<BabeId>(seed),
get_from_seed::<GrandpaId>(seed),
get_from_seed::<ValidatorId>(seed),
get_from_seed::<AssignmentId>(seed),
get_from_seed::<AuthorityDiscoveryId>(seed),
)
}

pub fn initial_authorities() -> Vec<(
AccountId,
AccountId,
Expand Down Expand Up @@ -250,6 +263,7 @@ pub mod rococo {
)
})
.collect::<Vec<_>>(),
non_authority_keys: Default::default(),
},
babe: rococo_runtime::BabeConfig {
authorities: Default::default(),
Expand Down Expand Up @@ -373,6 +387,7 @@ pub mod basilisk {
)
})
.collect(),
non_authority_keys: Default::default(),
},
asset_registry: basilisk_runtime::AssetRegistryConfig {
registered_assets: vec![
Expand Down Expand Up @@ -460,6 +475,7 @@ pub mod other_parachain {
)
})
.collect(),
non_authority_keys: Default::default(),
},
asset_registry: basilisk_runtime::AssetRegistryConfig {
registered_assets: vec![(b"AUSD".to_vec(), 1_000_000u128, Some(AUSD))],
Expand Down
38 changes: 24 additions & 14 deletions pallets/xyk-liquidity-mining/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ impl AMM<AccountId, AssetId, AssetPair, Balance> for DummyAMM {

fn execute_buy(
_transfer: &hydradx_traits::AMMTransfer<AccountId, AssetId, AssetPair, Balance>,
_destination: Option<&AccountId>,
) -> frame_support::dispatch::DispatchResult {
Err(sp_runtime::DispatchError::Other("NotImplemented"))
}
Expand Down Expand Up @@ -508,6 +509,20 @@ impl hydradx_traits::liquidity_mining::Mutate<AccountId, AssetId, BlockNumber> f
Ok((farm_id, max_reward_per_period))
}

fn create_global_farm_without_price_adjustment(
_total_rewards: Self::Balance,
_planned_yielding_periods: Self::Period,
_blocks_per_period: BlockNumber,
_incentivized_asset: AssetId,
_reward_currency: AssetId,
_owner: AccountId,
_yield_per_period: Perquintill,
_min_deposit: Self::Balance,
) -> Result<(YieldFarmId, Self::Balance), Self::Error> {
//NOTE: Basilisk is not using this fn.
Err(sp_runtime::DispatchError::Other("Not implemented"))
}

fn update_global_farm_price_adjustment(
_who: AccountId,
global_farm_id: u32,
Expand All @@ -524,6 +539,15 @@ impl hydradx_traits::liquidity_mining::Mutate<AccountId, AssetId, BlockNumber> f
})
}

fn update_global_farm(
_global_farm_id: GlobalFarmId,
_planned_yielding_periods: Self::Period,
_yield_per_period: Perquintill,
_min_deposit: Self::Balance
) -> Result<(), Self::Error> {
Err(sp_runtime::DispatchError::Other("Not implemented"))
}

fn terminate_global_farm(
who: AccountId,
global_farm_id: u32,
Expand Down Expand Up @@ -761,20 +785,6 @@ impl hydradx_traits::liquidity_mining::Mutate<AccountId, AssetId, BlockNumber> f
fn get_global_farm_id(deposit_id: u128, yield_farm_id: u32) -> Option<u32> {
DEPOSIT_ENTRIES.with(|v| v.borrow().get(&(deposit_id, yield_farm_id)).map(|d| d.global_farm_id))
}

fn create_global_farm_without_price_adjustment(
_total_rewards: Self::Balance,
_planned_yielding_periods: Self::Period,
_blocks_per_period: BlockNumber,
_incentivized_asset: AssetId,
_reward_currency: AssetId,
_owner: AccountId,
_yield_per_period: Perquintill,
_min_deposit: Self::Balance,
) -> Result<(YieldFarmId, Self::Balance), Self::Error> {
//NOTE: Basilisk is not using this fn.
Err(sp_runtime::DispatchError::Other("Not implemented"))
}
}

//NOTE: this is and should not be used anywhere. This exists only to make trait bellow happy. Trait
Expand Down

0 comments on commit b93aaef

Please sign in to comment.