Skip to content

Commit

Permalink
fix clippy in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
laruh committed Dec 12, 2024
1 parent ac9a5a3 commit ab56a12
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion mm2src/mm2_main/src/lp_swap/maker_swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
27 changes: 13 additions & 14 deletions mm2src/mm2_main/tests/docker_tests/eth_docker_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, &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;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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, &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;
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -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, &eth_sepolia_conf(), false);
let maker_coin = get_or_create_sepolia_coin(&MM_CTX, SEPOLIA_MAKER_PRIV, ETH, &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());
Expand Down Expand Up @@ -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());
Expand Down
18 changes: 9 additions & 9 deletions mm2src/mm2_main/tests/docker_tests/swap_proto_v2_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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),
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
}
}

Expand Down

0 comments on commit ab56a12

Please sign in to comment.