From 8f81ddc69f921ab611072f0db6e0396b1da15c20 Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Thu, 26 Oct 2023 17:21:34 +0200 Subject: [PATCH 1/2] tests: fix FI --- .../liquidity_pools/foreign_investments.rs | 40 ++++++++----------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/foreign_investments.rs b/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/foreign_investments.rs index 792527066f..e1d30ab9d6 100644 --- a/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/foreign_investments.rs +++ b/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/foreign_investments.rs @@ -103,7 +103,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let amount = 100_000_000; + let amount = 10 * dollar(12); let investor: AccountId = AccountConverter::::convert(( DOMAIN_MOONBEAM, @@ -112,14 +112,6 @@ mod same_currencies { let currency_id = AUSD_CURRENCY_ID; let currency_decimals = currency_decimals::AUSD; - let sending_domain_locator = Domain::convert(DEFAULT_DOMAIN_ADDRESS_MOONBEAM.domain()); - let pool_account = - pallet_pool_system::pool_types::PoolLocator { pool_id }.into_account_truncating(); - - Tokens::mint_into(AUSD_CURRENCY_ID, &sending_domain_locator, AUSD_ED).unwrap(); - Tokens::mint_into(AUSD_CURRENCY_ID, &investor, AUSD_ED).unwrap(); - Tokens::mint_into(AUSD_CURRENCY_ID, &pool_account, AUSD_ED).unwrap(); - // Create new pool create_currency_pool(pool_id, currency_id, currency_decimals.into()); @@ -159,7 +151,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let invest_amount: u128 = 100_000_000; + let invest_amount: u128 = 10 * dollar(12); let decrease_amount = invest_amount / 3; let final_amount = invest_amount - decrease_amount; let investor: AccountId = @@ -241,7 +233,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let invest_amount = 100_000_000; + let invest_amount = 10 * dollar(12); let investor: AccountId = AccountConverter::::convert(( DOMAIN_MOONBEAM, @@ -338,7 +330,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let amount = 100_000_000; + let amount = 10 * dollar(12); let investor: AccountId = AccountConverter::::convert(( DOMAIN_MOONBEAM, @@ -490,7 +482,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let invest_amount = 100_000_000; + let invest_amount = 10 * dollar(12); let investor: AccountId = AccountConverter::::convert(( DOMAIN_MOONBEAM, @@ -748,7 +740,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let amount = 100_000_000; + let amount = 10 * dollar(12); let investor: AccountId = AccountConverter::::convert(( DOMAIN_MOONBEAM, @@ -801,7 +793,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let redeem_amount = 100_000_000; + let redeem_amount = 10 * dollar(12); let decrease_amount = redeem_amount / 3; let final_amount = redeem_amount - decrease_amount; let investor: AccountId = @@ -914,7 +906,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let redeem_amount = 100_000_000; + let redeem_amount = 10 * dollar(12); let investor: AccountId = AccountConverter::::convert(( DOMAIN_MOONBEAM, @@ -1010,7 +1002,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let amount = 100_000_000; + let amount = 10 * dollar(12); let investor: AccountId = AccountConverter::::convert(( DOMAIN_MOONBEAM, @@ -1164,7 +1156,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let redeem_amount = 100_000_000; + let redeem_amount = 10 * dollar(12); let investor: AccountId = AccountConverter::::convert(( DOMAIN_MOONBEAM, @@ -1388,7 +1380,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let invest_amount: u128 = 100_000_000; + let invest_amount: u128 = 10 * dollar(12); let decrease_amount = invest_amount + 1; let investor: AccountId = AccountConverter::< DevelopmentRuntime, @@ -1430,7 +1422,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let redeem_amount: u128 = 100_000_000; + let redeem_amount: u128 = 10 * dollar(12); let decrease_amount = redeem_amount + 1; let investor: AccountId = AccountConverter::< DevelopmentRuntime, @@ -1473,7 +1465,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let amount: u128 = 100_000_000; + let amount: u128 = 10 * dollar(12); let investor: AccountId = AccountConverter::< DevelopmentRuntime, LocationToAccountId, @@ -1509,7 +1501,7 @@ mod same_currencies { tranche_id: default_tranche_id(pool_id), investor: investor.clone().into(), currency: general_currency_index(currency_id), - amount: 1, + amount: AUSD_ED, }; assert_noop!( LiquidityPools::submit(DEFAULT_DOMAIN_ADDRESS_MOONBEAM, increase_msg), @@ -1541,7 +1533,7 @@ mod same_currencies { Development::execute_with(|| { setup_pre_requirements(); let pool_id = DEFAULT_POOL_ID; - let amount: u128 = 100_000_000; + let amount: u128 = 10 * dollar(12); let investor: AccountId = AccountConverter::< DevelopmentRuntime, LocationToAccountId, @@ -1644,7 +1636,7 @@ mod same_currencies { tranche_id: default_tranche_id(pool_id), investor: investor.clone().into(), currency: general_currency_index(foreign_currency), - amount: 1, + amount: AUSD_ED, }; assert_noop!( LiquidityPools::submit(DEFAULT_DOMAIN_ADDRESS_MOONBEAM, increase_msg), From 9bb42f04c83d82b08f00cb82b004fc960cd3095f Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Thu, 26 Oct 2023 17:21:49 +0200 Subject: [PATCH 2/2] tests: fix LP transfer non tranche --- .../development/tests/liquidity_pools/transfers.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/transfers.rs b/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/transfers.rs index cb9c9ffc9f..8b7998bb82 100644 --- a/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/transfers.rs +++ b/runtime/integration-tests/src/liquidity_pools/pallet/development/tests/liquidity_pools/transfers.rs @@ -52,7 +52,7 @@ use xcm_emulator::TestExt; use crate::{ liquidity_pools::pallet::development::{ - setup::{dollar, ALICE, BOB}, + setup::{dollar, ALICE, BOB, CHARLIE}, test_net::{Development, Moonbeam, RelayChain, TestNet}, tests::liquidity_pools::setup::{ asset_metadata, create_ausd_pool, create_currency_pool, @@ -73,13 +73,17 @@ fn transfer_non_tranche_tokens_from_local() { // Register GLMR and fund BOB setup_pre_requirements(); - let initial_balance = 100_000_000; + let initial_balance = 2 * AUSD_ED; let amount = initial_balance / 2; let dest_address = DEFAULT_DOMAIN_ADDRESS_MOONBEAM; let currency_id = AUSD_CURRENCY_ID; - let source_account = BOB; + let source_account = CHARLIE; // Mint sufficient balance + assert_eq!( + OrmlTokens::free_balance(currency_id, &source_account.into()), + 0 + ); assert_ok!(OrmlTokens::mint_into( currency_id, &source_account.into(),