diff --git a/Makefile.toml b/Makefile.toml index 482d978..00c8b68 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -65,6 +65,19 @@ args = [ "warnings", ] +[tasks.clippy-tests] +category = "Check" +command = "${CARGO}" +args = [ + "clippy", + "--all-features", + "--tests", + "--", + "-D", + "warnings", +] + + [tasks.check-fmt] category = "Check" command = "${CARGO}" @@ -79,6 +92,7 @@ category = "Check" dependencies = [ "check-fmt", "clippy", + "clippy-tests", ] [tasks.post-contract-build-env] @@ -160,7 +174,7 @@ category = "Test" command = "${CARGO}" args = [ "test", - "test_migration", + # "test_migration", "--features", "${CARGO_FEATURES_TEST}", "--", diff --git a/eth-connector-tests/src/connector.rs b/eth-connector-tests/src/connector.rs index 0033ee8..5bd2d97 100644 --- a/eth-connector-tests/src/connector.rs +++ b/eth-connector-tests/src/connector.rs @@ -41,7 +41,7 @@ async fn test_ft_transfer() -> anyhow::Result<()> { ); assert_eq!( contract - .get_eth_on_near_balance(&contract.contract.id()) + .get_eth_on_near_balance(contract.contract.id()) .await? .0, DEPOSITED_FEE - transfer_amount as u128 @@ -85,12 +85,12 @@ async fn test_ft_transfer_user() -> anyhow::Result<()> { assert!(res.is_success()); assert_eq!( - contract.get_eth_on_near_balance(&user_acc.id()).await?.0, + contract.get_eth_on_near_balance(user_acc.id()).await?.0, DEPOSITED_AMOUNT - DEPOSITED_FEE - transfer_amount as u128 ); assert_eq!( contract - .get_eth_on_near_balance(&contract.contract.id()) + .get_eth_on_near_balance(contract.contract.id()) .await? .0, DEPOSITED_FEE + transfer_amount as u128 @@ -128,7 +128,7 @@ async fn test_withdraw_eth_from_near() -> anyhow::Result<()> { assert_eq!(data.eth_custodian_address, custodian_addr); let balance = contract - .get_eth_on_near_balance(&contract.contract.id()) + .get_eth_on_near_balance(contract.contract.id()) .await?; assert_eq!(balance.0, DEPOSITED_FEE - withdraw_amount.as_u128()); @@ -176,13 +176,13 @@ async fn test_withdraw_eth_from_near_user() -> anyhow::Result<()> { assert_eq!( contract - .get_eth_on_near_balance(&contract.contract.id()) + .get_eth_on_near_balance(contract.contract.id()) .await? .0, DEPOSITED_FEE ); assert_eq!( - contract.get_eth_on_near_balance(&user_acc.id()).await?.0, + contract.get_eth_on_near_balance(user_acc.id()).await?.0, DEPOSITED_AMOUNT - DEPOSITED_FEE - withdraw_amount.as_u128() ); assert_eq!( @@ -206,7 +206,7 @@ async fn test_deposit_eth_to_near_balance_total_supply() -> anyhow::Result<()> { assert_eq!(balance.0, DEPOSITED_AMOUNT - DEPOSITED_FEE); let balance = contract - .get_eth_on_near_balance(&contract.contract.id()) + .get_eth_on_near_balance(contract.contract.id()) .await?; assert_eq!(balance.0, DEPOSITED_FEE); @@ -248,7 +248,7 @@ async fn test_ft_transfer_call_eth() -> anyhow::Result<()> { assert_eq!(balance.0, DEPOSITED_AMOUNT - DEPOSITED_FEE); let balance = contract - .get_eth_on_near_balance(&contract.contract.id()) + .get_eth_on_near_balance(contract.contract.id()) .await?; assert_eq!(balance.0, DEPOSITED_FEE); @@ -278,7 +278,7 @@ async fn test_ft_transfer_call_eth() -> anyhow::Result<()> { assert_eq!(balance.0, DEPOSITED_AMOUNT - DEPOSITED_FEE); let balance = contract - .get_eth_on_near_balance(&contract.contract.id()) + .get_eth_on_near_balance(contract.contract.id()) .await?; assert_eq!(balance.0, DEPOSITED_FEE); @@ -301,7 +301,7 @@ async fn test_ft_transfer_call_without_message() -> anyhow::Result<()> { assert_eq!(balance.0, DEPOSITED_AMOUNT - DEPOSITED_FEE); let balance = contract - .get_eth_on_near_balance(&contract.contract.id()) + .get_eth_on_near_balance(contract.contract.id()) .await?; assert_eq!(balance.0, DEPOSITED_FEE); @@ -324,7 +324,7 @@ async fn test_ft_transfer_call_without_message() -> anyhow::Result<()> { let balance = contract.get_eth_on_near_balance(&receiver_id).await?; assert_eq!(balance.0, DEPOSITED_AMOUNT - DEPOSITED_FEE); let balance = contract - .get_eth_on_near_balance(&contract.contract.id()) + .get_eth_on_near_balance(contract.contract.id()) .await?; assert_eq!(balance.0, DEPOSITED_FEE); @@ -346,7 +346,7 @@ async fn test_ft_transfer_call_without_message() -> anyhow::Result<()> { let balance = contract.get_eth_on_near_balance(&some_acc).await?; assert_eq!(balance.0, 0); let balance = contract - .get_eth_on_near_balance(&contract.contract.id()) + .get_eth_on_near_balance(contract.contract.id()) .await?; assert_eq!(balance.0, DEPOSITED_FEE); @@ -363,7 +363,7 @@ async fn test_ft_transfer_call_without_message() -> anyhow::Result<()> { async fn test_deposit_with_0x_prefix() -> anyhow::Result<()> { let contract = TestContract::new().await?; - let eth_custodian_address: Address = Address::decode(&CUSTODIAN_ADDRESS.to_string()).unwrap(); + let eth_custodian_address: Address = Address::decode(CUSTODIAN_ADDRESS).unwrap(); let recipient_address = Address::from_array([10u8; 20]); let deposit_amount = 17; let recipient_address_encoded = recipient_address.encode(); @@ -415,7 +415,7 @@ async fn test_deposit_with_0x_prefix() -> anyhow::Result<()> { assert!(res.is_success()); let balance = contract - .get_eth_on_near_balance(&contract.contract.id()) + .get_eth_on_near_balance(contract.contract.id()) .await?; assert_eq!(balance.0, deposit_amount); @@ -472,7 +472,7 @@ async fn test_ft_transfer_call_without_relayer() -> anyhow::Result<()> { assert_eq!(balance.0, DEPOSITED_AMOUNT - DEPOSITED_FEE); let balance = contract - .get_eth_on_near_balance(&contract.contract.id()) + .get_eth_on_near_balance(contract.contract.id()) .await?; assert_eq!(balance.0, DEPOSITED_FEE); @@ -502,7 +502,7 @@ async fn test_ft_transfer_call_without_relayer() -> anyhow::Result<()> { assert_eq!(balance.0, DEPOSITED_AMOUNT - DEPOSITED_FEE); let balance = contract - .get_eth_on_near_balance(&contract.contract.id()) + .get_eth_on_near_balance(contract.contract.id()) .await?; assert_eq!(balance.0, DEPOSITED_FEE); @@ -547,7 +547,7 @@ async fn test_ft_transfer_call_fee_greater_than_amount() -> anyhow::Result<()> { assert_eq!(balance.0, DEPOSITED_AMOUNT - DEPOSITED_FEE); let balance = contract - .get_eth_on_near_balance(&contract.contract.id()) + .get_eth_on_near_balance(contract.contract.id()) .await?; assert_eq!(balance.0, DEPOSITED_FEE); @@ -863,7 +863,7 @@ async fn test_get_accounts_counter_and_transfer() -> anyhow::Result<()> { ); let balance = contract - .get_eth_on_near_balance(&contract.contract.id()) + .get_eth_on_near_balance(contract.contract.id()) .await?; assert_eq!(balance.0, DEPOSITED_FEE - transfer_amount as u128); @@ -905,7 +905,7 @@ async fn test_deposit_to_near_with_zero_fee() -> anyhow::Result<()> { assert_eq!(balance.0, deposited_amount); let balance = contract - .get_eth_on_near_balance(&contract.contract.id()) + .get_eth_on_near_balance(contract.contract.id()) .await?; assert_eq!(balance.0, 0); @@ -1126,12 +1126,12 @@ async fn test_access_rights() -> anyhow::Result<()> { assert_eq!( DEPOSITED_AMOUNT - DEPOSITED_FEE + transfer_amount1.0, - contract.get_eth_on_near_balance(&user_acc.id()).await?.0 + contract.get_eth_on_near_balance(user_acc.id()).await?.0 ); assert_eq!( DEPOSITED_FEE - transfer_amount1.0, contract - .get_eth_on_near_balance(&contract.contract.id()) + .get_eth_on_near_balance(contract.contract.id()) .await? .0 ); @@ -1149,12 +1149,12 @@ async fn test_access_rights() -> anyhow::Result<()> { assert_eq!( DEPOSITED_AMOUNT - DEPOSITED_FEE + transfer_amount1.0, - contract.get_eth_on_near_balance(&user_acc.id()).await?.0 + contract.get_eth_on_near_balance(user_acc.id()).await?.0 ); assert_eq!( DEPOSITED_FEE - transfer_amount1.0, contract - .get_eth_on_near_balance(&contract.contract.id()) + .get_eth_on_near_balance(contract.contract.id()) .await? .0 ); @@ -1189,12 +1189,12 @@ async fn test_access_rights() -> anyhow::Result<()> { assert_eq!( DEPOSITED_AMOUNT - DEPOSITED_FEE + transfer_amount1.0 - transfer_amount2.0, - contract.get_eth_on_near_balance(&user_acc.id()).await?.0 + contract.get_eth_on_near_balance(user_acc.id()).await?.0 ); assert_eq!( DEPOSITED_FEE - transfer_amount1.0, contract - .get_eth_on_near_balance(&contract.contract.id()) + .get_eth_on_near_balance(contract.contract.id()) .await? .0 ); diff --git a/eth-connector-tests/src/migration.rs b/eth-connector-tests/src/migration.rs index 1035bd0..f2dbc24 100644 --- a/eth-connector-tests/src/migration.rs +++ b/eth-connector-tests/src/migration.rs @@ -122,7 +122,7 @@ async fn test_migration_state() -> anyhow::Result<()> { for (i, (account, amount)) in data.accounts.iter().enumerate() { let account = AccountId::try_from(account.to_string()).unwrap(); let amount = NEP141Wei::new(amount.as_u128()); - accounts.insert(account.clone(), amount.clone()); + accounts.insert(account.clone(), amount); if accounts.len() < limit && i < data.accounts.len() - 1 { continue; } @@ -248,7 +248,7 @@ async fn test_migration_state() -> anyhow::Result<()> { for (i, (account, amount)) in data.accounts.iter().enumerate() { let account = AccountId::try_from(account.to_string()).unwrap(); let amount = NEP141Wei::new(amount.as_u128()); - accounts.insert(account.clone(), amount.clone()); + accounts.insert(account, amount); if accounts.len() < limit && i < data.accounts.len() - 1 { continue; }