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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/fmt-and-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ jobs:
rustup toolchain install nightly-2022-10-29 --no-self-update --profile=minimal --component rustfmt clippy
rustup default nightly-2022-10-29

- name: Install OS dependencies
run: |
sudo apt-get update
sudo apt-get -y install libudev-dev
if: matrix.os == 'ubuntu-latest'

- name: fmt check
run: cargo fmt -- --check

- name: x86-64 code lint
run: cargo clippy --all-targets -- --D warnings
run: cargo clippy --all-targets --all-features -- --D warnings

wasm-lint:
timeout-minutes: 45
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- An issue was fixed where we don't have to wait for all EVM nodes to sync the latest account nonce [#1757](https://github.com/KomodoPlatform/atomicDEX-API/pull/1757)
- optimized dev and release compilation profiles and removed ci [#1759](https://github.com/KomodoPlatform/atomicDEX-API/pull/1759)
- fix receiver trade fee for cosmos swaps [#1767](https://github.com/KomodoPlatform/atomicDEX-API/pull/1767)
- All features were enabled to be checked under x86-64 code lint CI step with `--all-features` option [#1760](https://github.com/KomodoPlatform/atomicDEX-API/pull/1760)


## v1.0.2-beta - 2023-04-11
Expand Down
6 changes: 3 additions & 3 deletions mm2src/coins/solana.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ pub mod solana_common;
mod solana_decode_tx_helpers;
pub mod spl;

mod solana_common_tests;
mod solana_tests;
mod spl_tests;
#[cfg(test)] mod solana_common_tests;
#[cfg(test)] mod solana_tests;
#[cfg(test)] mod spl_tests;

pub const SOLANA_DEFAULT_DECIMALS: u64 = 9;
pub const LAMPORTS_DUMMY_AMOUNT: u64 = 10;
Expand Down
8 changes: 3 additions & 5 deletions mm2src/coins/solana/solana_common_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ pub fn generate_key_pair_from_seed(seed: String) -> Keypair {
.unwrap()
.derive(&derivation_path)
.unwrap();
let ref priv_key = ext.secret_key;
let pub_key = ext.public_key();
let pair = ed25519_dalek::Keypair {
secret: ext.secret_key,
Expand All @@ -59,16 +58,15 @@ pub fn spl_coin_for_test(
decimals: u8,
token_contract_address: Pubkey,
) -> SplToken {
let spl_coin = SplToken {
SplToken {
conf: Arc::new(SplTokenFields {
decimals,
ticker,
token_contract_address,
abortable_system: AbortableQueue::default(),
}),
platform_coin: solana_coin,
};
spl_coin
}
}

pub fn solana_coin_for_test(seed: String, net_type: SolanaNet) -> (MmArc, SolanaCoin) {
Expand All @@ -81,7 +79,7 @@ pub fn solana_coin_for_test(seed: String, net_type: SolanaNet) -> (MmArc, Solana
{"coin":"SOL","name":"solana","protocol":{"type":"SOL"},"rpcport":80,"mm2":1}
]
});
let ctx = MmCtxBuilder::new().with_conf(conf.clone()).into_mm_arc();
let ctx = MmCtxBuilder::new().with_conf(conf).into_mm_arc();
let (ticker, decimals) = ("SOL".to_string(), 8);
let key_pair = generate_key_pair_from_iguana_seed(seed);
let my_address = key_pair.pubkey().to_string();
Expand Down
39 changes: 19 additions & 20 deletions mm2src/coins/solana/solana_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fn solana_prerequisites() {
#[cfg(not(target_arch = "wasm32"))]
fn solana_coin_creation() {
let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase.clone(), SolanaNet::Testnet);
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet);
assert_eq!(
sol_coin.my_address().unwrap(),
"FJktmyjV9aBHEShT4hfnLpr9ELywdwVtEL1w1rSWgbVf"
Expand All @@ -86,7 +86,7 @@ fn solana_coin_creation() {
#[cfg(not(target_arch = "wasm32"))]
fn solana_my_balance() {
let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase.clone(), SolanaNet::Testnet);
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet);
let res = block_on(sol_coin.my_balance().compat()).unwrap();
assert_ne!(res.spendable, BigDecimal::from(0));
}
Expand All @@ -95,7 +95,7 @@ fn solana_my_balance() {
#[cfg(not(target_arch = "wasm32"))]
fn solana_block_height() {
let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase.clone(), SolanaNet::Testnet);
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet);
let res = block_on(sol_coin.current_block().compat()).unwrap();
println!("block is : {}", res);
assert!(res > 0);
Expand All @@ -105,29 +105,28 @@ fn solana_block_height() {
#[cfg(not(target_arch = "wasm32"))]
fn solana_validate_address() {
let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase.clone(), SolanaNet::Testnet);
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet);

// invalid len
let res = sol_coin.validate_address("invalidaddressobviously");
assert_eq!(res.is_valid, false);

assert!(!res.is_valid);
let res = sol_coin.validate_address("GMtMFbuVgjDnzsBd3LLBfM4X8RyYcDGCM92tPq2PG6B2");
assert_eq!(res.is_valid, true);
assert!(res.is_valid);

// Typo
let res = sol_coin.validate_address("Fr8fraJXAe1cFU81mF7NhHTrUzXjZAJkQE1gUQ11riH");
assert_eq!(res.is_valid, false);
assert!(!res.is_valid);

// invalid len
let res = sol_coin.validate_address("r8fraJXAe1cFU81mF7NhHTrUzXjZAJkQE1gUQ11riHn");
assert_eq!(res.is_valid, false);
assert!(!res.is_valid);
}

#[test]
#[cfg(not(target_arch = "wasm32"))]
fn test_sign_message() {
let passphrase = "spice describe gravity federal blast come thank unfair canal monkey style afraid".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase.clone(), SolanaNet::Testnet);
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet);
let signature = sol_coin.sign_message("test").unwrap();
assert_eq!(
signature,
Expand All @@ -139,7 +138,7 @@ fn test_sign_message() {
#[cfg(not(target_arch = "wasm32"))]
fn test_verify_message() {
let passphrase = "spice describe gravity federal blast come thank unfair canal monkey style afraid".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase.clone(), SolanaNet::Testnet);
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet);
let is_valid = sol_coin
.verify_message(
"4dzKwEteN8nch76zPMEjPX19RsaQwGTxsbtfg2bwGTkGenLfrdm31zvn9GH5rvaJBwivp6ESXx1KYR672ngs3UfF",
Expand All @@ -154,7 +153,7 @@ fn test_verify_message() {
#[cfg(not(target_arch = "wasm32"))]
fn solana_transaction_simulations() {
let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase.clone(), SolanaNet::Devnet);
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Devnet);
let request_amount = BigDecimal::try_from(0.0001).unwrap();
let valid_tx_details = block_on(
sol_coin
Expand Down Expand Up @@ -183,7 +182,7 @@ fn solana_transaction_simulations() {
#[cfg(not(target_arch = "wasm32"))]
fn solana_transaction_zero_balance() {
let passphrase = "fake passphrase".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase.clone(), SolanaNet::Devnet);
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Devnet);
let invalid_tx_details = block_on(
sol_coin
.withdraw(WithdrawRequest {
Expand All @@ -204,15 +203,15 @@ fn solana_transaction_zero_balance() {
WithdrawError::NotSufficientBalance { required, .. } => {
assert_eq!(required, sol_required);
},
e @ _ => panic!("Unexpected err {:?}", e),
e => panic!("Unexpected err {:?}", e),
};
}

#[test]
#[cfg(not(target_arch = "wasm32"))]
fn solana_transaction_simulations_not_enough_for_fees() {
let passphrase = "non existent passphrase".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase.clone(), SolanaNet::Devnet);
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Devnet);
let invalid_tx_details = block_on(
sol_coin
.withdraw(WithdrawRequest {
Expand All @@ -238,15 +237,15 @@ fn solana_transaction_simulations_not_enough_for_fees() {
assert_eq!(available, 0.into());
assert_eq!(required, sol_required);
},
e @ _ => panic!("Unexpected err {:?}", e),
e => panic!("Unexpected err {:?}", e),
};
}

#[test]
#[cfg(not(target_arch = "wasm32"))]
fn solana_transaction_simulations_max() {
let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase.clone(), SolanaNet::Devnet);
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Devnet);
let valid_tx_details = block_on(
sol_coin
.withdraw(WithdrawRequest {
Expand Down Expand Up @@ -275,7 +274,7 @@ fn solana_transaction_simulations_max() {
#[cfg(not(target_arch = "wasm32"))]
fn solana_test_transactions() {
let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase.clone(), SolanaNet::Devnet);
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Devnet);
let valid_tx_details = block_on(
sol_coin
.withdraw(WithdrawRequest {
Expand All @@ -295,7 +294,7 @@ fn solana_test_transactions() {
let tx_str = hex::encode(&*valid_tx_details.tx_hex.0);
let res = block_on(sol_coin.send_raw_tx(&tx_str).compat()).unwrap();

let res2 = block_on(sol_coin.send_raw_tx_bytes(&*valid_tx_details.tx_hex.0).compat()).unwrap();
let res2 = block_on(sol_coin.send_raw_tx_bytes(&valid_tx_details.tx_hex.0).compat()).unwrap();
assert_eq!(res, res2);

//println!("{:?}", res);
Expand All @@ -307,7 +306,7 @@ fn solana_test_transactions() {
#[cfg(not(target_arch = "wasm32"))]
fn solana_test_tx_history() {
let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase.clone(), SolanaNet::Testnet);
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet);
let res = sol_coin
.client
.get_signatures_for_address(&sol_coin.key_pair.pubkey())
Expand Down
22 changes: 11 additions & 11 deletions mm2src/coins/solana/spl_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use std::str::FromStr;
#[cfg(not(target_arch = "wasm32"))]
fn spl_coin_creation() {
let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase.clone(), SolanaNet::Testnet);
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet);
let sol_spl_usdc_coin = spl_coin_for_test(
sol_coin.clone(),
sol_coin,
"USDC".to_string(),
6,
solana_sdk::pubkey::Pubkey::from_str("CpMah17kQEL2wqyMKt3mZBdTnZbkbfx4nqmQMFDP5vwp").unwrap(),
Expand All @@ -28,9 +28,9 @@ fn spl_coin_creation() {
#[cfg(not(target_arch = "wasm32"))]
fn test_sign_message() {
let passphrase = "spice describe gravity federal blast come thank unfair canal monkey style afraid".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase.clone(), SolanaNet::Testnet);
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet);
let sol_spl_usdc_coin = spl_coin_for_test(
sol_coin.clone(),
sol_coin,
"USDC".to_string(),
6,
solana_sdk::pubkey::Pubkey::from_str("CpMah17kQEL2wqyMKt3mZBdTnZbkbfx4nqmQMFDP5vwp").unwrap(),
Expand All @@ -46,9 +46,9 @@ fn test_sign_message() {
#[cfg(not(target_arch = "wasm32"))]
fn test_verify_message() {
let passphrase = "spice describe gravity federal blast come thank unfair canal monkey style afraid".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase.clone(), SolanaNet::Testnet);
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet);
let sol_spl_usdc_coin = spl_coin_for_test(
sol_coin.clone(),
sol_coin,
"USDC".to_string(),
6,
solana_sdk::pubkey::Pubkey::from_str("CpMah17kQEL2wqyMKt3mZBdTnZbkbfx4nqmQMFDP5vwp").unwrap(),
Expand All @@ -67,7 +67,7 @@ fn test_verify_message() {
#[cfg(not(target_arch = "wasm32"))]
fn spl_my_balance() {
let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase.clone(), SolanaNet::Testnet);
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet);
let sol_spl_usdc_coin = spl_coin_for_test(
sol_coin.clone(),
"USDC".to_string(),
Expand All @@ -80,7 +80,7 @@ fn spl_my_balance() {
assert!(res.spendable < BigDecimal::from(10));

let sol_spl_wsol_coin = spl_coin_for_test(
sol_coin.clone(),
sol_coin,
"WSOL".to_string(),
8,
solana_sdk::pubkey::Pubkey::from_str("So11111111111111111111111111111111111111112").unwrap(),
Expand All @@ -95,9 +95,9 @@ fn spl_my_balance() {
#[cfg(not(target_arch = "wasm32"))]
fn test_spl_transactions() {
let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase.clone(), SolanaNet::Testnet);
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet);
let usdc_sol_coin = spl_coin_for_test(
sol_coin.clone(),
sol_coin,
"USDC".to_string(),
6,
solana_sdk::pubkey::Pubkey::from_str("CpMah17kQEL2wqyMKt3mZBdTnZbkbfx4nqmQMFDP5vwp").unwrap(),
Expand Down Expand Up @@ -127,6 +127,6 @@ fn test_spl_transactions() {
let res = block_on(usdc_sol_coin.send_raw_tx(&tx_str).compat()).unwrap();
println!("{:?}", res);

let res2 = block_on(usdc_sol_coin.send_raw_tx_bytes(&*valid_tx_details.tx_hex.0).compat()).unwrap();
let res2 = block_on(usdc_sol_coin.send_raw_tx_bytes(&valid_tx_details.tx_hex.0).compat()).unwrap();
assert_eq!(res, res2);
}
5 changes: 5 additions & 0 deletions mm2src/coins/z_coin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ impl ZCoin {
#[inline]
pub fn consensus_params_ref(&self) -> &ZcoinConsensusParams { &self.z_fields.consensus_params }

#[inline]
pub async fn is_sapling_state_synced(&self) -> bool {
onur-ozkan marked this conversation as resolved.
Show resolved Hide resolved
matches!(self.sync_status().await, Ok(SyncStatus::Finished { block_number: _ }))
}

#[inline]
pub async fn sync_status(&self) -> Result<SyncStatus, MmError<BlockchainScanStopped>> {
self.z_fields
Expand Down
Loading