Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable clippy --all-features on CI #1760

Merged
merged 5 commits into from Apr 26, 2023
Merged

Enable clippy --all-features on CI #1760

merged 5 commits into from Apr 26, 2023

Conversation

rozhkovdmitrii
Copy link

No description provided.

@caglaryucekaya
Copy link

@caglaryucekaya caglaryucekaya added the in progress Changes will be made from the author label Apr 19, 2023
Comment on lines 13 to 15
// dummy test helping IDE to recognize this as test module
#[test]
fn dummy() { assert!(true) }
fn dummy() {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't use IDEs, can anyone test this?

cc @KomodoPlatform/mm2

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine. Removed the test and the IDE didn't recognize docker_tests as a test mod
https://github.com/KomodoPlatform/atomicDEX-API/blob/75663fff7f3f052b0b153d2695e7b8b84480513f/mm2src/mm2_main/tests/docker_tests_main.rs#L29
With the change in this PR it's still recognized as a test mod.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm then why here assert!(true) was left for dummy test help? @rozhkovdmitrii

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was left because clippy didn't recognize it as problem. I think that is outdated workaround, I've got rid of it. Thank you @laruh

@rozhkovdmitrii rozhkovdmitrii marked this pull request as ready for review April 20, 2023 11:30
@rozhkovdmitrii rozhkovdmitrii marked this pull request as draft April 20, 2023 11:30
@rozhkovdmitrii rozhkovdmitrii marked this pull request as ready for review April 20, 2023 11:52
@shamardy shamardy added bug fixing week 1 and removed in progress Changes will be made from the author labels Apr 20, 2023
@shamardy
Copy link
Collaborator

Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this very much needed refactor/fixes! Only some minor comments :)

mm2src/coins/z_coin.rs Outdated Show resolved Hide resolved
mm2src/mm2_main/tests/docker_tests/docker_tests_inner.rs Outdated Show resolved Hide resolved
mm2src/mm2_main/tests/docker_tests/mod.rs Outdated Show resolved Hide resolved
mm2src/mm2_main/tests/mm2_tests/mod.rs Outdated Show resolved Hide resolved
@rozhkovdmitrii
Copy link
Author

@rozhkovdmitrii shouldn't we use the --all-features flag here after the fixes?

Yeah thank you, I lost during solving conflicts

Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last minor comments related to commits after last review and z_coin_native_tests which I didn't cover in the last review

mm2src/mm2_main/tests/mm2_tests/mod.rs Outdated Show resolved Hide resolved
let priv_key = [1; 32];
let mut conf = zombie_conf();
let params = default_zcoin_activation_params();
let priv_key = PrivKeyBuildPolicy::IguanaPrivKey(IguanaPrivKey::default());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use priv_key = [1; 32]; instead of default as it was done before, This will need changing in all tests that had it.

Index: mm2src/coins/z_coin/z_coin_native_tests.rs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/mm2src/coins/z_coin/z_coin_native_tests.rs b/mm2src/coins/z_coin/z_coin_native_tests.rs
--- a/mm2src/coins/z_coin/z_coin_native_tests.rs	(revision 1d6c9afbaeed16f524db6d953f57b589297a5f2f)
+++ b/mm2src/coins/z_coin/z_coin_native_tests.rs	(date 1682094202752)
@@ -17,7 +17,8 @@
     let ctx = MmCtxBuilder::default().into_mm_arc();
     let mut conf = zombie_conf();
     let params = default_zcoin_activation_params();
-    let priv_key = PrivKeyBuildPolicy::IguanaPrivKey(IguanaPrivKey::default());
+    let private_key_data = [1; 32];
+    let priv_key = PrivKeyBuildPolicy::IguanaPrivKey(private_key_data.into());
     let db_dir = PathBuf::from("./for_tests");
     let z_key = decode_extended_spending_key(z_mainnet_constants::HRP_SAPLING_EXTENDED_SPENDING_KEY, "secret-extended-key-main1q0k2ga2cqqqqpq8m8j6yl0say83cagrqp53zqz54w38ezs8ly9ly5ptamqwfpq85u87w0df4k8t2lwyde3n9v0gcr69nu4ryv60t0kfcsvkr8h83skwqex2nf0vr32794fmzk89cpmjptzc22lgu5wfhhp8lgf3f5vn2l3sge0udvxnm95k6dtxj2jwlfyccnum7nz297ecyhmd5ph526pxndww0rqq0qly84l635mec0x4yedf95hzn6kcgq8yxts26k98j9g32kjc8y83fe").unwrap().unwrap();
     let CoinProtocol::ZHTLC(protocol_info) = serde_json::from_value::<CoinProtocol>(conf["protocol"].take()).unwrap() else { unimplemented!() };
@@ -27,7 +28,7 @@
         "ZOMBIE",
         &conf,
         &params,
-        priv_key.clone(),
+        priv_key,
         db_dir,
         z_key,
         protocol_info,
@@ -52,7 +53,6 @@
     };
     let tx = coin.send_maker_payment(args).wait().unwrap();
     println!("swap tx {}", hex::encode(tx.tx_hash().0));
