Skip to content

Commit

Permalink
fix lp tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed Aug 13, 2024
1 parent 7bb3076 commit a59c6aa
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 51 deletions.
2 changes: 1 addition & 1 deletion runtime/integration-tests/src/cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 2 additions & 7 deletions runtime/integration-tests/src/cases/lp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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::*;
Expand Down
61 changes: 20 additions & 41 deletions runtime/integration-tests/src/cases/lp/setup_lp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ pub fn setup<T: Runtime, F: FnOnce(&mut <RuntimeEnv<T> as EnvEvmExtension<T>>::E
evm.load_contracts();

// Fund gateway sender
give_balance::<T>(
<T as pallet_liquidity_pools_gateway::Config>::Sender::get(),
DEFAULT_BALANCE * CFG,
);
give_balance::<T>(T::Sender::get().address().into(), DEFAULT_BALANCE * CFG);

// Register general local pool-currency
register_currency::<T>(LocalUSDC, |_| {});
Expand All @@ -67,49 +64,31 @@ pub fn setup<T: Runtime, F: FnOnce(&mut <RuntimeEnv<T> as EnvEvmExtension<T>>::E
// Create router
let (base_fee, _) = <T as pallet_evm::Config>::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::<T>::new(
EVMRouter::new(evm_domain),
BoundedVec::<u8, ConstU32<MAX_AXELAR_EVM_CHAIN_SIZE>>::try_from(
EVM_DOMAIN_STR.as_bytes().to_vec(),
)
.unwrap(),
evm.deployed(names::ADAPTER).address(),
);

assert_ok!(
pallet_liquidity_pools_gateway::Pallet::<T>::set_domain_router(
RawOrigin::Root.into(),
Domain::EVM(EVM_DOMAIN_CHAIN_ID),
DomainRouter::<T>::AxelarEVM(axelar_evm_router),
)
);

assert_ok!(pallet_liquidity_pools_gateway::Pallet::<T>::add_instance(
assert_ok!(pallet_axelar_router::Pallet::<T>::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::<T>::set_gateway(
RawOrigin::Root.into(),
evm.deployed(names::ADAPTER).address()
));

assert_ok!(axelar_gateway_precompile::Pallet::<T>::set_converter(
assert_ok!(pallet_liquidity_pools_gateway::Pallet::<T>::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!(
Expand Down
4 changes: 2 additions & 2 deletions runtime/integration-tests/src/cases/lp/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -99,7 +99,7 @@ pub fn verify_outbound_failure_on_lp<T: Runtime>(to: H160) {
// The sender is the sender account on the gateway
assert_eq!(
status.from.0,
<T as pallet_liquidity_pools_gateway::Config>::Sender::get().as_slice()[0..20]
<T as pallet_liquidity_pools_gateway::Config>::Sender::get().address()[0..20]
);
assert_eq!(status.to.unwrap().0, to.0);
assert!(!receipt_ok(receipt));
Expand Down

0 comments on commit a59c6aa

Please sign in to comment.