From 1ab5cbddafd4eff041bdb35c98f88e32d705dd09 Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Tue, 15 Aug 2023 19:13:55 +0530 Subject: [PATCH] fix: clippy warnings. --- .../runtime-tests/src/parachain/replace.rs | 82 ++----------------- 1 file changed, 7 insertions(+), 75 deletions(-) diff --git a/parachain/runtime/runtime-tests/src/parachain/replace.rs b/parachain/runtime/runtime-tests/src/parachain/replace.rs index 4882d66d59..7a87eb5336 100644 --- a/parachain/runtime/runtime-tests/src/parachain/replace.rs +++ b/parachain/runtime/runtime-tests/src/parachain/replace.rs @@ -100,27 +100,6 @@ mod request_replace_tests { issue: &IssueRequest, amount: Amount, ) { - let result = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); - println!("--- result: {:#?} ---", result); - let result = ParachainTwoVaultState::get_default(&old_vault_id, &new_vault_id); - println!("--- result: {:#?} ---", result); - - // let result = ParachainTwoVaultState::get_default(&old_vault_id, &new_vault_id).with_changes( - // |old_vault, new_vault, _| { - // *old_vault - // .free_balance - // .get_mut(&new_vault_id.collateral_currency()) - // .unwrap() -= Amount::new(issue.griefing_collateral, new_vault_id.collateral_currency()); - // // let issue_amount = issue.amount(); - // println!("---- issue_amount: {:?} ----",amount); - // - // old_vault.to_be_redeemed += amount; - // new_vault.to_be_issued += amount; - // } - // ); - // println!("--- to_be_redeemed: {:#?} ---",result.vault1.to_be_redeemed); - // println!("--- to_be_issued: {:#?} ---",result.vault2.to_be_issued); - assert_eq!( ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), ParachainTwoVaultState::get_default(&old_vault_id, &new_vault_id).with_changes( @@ -139,7 +118,6 @@ mod request_replace_tests { fn integration_test_replace_accept_replace_at_capacity_succeeds() { test_with(|old_vault_id, new_vault_id| { let accept_amount = new_vault_id.wrapped(DEFAULT_VAULT_TO_BE_REPLACED.amount()); - println!("accept_amount: {:?},", accept_amount.amount()); assert_ok!(RuntimeCall::Redeem(RedeemCall::request_replace { currency_pair: old_vault_id.currencies.clone(), amount: accept_amount.amount(), @@ -157,9 +135,6 @@ mod request_replace_tests { let issue_id = assert_issue_request_event(); let issue = IssuePallet::get_issue_request_from_id(&issue_id).unwrap(); - println!("---- issue event: {:#?} -----", issue); - // println!("---- redeem event: {:#?} ----",redeem); - assert_eq!(issue.griefing_collateral(), griefing(2)); assert_state_after_accept_replace_correct(&old_vault_id, &new_vault_id, &issue, accept_amount); }); @@ -172,7 +147,6 @@ mod request_replace_tests { let accept_amount = DEFAULT_VAULT_TO_BE_REPLACED / 4; let accept_amount = old_vault_id.wrapped(accept_amount.amount()); - println!("accept_amount: {:?}", accept_amount.amount()); assert_ok!(RuntimeCall::Redeem(RedeemCall::request_replace { currency_pair: old_vault_id.currencies.clone(), @@ -191,9 +165,6 @@ mod request_replace_tests { let issue_id = assert_issue_request_event(); let issue = IssuePallet::get_issue_request_from_id(&issue_id).unwrap(); - println!("---- issue event: {:#?} -----", issue); - // println!("---- redeem event: {:#?} ----",redeem); - assert_eq!(issue.griefing_collateral(), griefing(1)); assert_state_after_accept_replace_correct(&old_vault_id, &new_vault_id, &issue, accept_amount); }); @@ -206,7 +177,6 @@ mod request_replace_tests { let accept_amount = DEFAULT_VAULT_TO_BE_REPLACED * 4; let accept_amount = old_vault_id.wrapped(accept_amount.amount()); - println!("accept_amount: {:?}", accept_amount.amount()); assert_ok!(RuntimeCall::Redeem(RedeemCall::request_replace { currency_pair: old_vault_id.currencies.clone(), @@ -218,14 +188,12 @@ mod request_replace_tests { let redeem_id = assert_redeem_request_event(); let redeem = RedeemPallet::get_open_redeem_request_from_id(&redeem_id).unwrap(); - println!("---- redeem event: {:#?} ----", redeem); assert_eq!(redeem.amount_btc, accept_amount.amount() / 2); assert_eq!(redeem.issue_id.is_some(), true); let issue_id = assert_issue_request_event(); let issue = IssuePallet::get_issue_request_from_id(&issue_id).unwrap(); - println!("---- issue event: {:#?} -----", issue); assert_eq!(issue.griefing_collateral(), griefing(4)); assert_state_after_accept_replace_correct( @@ -332,7 +300,6 @@ mod expiry_test { /// test replace created by accept fn test_with(initial_period: u32, execute: impl Fn((H256, H256))) { let amount_btc = wrapped(5_000); - let griefing_collateral = griefing(1000); super::test_with(|old_vault_id, new_vault_id| { set_replace_period(initial_period); assert_ok!(RuntimeCall::Redeem(RedeemCall::request_replace { @@ -610,11 +577,6 @@ fn integration_test_replace_execute_replace_success() { let pre_execute_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); assert_ok!(execute_replace(redeem_id)); - - let new_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); - - println!("---- old_state: {:#?} ----", pre_execute_state); - println!("---- new_state: {:#?} ----", new_state); assert_eq!( ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), pre_execute_state.with_changes(|old_vault, new_vault, _| { @@ -659,11 +621,6 @@ fn integration_test_replace_execute_replace_old_vault_liquidated() { let collateral_for_replace = calculate_replace_collateral(&old, redeem.amount_btc(), old_vault_id.collateral_currency()); - let new_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); - - println!("---- old_state: {:#?} ----", pre_execution_state); - println!("---- new_state: {:#?} ----", new_state); - assert_eq!( ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), pre_execution_state.with_changes(|old_vault, new_vault, liquidation_vault| { @@ -692,9 +649,7 @@ fn integration_test_replace_execute_replace_new_vault_liquidated() { test_with(|old_vault_id, new_vault_id| { let accept_amount = new_vault_id.wrapped(10000); - let (redeem_id, redeem, _issue_id, issue) = setup_replace(accept_amount, &old_vault_id, &new_vault_id); - - let old = CoreVaultData::vault(old_vault_id.clone()); + let (redeem_id, _redeem, _issue_id, issue) = setup_replace(accept_amount, &old_vault_id, &new_vault_id); liquidate_vault(&new_vault_id); @@ -702,13 +657,6 @@ fn integration_test_replace_execute_replace_new_vault_liquidated() { assert_ok!(execute_replace(redeem_id)); - let collateral_for_replace = - calculate_replace_collateral(&old, redeem.amount_btc(), old_vault_id.collateral_currency()); - - let new_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); - println!("---- old_state: {:#?} ----", pre_execution_state); - println!("---- new_state: {:#?} ----", new_state); - assert_eq!( ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), pre_execution_state.with_changes(|old_vault, _new_vault, liquidation_vault| { @@ -771,7 +719,7 @@ fn integration_test_replace_execute_replace_both_vaults_liquidated() { fn integration_test_replace_execute_replace_with_cancelled() { test_with(|old_vault_id, new_vault_id| { let accept_amount = new_vault_id.wrapped(10000); - let (redeem_id, redeem, _issue_id, issue) = setup_replace(accept_amount, &old_vault_id, &new_vault_id); + let (redeem_id, _redeem, _issue_id, _issue) = setup_replace(accept_amount, &old_vault_id, &new_vault_id); cancel_replace(redeem_id); assert_err!(execute_replace(redeem_id), RedeemError::RedeemCancelled); }); @@ -781,12 +729,9 @@ fn integration_test_replace_execute_replace_with_cancelled() { fn integration_test_replace_cancel_replace_success() { test_with(|old_vault_id, new_vault_id| { let accept_amount = new_vault_id.wrapped(10000); - let (redeem_id, redeem, _issue_id, issue) = setup_replace(accept_amount, &old_vault_id, &new_vault_id); + let (redeem_id, _redeem, _issue_id, issue) = setup_replace(accept_amount, &old_vault_id, &new_vault_id); let pre_cancellation_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); cancel_replace(redeem_id); - let new_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); - println!("---- pre_cancellation_state: {:#?} ----", pre_cancellation_state); - println!("---- new_state: {:#?} ----", new_state); assert_eq!( ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), @@ -816,9 +761,6 @@ fn integration_test_replace_cancel_replace_old_vault_liquidated() { let collateral_for_replace = calculate_replace_collateral(&old, redeem.amount_btc(), old_vault_id.collateral_currency()); - let new_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); - println!("---- pre_cancellation_state: {:#?} ----", pre_cancellation_state); - println!("---- new_state: {:#?} ----", new_state); assert_eq!( ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), @@ -842,16 +784,13 @@ fn integration_test_replace_cancel_replace_old_vault_liquidated() { fn integration_test_replace_cancel_replace_new_vault_liquidated() { test_with(|old_vault_id, new_vault_id| { let accept_amount = new_vault_id.wrapped(10000); - let (redeem_id, redeem, _issue_id, issue) = setup_replace(accept_amount, &old_vault_id, &new_vault_id); + let (redeem_id, _redeem, _issue_id, issue) = setup_replace(accept_amount, &old_vault_id, &new_vault_id); liquidate_vault(&new_vault_id); let pre_cancellation_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); cancel_replace(redeem_id); - let new_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); - println!("---- pre_cancellation_state: {:#?} ----", pre_cancellation_state); - println!("---- new_state: {:#?} ----", new_state); assert_eq!( ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), @@ -881,9 +820,6 @@ fn integration_test_replace_cancel_replace_both_vaults_liquidated() { let pre_cancellation_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); cancel_replace(redeem_id); - let new_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); - println!("---- pre_cancellation_state: {:#?} ----", pre_cancellation_state); - println!("---- new_state: {:#?} ----", new_state); let collateral_for_replace = calculate_replace_collateral(&old, redeem.amount_btc(), old_vault_id.collateral_currency()); @@ -931,15 +867,11 @@ fn integration_test_replace_vault_with_different_currency_succeeds() { CoreVaultData::force_to(&new_vault_id, default_vault_state(&new_vault_id)); let accept_amount = new_vault_id.wrapped(10000); - let (redeem_id, redeem, _issue_id, issue) = setup_replace(accept_amount, &old_vault_id, &new_vault_id); + let (redeem_id, _redeem, _issue_id, issue) = setup_replace(accept_amount, &old_vault_id, &new_vault_id); let pre_execute_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); assert_ok!(execute_replace(redeem_id)); - let new_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); - - println!("---- pre_execute_state: {:#?} ----", pre_execute_state); - println!("---- new_state: {:#?} ----", new_state); assert_eq!( ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), @@ -993,7 +925,7 @@ mod oracle_down { fn no_oracle_cancel_replace_succeeds() { test_with(|old_vault_id, new_vault_id| { let accept_amount = new_vault_id.wrapped(10000); - let (redeem_id, redeem, _issue_id, issue) = setup_replace(accept_amount, &old_vault_id, &new_vault_id); + let (redeem_id, _redeem, _issue_id, _issue) = setup_replace(accept_amount, &old_vault_id, &new_vault_id); OraclePallet::expire_all(); @@ -1012,7 +944,7 @@ mod oracle_down { fn no_oracle_execute_cancelled_replace_succeeds() { test_with(|old_vault_id, new_vault_id| { let accept_amount = new_vault_id.wrapped(10000); - let (redeem_id, redeem, _issue_id, issue) = setup_replace(accept_amount, &old_vault_id, &new_vault_id); + let (redeem_id, _redeem, _issue_id, _issue) = setup_replace(accept_amount, &old_vault_id, &new_vault_id); OraclePallet::expire_all(); assert_ok!(execute_replace(redeem_id));