-
Notifications
You must be signed in to change notification settings - Fork 94
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
Conversation
// dummy test helping IDE to recognize this as test module | ||
#[test] | ||
fn dummy() { assert!(true) } | ||
fn dummy() {} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 shouldn't we use the |
There was a problem hiding this 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 :)
Yeah thank you, I lost during solving conflicts |
There was a problem hiding this 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
let priv_key = [1; 32]; | ||
let mut conf = zombie_conf(); | ||
let params = default_zcoin_activation_params(); | ||
let priv_key = PrivKeyBuildPolicy::IguanaPrivKey(IguanaPrivKey::default()); |
There was a problem hiding this comment.
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,
¶ms,
- 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();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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!() }; |
There was a problem hiding this comment.
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),
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-approve
1717207
to
1b0cd3a
Compare
14ecd3d
to
919fba6
Compare
There was a problem hiding this 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:
There was a problem hiding this 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.
919fba6
to
c1c48dd
Compare
83dd62f
to
92dc9d3
Compare
@rozhkovdmitrii |
done |
There was a problem hiding this 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
d61f2e9
to
d106978
Compare
Thank you, @ozkanonur, done |
No description provided.