-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37e8ed5
commit 1e7e13a
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ mod config; | |
mod helper; | ||
mod zapin; | ||
mod zapout; | ||
mod withdraw; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use cosmwasm_std::{coins, Uint128}; | ||
use decimal::*; | ||
use oraiswap::mixed_router::SwapOperation; | ||
use oraiswap_v3_common::asset::{Asset, AssetInfo}; | ||
use oraiswap_v3_common::math::percentage::Percentage; | ||
|
||
use oraiswap_v3_common::storage::{FeeTier, PoolKey}; | ||
|
||
use crate::msg::Route; | ||
use crate::tests::common::init_basic_v3_pool; | ||
use crate::tests::helper::MockApp; | ||
use crate::tests::helper::{macros::*, FEE_DENOM}; | ||
|
||
#[test] | ||
fn test_withdraw() { | ||
let (mut app, accounts) = MockApp::new(&[ | ||
("alice", &coins(100_000_000_000, FEE_DENOM)), | ||
("bob", &coins(100_000_000_000, FEE_DENOM)), | ||
]); | ||
let alice = &accounts[0]; | ||
let bob = &accounts[1]; | ||
let initial_amount = 10u128.pow(20); | ||
let (token_x, _, _) = | ||
create_3_tokens!(app, initial_amount, initial_amount, initial_amount, alice); | ||
|
||
let zapper = create_zapper!(app, alice); | ||
|
||
app.mint_token(alice, zapper.as_str(), token_x.as_str(), 1) | ||
.unwrap(); | ||
let assets: Vec<Asset> = vec![Asset { | ||
info: AssetInfo::Token { | ||
contract_addr: token_x.clone(), | ||
}, | ||
amount: Uint128::new(1), | ||
}]; | ||
let err = app.withdraw(bob, zapper.as_str(), assets.clone(), Some(bob)) | ||
.unwrap_err(); | ||
assert!(err.root_cause().to_string().contains("Unauthorized")); | ||
|
||
app.withdraw(alice, zapper.as_str(), assets, Some(bob)) | ||
.unwrap(); | ||
let balance = balance_of!(app, token_x, bob); | ||
assert_eq!(balance, 1); | ||
} |