-    let PrivKeyBuildPolicy::IguanaPrivKey(private_key_data) = priv_key else { unimplemented!() };
 
     let refund_args = RefundPaymentArgs {
         payment_tx: &tx.tx_hex(),
@@ -60,7 +60,7 @@
         other_pubkey: taker_pub,
         secret_hash: &secret_hash,
         swap_contract_address: &None,
-        swap_unique_data: private_key_data.as_slice(),
+        swap_unique_data: &private_key_data,
         watcher_reward: false,
     };
     let refund_tx = coin.send_maker_refunds_payment(refund_args).wait().unwrap();

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As shown in the above patch, this line
https://github.com/KomodoPlatform/atomicDEX-API/blob/2340ad8c2d574f183cfb5f06444e19a6cde7a19b/mm2src/coins/z_coin/z_coin_native_tests.rs#L58
Won't be needed if we initialized private key data variable before using it in the policy. This will also avoid a clone that is currently used.

Copy link
Collaborator

@shamardy shamardy Apr 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a blocker, I will approve the PR without it, but it will make code a tiny bit better :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

let z_key = decode_extended_spending_key(z_mainnet_constants::HRP_SAPLING_EXTENDED_SPENDING_KEY, "secret-extended-key-main1q0k2ga2cqqqqpq8m8j6yl0say83cagrqp53zqz54w38ezs8ly9ly5ptamqwfpq85u87w0df4k8t2lwyde3n9v0gcr69nu4ryv60t0kfcsvkr8h83skwqex2nf0vr32794fmzk89cpmjptzc22lgu5wfhhp8lgf3f5vn2l3sge0udvxnm95k6dtxj2jwlfyccnum7nz297ecyhmd5ph526pxndww0rqq0qly84l635mec0x4yedf95hzn6kcgq8yxts26k98j9g32kjc8y83fe").unwrap().unwrap();
let CoinProtocol::ZHTLC(protocol_info) = serde_json::from_value::<CoinProtocol>(conf["protocol"].take()).unwrap() else { unimplemented!() };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer panicking here instead of unimplemented to have a clear message of the reason for panic, please change this in all tests that have unimplemented

let protocol_info = match serde_json::from_value::<CoinProtocol>(conf["protocol"].take()).unwrap() {
        CoinProtocol::ZHTLC(protocol_info) => protocol_info,
        other_protocol => panic!("Wrong protocol in coin conf {:?}", other_protocol),
    };

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

@shamardy shamardy Apr 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this panic
https://github.com/KomodoPlatform/atomicDEX-API/blob/2340ad8c2d574f183cfb5f06444e19a6cde7a19b/mm2src/coins/z_coin/z_coin_native_tests.rs#L25
No need to mention zombie_conf since this can happen if a dev editing this test used another conf by mistake, it's also a wrong protocol not a failure to get protocol.
Again not a blocker :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

shamardy
shamardy previously approved these changes Apr 24, 2023
Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

shamardy
shamardy previously approved these changes Apr 24, 2023
Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approve

@rozhkovdmitrii rozhkovdmitrii force-pushed the 1745-clippy-all-features branch 3 times, most recently from 14ecd3d to 919fba6 Compare April 24, 2023 14:16
Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work :) This roughly LGTM. I have one suggestion and question:

mm2src/coins/z_coin.rs Show resolved Hide resolved
mm2src/mm2_main/tests/mm2_tests/mod.rs Show resolved Hide resolved
laruh
laruh previously approved these changes Apr 25, 2023
Copy link
Member

@laruh laruh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the fixes.

I have some notes for the future.
Currently module z_coin_native_tests doesnt work, bcz all other tests were moved to .path/mm2_main/tests/ where we keep our test modules. So I couldn't check if the z_coin_native_tests module works.
As for z_coin_tests module, I updated check point blocks for zhtlc coin configs like arrr and zombie and the tests started successfully. However only activation tests passed successfully, the rest failed with errors like not enough balance or there were no transactions in the history. It can be fixed later.
Screenshot from 2023-04-25 17-43-27

@laruh
Copy link
Member

laruh commented Apr 25, 2023

@rozhkovdmitrii
I was told that pirate.dragonhound.info:10032 and http://pirate.dragonhound.info:443 dont work anymore, could you make changes in what we have here for pirate urls.
electrum_servers should be node1.chainkeeper.pro:10132 and light_wallet_d_servers should be http://node1.chainkeeper.pro:443 like here

@rozhkovdmitrii
Copy link
Author

@rozhkovdmitrii I was told that pirate.dragonhound.info:10032 and http://pirate.dragonhound.info:443 dont work anymore, could you make changes in what we have here for pirate urls. electrum_servers should be node1.chainkeeper.pro:10132 and light_wallet_d_servers should be http://node1.chainkeeper.pro:443 like here

done

onur-ozkan
onur-ozkan previously approved these changes Apr 25, 2023
Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for this enhancement!

can you add an entry to the changelog regarding to this clippy fixes for all features flag? @rozhkovdmitrii

@rozhkovdmitrii
Copy link
Author

thank you for this enhancement!

can you add an entry to the changelog regarding to this clippy fixes for all features flag? @rozhkovdmitrii

Thank you, @ozkanonur, done

@onur-ozkan onur-ozkan merged commit ef82cb7 into dev Apr 26, 2023
19 of 20 checks passed
@onur-ozkan onur-ozkan deleted the 1745-clippy-all-features branch April 26, 2023 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Running clippy with --all-features results in a set of warnings
5 participants