Skip to content

Commit

Permalink
not important; fix test compilation - WithdrawRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
mariocynicys committed Sep 12, 2024
1 parent 12c5b41 commit 5d90387
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 115 deletions.
10 changes: 2 additions & 8 deletions mm2src/coins/eth/eth_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,13 @@ fn test_withdraw_impl_manual_fee() {

let withdraw_req = WithdrawRequest {
amount: 1.into(),
from: None,
to: "0x7Bc1bBDD6A0a722fC9bffC49c921B685ECB84b94".to_string(),
coin: "ETH".to_string(),
max: false,
fee: Some(WithdrawFee::EthGas {
gas: gas_limit::ETH_MAX_TRADE_GAS,
gas_price: 1.into(),
}),
memo: None,
ibc_source_channel: None,
..Default::default()
};
coin.get_balance().wait().unwrap();

Expand Down Expand Up @@ -260,16 +257,13 @@ fn test_withdraw_impl_fee_details() {

let withdraw_req = WithdrawRequest {
amount: 1.into(),
from: None,
to: "0x7Bc1bBDD6A0a722fC9bffC49c921B685ECB84b94".to_string(),
coin: "JST".to_string(),
max: false,
fee: Some(WithdrawFee::EthGas {
gas: gas_limit::ETH_MAX_TRADE_GAS,
gas_price: 1.into(),
}),
memo: None,
ibc_source_channel: None,
..Default::default()
};
coin.get_balance().wait().unwrap();

Expand Down
14 changes: 3 additions & 11 deletions mm2src/coins/lp_coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2160,7 +2160,7 @@ pub trait GetWithdrawSenderAddress {
/// Instead, accept a generic type from withdraw implementations.
/// This way we won't have to update the payload for every platform when
/// one of them requires specific addition.
#[derive(Clone, Deserialize)]
#[derive(Clone, Default, Deserialize)]
pub struct WithdrawRequest {
coin: String,
from: Option<WithdrawFrom>,
Expand Down Expand Up @@ -2222,15 +2222,9 @@ impl WithdrawRequest {
pub fn new_max(coin: String, to: String) -> WithdrawRequest {
WithdrawRequest {
coin,
from: None,
to,
amount: 0.into(),
max: true,
fee: None,
memo: None,
ibc_source_channel: None,
#[cfg(target_arch = "wasm32")]
broadcast: false,
..Default::default()
}
}
}
Expand Down Expand Up @@ -5691,10 +5685,8 @@ pub mod for_tests {
}),
to: to.to_owned(),
coin: ticker.to_owned(),
max: false,
fee,
memo: None,
ibc_source_channel: None,
..Default::default()
};
let init = init_withdraw(ctx.clone(), withdraw_req).await.unwrap();
let timeout = wait_until_ms(150000);
Expand Down
11 changes: 2 additions & 9 deletions mm2src/coins/qrc20/qrc20_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,9 @@ fn test_withdraw_to_p2sh_address_should_fail() {

let req = WithdrawRequest {
amount: 10.into(),
from: None,
to: p2sh_address.to_string(),
coin: "QRC20".into(),
max: false,
fee: None,
memo: None,
ibc_source_channel: None,
..Default::default()
};
let err = coin.withdraw(req).wait().unwrap_err().into_inner();
let expect = WithdrawError::InvalidAddress("QRC20 can be sent to P2PKH addresses only".to_owned());
Expand Down Expand Up @@ -129,16 +125,13 @@ fn test_withdraw_impl_fee_details() {

let withdraw_req = WithdrawRequest {
amount: 10.into(),
from: None,
to: "qHmJ3KA6ZAjR9wGjpFASn4gtUSeFAqdZgs".into(),
coin: "QRC20".into(),
max: false,
fee: Some(WithdrawFee::Qrc20Gas {
gas_limit: 2_500_000,
gas_price: 40,
}),
memo: None,
ibc_source_channel: None,
..Default::default()
};
let tx_details = coin.withdraw(withdraw_req).wait().unwrap();

Expand Down
29 changes: 5 additions & 24 deletions mm2src/coins/solana/solana_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,9 @@ fn solana_transaction_simulations() {
sol_coin
.withdraw(WithdrawRequest {
coin: "SOL".to_string(),
from: None,
to: sol_coin.my_address.clone(),
amount: request_amount.clone(),
max: false,
fee: None,
memo: None,
ibc_source_channel: None,
..Default::default()
})
.compat(),
)
Expand All @@ -189,13 +185,9 @@ fn solana_transaction_zero_balance() {
sol_coin
.withdraw(WithdrawRequest {
coin: "SOL".to_string(),
from: None,
to: sol_coin.my_address.clone(),
amount: BigDecimal::from_str("0.000001").unwrap(),
max: false,
fee: None,
memo: None,
ibc_source_channel: None,
..Default::default()
})
.compat(),
);
Expand All @@ -219,13 +211,9 @@ fn solana_transaction_simulations_not_enough_for_fees() {
sol_coin
.withdraw(WithdrawRequest {
coin: "SOL".to_string(),
from: None,
to: sol_coin.my_address.clone(),
amount: BigDecimal::from(1),
max: false,
fee: None,
memo: None,
ibc_source_channel: None,
..Default::default()
})
.compat(),
);
Expand Down Expand Up @@ -254,13 +242,10 @@ fn solana_transaction_simulations_max() {
sol_coin
.withdraw(WithdrawRequest {
coin: "SOL".to_string(),
from: None,
to: sol_coin.my_address.clone(),
amount: BigDecimal::from(0),
max: true,
fee: None,
memo: None,
ibc_source_channel: None,
..Default::default()
})
.compat(),
)
Expand All @@ -284,13 +269,9 @@ fn solana_test_transactions() {
sol_coin
.withdraw(WithdrawRequest {
coin: "SOL".to_string(),
from: None,
to: sol_coin.my_address.clone(),
amount: BigDecimal::try_from(0.0001).unwrap(),
max: false,
fee: None,
memo: None,
ibc_source_channel: None,
..Default::default()
})
.compat(),
)
Expand Down
6 changes: 1 addition & 5 deletions mm2src/coins/solana/spl_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,9 @@ fn test_spl_transactions() {
usdc_sol_coin
.withdraw(WithdrawRequest {
coin: "USDC".to_string(),
from: None,
to: "AYJmtzc9D4KU6xsDzhKShFyYKUNXY622j9QoQEo4LfpX".to_string(),
amount: withdraw_amount.clone(),
max: false,
fee: None,
memo: None,
ibc_source_channel: None,
..Default::default()
})
.compat(),
)
Expand Down
Loading

0 comments on commit 5d90387

Please sign in to comment.