Skip to content

Commit

Permalink
test: deposit and withdraw
Browse files Browse the repository at this point in the history
  • Loading branch information
joemonem committed Dec 12, 2024
1 parent fba4283 commit 90a4b9d
Showing 1 changed file with 72 additions and 3 deletions.
75 changes: 72 additions & 3 deletions tests-integration/src/tests/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ use euclid::{
RegisterFactoryChainIbc, RegisterFactoryChainNative, TokenDenom, TokenDenomsResponse,
VlpResponse,
},
virtual_balance::GetStateResponse,
virtual_balance::{GetBalanceResponse, GetStateResponse},
vlp::GetLiquidityResponse,
},
swap::NextSwapPair,
token::{Pair, PairWithDenomAndAmount, Token, TokenWithDenom, TokenWithDenomAndAmount},
virtual_balance::BalanceKey,
};
use factory::{
mock::{mock_factory, MockFactory},
Expand Down Expand Up @@ -733,13 +734,13 @@ fn test_create_pool_with_funds() {
min_amount_out: Uint128::from(9000u128),
timeout: None,
swaps: vec![NextSwapPair {
token_in: eucl_token.token,
token_in: eucl_token.token.clone(),
token_out: nibi_token.token,
test_fail: None,
}],
cross_chain_addresses: vec![CrossChainUserWithLimit {
user: CrossChainUser {
address: sender,
address: sender.clone(),
chain_uid: ChainUid::create("nibiru".to_string()).unwrap(),
},
limit: None,
Expand Down Expand Up @@ -780,6 +781,74 @@ fn test_create_pool_with_funds() {
total_amount: Uint128::from((10_000u128 * 2) + 1000),
}
);

// Test deposit
factory_nibiru
.execute(
&euclid::msgs::factory::ExecuteMsg::DepositToken {
amount_in: Uint128::from(100u128),
asset_in: eucl_token.clone(),
recipient: None,
timeout: None,
},
Some(&[coin(100, "eucl")]),
)
.unwrap();

let virtual_balance_query: GetBalanceResponse = virtual_balance_nibiru
.query(&euclid::msgs::virtual_balance::QueryMsg::GetBalance {
balance_key: BalanceKey {
cross_chain_user: CrossChainUser {
address: sender.clone(),
chain_uid: ChainUid::create("nibiru".to_string()).unwrap(),
},
token_id: eucl_token.token.to_string(),
},
})
.unwrap();
assert_eq!(
virtual_balance_query,
GetBalanceResponse {
amount: Uint128::from(100u128),
}
);

// Test withdraw
factory_nibiru
.withdraw_virtual_balance(
Uint128::new(50),
vec![CrossChainUserWithLimit {
user: CrossChainUser {
address: sender.clone(),
chain_uid: ChainUid::create("nibiru".to_string()).unwrap(),
},
limit: None,
preferred_denom: None,
refund_address: None,
forwarding_message: None,
}],
Token::create("eucl".to_string()).unwrap(),
None,
)
.unwrap();

let virtual_balance_query: GetBalanceResponse = virtual_balance_nibiru
.query(&euclid::msgs::virtual_balance::QueryMsg::GetBalance {
balance_key: BalanceKey {
cross_chain_user: CrossChainUser {
address: sender.clone(),
chain_uid: ChainUid::create("nibiru".to_string()).unwrap(),
},
token_id: eucl_token.token.to_string(),
},
})
.unwrap();
assert_eq!(
virtual_balance_query,
GetBalanceResponse {
amount: Uint128::from(50u128),
}
);
}

#[test]
Expand Down

0 comments on commit 90a4b9d

Please sign in to comment.