From ab56a126224b9b3be652f194cae9804e8f9e89bc Mon Sep 17 00:00:00 2001 From: laruh Date: Thu, 12 Dec 2024 18:32:34 +0700 Subject: [PATCH] fix clippy in tests --- mm2src/mm2_main/src/lp_swap/maker_swap.rs | 2 +- .../tests/docker_tests/eth_docker_tests.rs | 27 +++++++++---------- .../tests/docker_tests/swap_proto_v2_tests.rs | 18 ++++++------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/mm2src/mm2_main/src/lp_swap/maker_swap.rs b/mm2src/mm2_main/src/lp_swap/maker_swap.rs index 97a3d63b2b..79d57912f1 100644 --- a/mm2src/mm2_main/src/lp_swap/maker_swap.rs +++ b/mm2src/mm2_main/src/lp_swap/maker_swap.rs @@ -1819,7 +1819,7 @@ impl MakerSavedSwap { event: MakerSwapEvent::Started(MakerSwapData { taker_coin: "".to_string(), maker_coin: "".to_string(), - taker: Default::default(), + taker_pubkey: Default::default(), secret: Default::default(), secret_hash: None, my_persistent_pub: Default::default(), diff --git a/mm2src/mm2_main/tests/docker_tests/eth_docker_tests.rs b/mm2src/mm2_main/tests/docker_tests/eth_docker_tests.rs index 079e566cfc..d922ba8f27 100644 --- a/mm2src/mm2_main/tests/docker_tests/eth_docker_tests.rs +++ b/mm2src/mm2_main/tests/docker_tests/eth_docker_tests.rs @@ -1485,7 +1485,7 @@ fn send_and_refund_taker_funding_by_secret_eth() { let maker_coin = get_or_create_sepolia_coin(&MM_CTX, SEPOLIA_MAKER_PRIV, ETH, ð_sepolia_conf(), false); let taker_secret = &[0; 32]; - let taker_secret_hash = sha256(&taker_secret).to_vec(); + let taker_secret_hash = sha256(taker_secret).to_vec(); let maker_secret = &[1; 32]; let maker_secret_hash = sha256(maker_secret).to_vec(); let funding_time_lock = now_sec() + 3000; @@ -1548,7 +1548,7 @@ fn send_and_refund_taker_funding_by_secret_erc20() { let maker_coin = get_or_create_sepolia_coin(&MM_CTX1, SEPOLIA_MAKER_PRIV, ERC20, erc20_conf, true); let taker_secret = &[0; 32]; - let taker_secret_hash = sha256(&taker_secret).to_vec(); + let taker_secret_hash = sha256(taker_secret).to_vec(); let maker_secret = [1; 32]; let maker_secret_hash = sha256(&maker_secret).to_vec(); @@ -1675,7 +1675,7 @@ fn taker_send_approve_and_spend_eth() { let maker_coin = get_or_create_sepolia_coin(&MM_CTX, SEPOLIA_MAKER_PRIV, ETH, ð_sepolia_conf(), false); let taker_secret = &[0; 32]; - let taker_secret_hash = sha256(&taker_secret).to_vec(); + let taker_secret_hash = sha256(taker_secret).to_vec(); let maker_secret = &[1; 32]; let maker_secret_hash = sha256(maker_secret).to_vec(); let funding_time_lock = now_sec() + 3000; @@ -1770,15 +1770,14 @@ fn taker_send_approve_and_spend_eth() { }; wait_pending_transactions(Address::from_slice(maker_address.as_bytes())); let spend_tx = - block_on(maker_coin.sign_and_broadcast_taker_payment_spend(&preimage, &spend_args, &maker_secret, &[])) - .unwrap(); + block_on(maker_coin.sign_and_broadcast_taker_payment_spend(&preimage, &spend_args, maker_secret, &[])).unwrap(); log!("Maker spent ETH payment, tx hash: {:02x}", spend_tx.tx_hash()); wait_for_confirmations(&maker_coin, &spend_tx, 100); let found_spend_tx = block_on(taker_coin.find_taker_payment_spend_tx(&taker_approve_tx, taker_coin_start_block, payment_time_lock)) .unwrap(); let extracted_maker_secret = block_on(taker_coin.extract_secret_v2(&[], &found_spend_tx)).unwrap(); - assert_eq!(maker_secret, extracted_maker_secret); + assert_eq!(maker_secret, &extracted_maker_secret); } #[cfg(feature = "sepolia-taker-swap-v2-tests")] @@ -2249,10 +2248,10 @@ fn send_maker_payment_and_refund_secret_eth() { let taker_coin = get_or_create_sepolia_coin(&MM_CTX1, SEPOLIA_TAKER_PRIV, ETH, ð_sepolia_conf(), false); let maker_coin = get_or_create_sepolia_coin(&MM_CTX, SEPOLIA_MAKER_PRIV, ETH, ð_sepolia_conf(), false); - let taker_secret = [0; 32]; - let taker_secret_hash = sha256(&taker_secret).to_vec(); - let maker_secret = [1; 32]; - let maker_secret_hash = sha256(&maker_secret).to_vec(); + let taker_secret = &[0; 32]; + let taker_secret_hash = sha256(taker_secret).to_vec(); + let maker_secret = &[1; 32]; + let maker_secret_hash = sha256(maker_secret).to_vec(); let payment_time_lock = now_sec() + 1000; let maker_address = block_on(maker_coin.my_addr()); @@ -2301,10 +2300,10 @@ fn send_maker_payment_and_refund_secret_erc20() { let taker_coin = get_or_create_sepolia_coin(&MM_CTX1, SEPOLIA_TAKER_PRIV, ERC20, erc20_conf, true); let maker_coin = get_or_create_sepolia_coin(&MM_CTX, SEPOLIA_MAKER_PRIV, ERC20, erc20_conf, true); - let taker_secret = [0; 32]; - let taker_secret_hash = sha256(&taker_secret).to_vec(); - let maker_secret = [1; 32]; - let maker_secret_hash = sha256(&maker_secret).to_vec(); + let taker_secret = &[0; 32]; + let taker_secret_hash = sha256(taker_secret).to_vec(); + let maker_secret = &[1; 32]; + let maker_secret_hash = sha256(maker_secret).to_vec(); let payment_time_lock = now_sec() + 1000; let maker_address = block_on(maker_coin.my_addr()); diff --git a/mm2src/mm2_main/tests/docker_tests/swap_proto_v2_tests.rs b/mm2src/mm2_main/tests/docker_tests/swap_proto_v2_tests.rs index 840c4481a4..31cdd4d3ff 100644 --- a/mm2src/mm2_main/tests/docker_tests/swap_proto_v2_tests.rs +++ b/mm2src/mm2_main/tests/docker_tests/swap_proto_v2_tests.rs @@ -107,8 +107,8 @@ fn send_and_refund_taker_funding_secret() { let (_mm_arc, coin, _privkey) = generate_utxo_coin_with_random_privkey(MYCOIN, 1000.into()); let funding_time_lock = now_sec() - 1000; - let taker_secret = [0; 32]; - let taker_secret_hash_owned = dhash160(&taker_secret); + let taker_secret = &[0; 32]; + let taker_secret_hash_owned = dhash160(taker_secret); let taker_secret_hash = taker_secret_hash_owned.as_slice(); let maker_pub = coin.my_public_key().unwrap(); let dex_fee = &DexFee::Standard("0.01".into()); @@ -186,7 +186,7 @@ fn send_and_refund_taker_funding_secret() { match found_refund_tx { Some(FundingTxSpend::RefundedSecret { tx, secret }) => { assert_eq!(refund_tx, tx); - assert_eq!(taker_secret, secret); + assert_eq!(taker_secret, &secret); }, unexpected => panic!("Got unexpected FundingTxSpend variant {:?}", unexpected), } @@ -559,10 +559,10 @@ fn send_and_refund_maker_payment_timelock() { #[test] fn send_and_refund_maker_payment_taker_secret() { let (_mm_arc, coin, _privkey) = generate_utxo_coin_with_random_privkey(MYCOIN, 1000.into()); - let taker_secret = [1; 32]; + let taker_secret = &[1; 32]; let time_lock = now_sec() + 1000; - let taker_secret_hash_owned = dhash160(&taker_secret); + let taker_secret_hash_owned = dhash160(taker_secret); let taker_secret_hash = taker_secret_hash_owned.as_slice(); let maker_secret_hash = &[1; 20]; let taker_pub = coin.my_public_key().unwrap(); @@ -699,8 +699,8 @@ fn test_v2_swap_utxo_utxo() { assert_eq!(locked_bob.locked_amount, expected); for uuid in uuids { - block_on(wait_for_swap_finished(&mm_bob, &uuid, 180)); - block_on(wait_for_swap_finished(&mm_alice, &uuid, 100)); + block_on(wait_for_swap_finished(&mm_bob, &uuid, 60)); + block_on(wait_for_swap_finished(&mm_alice, &uuid, 30)); let maker_swap_status = block_on(my_swap_status(&mm_bob, &uuid)); log!("{:?}", maker_swap_status); @@ -829,8 +829,8 @@ fn test_v2_swap_utxo_utxo_kickstart() { assert_eq!(locked_bob.locked_amount, expected); for uuid in uuids { - block_on(wait_for_swap_finished(&mm_bob, &uuid, 180)); - block_on(wait_for_swap_finished(&mm_alice, &uuid, 100)); + block_on(wait_for_swap_finished(&mm_bob, &uuid, 60)); + block_on(wait_for_swap_finished(&mm_alice, &uuid, 30)); } }