From a59c6aaf0c72a7e72f5e54cdf334ce2eb651ee85 Mon Sep 17 00:00:00 2001 From: lemunozm Date: Tue, 13 Aug 2024 21:51:42 +0200 Subject: [PATCH] fix lp tests --- runtime/integration-tests/src/cases.rs | 2 +- runtime/integration-tests/src/cases/lp/mod.rs | 9 +-- .../src/cases/lp/setup_lp.rs | 61 ++++++------------- .../integration-tests/src/cases/lp/utils.rs | 4 +- 4 files changed, 25 insertions(+), 51 deletions(-) diff --git a/runtime/integration-tests/src/cases.rs b/runtime/integration-tests/src/cases.rs index b0ea5ec3db..38f6212f63 100644 --- a/runtime/integration-tests/src/cases.rs +++ b/runtime/integration-tests/src/cases.rs @@ -8,7 +8,7 @@ mod investments; mod liquidity_pools; mod liquidity_pools_gateway_queue; mod loans; -//mod lp; +mod lp; mod oracles; mod proxy; mod restricted_transfers; diff --git a/runtime/integration-tests/src/cases/lp/mod.rs b/runtime/integration-tests/src/cases/lp/mod.rs index acfa20336a..1c6896a9bf 100644 --- a/runtime/integration-tests/src/cases/lp/mod.rs +++ b/runtime/integration-tests/src/cases/lp/mod.rs @@ -10,7 +10,6 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -use axelar_gateway_precompile::SourceConverter; use cfg_primitives::{Balance, PoolId, CFG, SECONDS_PER_HOUR, SECONDS_PER_YEAR}; use cfg_traits::Seconds; use cfg_types::{ @@ -22,14 +21,10 @@ use ethabi::{ ethereum_types::{H160, U128, U256}, FixedBytes, Token, Uint, }; -use frame_support::{ - assert_ok, dispatch::RawOrigin, pallet_prelude::ConstU32, traits::OriginTrait, BoundedVec, -}; +use frame_support::{assert_ok, dispatch::RawOrigin, traits::OriginTrait}; use frame_system::pallet_prelude::OriginFor; use hex_literal::hex; -use liquidity_pools_gateway_routers::{ - AxelarEVMRouter, DomainRouter, EVMDomain, EVMRouter, FeeValues, MAX_AXELAR_EVM_CHAIN_SIZE, -}; +use pallet_axelar_router::{AxelarConfig, DomainConfig, EvmConfig, FeeValues}; use pallet_evm::FeeCalculator; use runtime_common::account_conversion::AccountConverter; pub use setup_lp::*; diff --git a/runtime/integration-tests/src/cases/lp/setup_lp.rs b/runtime/integration-tests/src/cases/lp/setup_lp.rs index 684cdd83ab..efc3ad0299 100644 --- a/runtime/integration-tests/src/cases/lp/setup_lp.rs +++ b/runtime/integration-tests/src/cases/lp/setup_lp.rs @@ -41,10 +41,7 @@ pub fn setup as EnvEvmExtension>::E evm.load_contracts(); // Fund gateway sender - give_balance::( - ::Sender::get(), - DEFAULT_BALANCE * CFG, - ); + give_balance::(T::Sender::get().address().into(), DEFAULT_BALANCE * CFG); // Register general local pool-currency register_currency::(LocalUSDC, |_| {}); @@ -67,49 +64,31 @@ pub fn setup as EnvEvmExtension>::E // Create router let (base_fee, _) = ::FeeCalculator::min_gas_price(); - let evm_domain = EVMDomain { - target_contract_address: evm.deployed(names::ADAPTER).address(), - target_contract_hash: BlakeTwo256::hash_of( - &evm.deployed(names::ADAPTER).deployed_bytecode, - ), - fee_values: FeeValues { - value: sp_core::U256::zero(), - gas_limit: sp_core::U256::from(500_000), - gas_price: sp_core::U256::from(base_fee), - }, + let axelar_evm_config = AxelarConfig { + liquidity_pools_contract_address: evm.deployed(names::ADAPTER).address(), + domain: DomainConfig::Evm(EvmConfig { + chain_id: EVM_DOMAIN_CHAIN_ID, + target_contract_address: evm.deployed(names::ADAPTER).address(), + target_contract_hash: BlakeTwo256::hash_of( + &evm.deployed(names::ADAPTER).deployed_bytecode, + ), + fee_values: FeeValues { + value: sp_core::U256::zero(), + gas_limit: sp_core::U256::from(500_000), + gas_price: sp_core::U256::from(base_fee), + }, + }), }; - let axelar_evm_router = AxelarEVMRouter::::new( - EVMRouter::new(evm_domain), - BoundedVec::>::try_from( - EVM_DOMAIN_STR.as_bytes().to_vec(), - ) - .unwrap(), - evm.deployed(names::ADAPTER).address(), - ); - - assert_ok!( - pallet_liquidity_pools_gateway::Pallet::::set_domain_router( - RawOrigin::Root.into(), - Domain::EVM(EVM_DOMAIN_CHAIN_ID), - DomainRouter::::AxelarEVM(axelar_evm_router), - ) - ); - - assert_ok!(pallet_liquidity_pools_gateway::Pallet::::add_instance( + assert_ok!(pallet_axelar_router::Pallet::::set_config( RawOrigin::Root.into(), - DomainAddress::evm(EVM_DOMAIN_CHAIN_ID, EVM_LP_INSTANCE) + EVM_DOMAIN_STR.as_bytes().to_vec().try_into().unwrap(), + Box::new(axelar_evm_config) )); - assert_ok!(axelar_gateway_precompile::Pallet::::set_gateway( - RawOrigin::Root.into(), - evm.deployed(names::ADAPTER).address() - )); - - assert_ok!(axelar_gateway_precompile::Pallet::::set_converter( + assert_ok!(pallet_liquidity_pools_gateway::Pallet::::add_instance( RawOrigin::Root.into(), - BlakeTwo256::hash(EVM_DOMAIN_STR.as_bytes()), - SourceConverter::new(EVM_DOMAIN), + DomainAddress::evm(EVM_DOMAIN_CHAIN_ID, EVM_LP_INSTANCE) )); assert_ok!( diff --git a/runtime/integration-tests/src/cases/lp/utils.rs b/runtime/integration-tests/src/cases/lp/utils.rs index 191f8ddb16..e8229d5c17 100644 --- a/runtime/integration-tests/src/cases/lp/utils.rs +++ b/runtime/integration-tests/src/cases/lp/utils.rs @@ -20,7 +20,7 @@ use frame_support::traits::{OriginTrait, PalletInfo}; use frame_system::pallet_prelude::OriginFor; use pallet_evm::ExecutionInfo; use pallet_liquidity_pools_gateway::message::GatewayMessage; -use sp_core::{ByteArray, Get}; +use sp_core::Get; use sp_runtime::{ traits::{Convert, EnsureAdd}, DispatchError, @@ -99,7 +99,7 @@ pub fn verify_outbound_failure_on_lp(to: H160) { // The sender is the sender account on the gateway assert_eq!( status.from.0, - ::Sender::get().as_slice()[0..20] + ::Sender::get().address()[0..20] ); assert_eq!(status.to.unwrap().0, to.0); assert!(!receipt_ok(receipt));