Skip to content

Commit

Permalink
Changed clippy invokation in cargo make for tests, fixed tests clippy…
Browse files Browse the repository at this point in the history
… issues
  • Loading branch information
mrLSD committed Nov 23, 2022
1 parent 3b4da21 commit 85c469c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 28 deletions.
16 changes: 15 additions & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -79,6 +92,7 @@ category = "Check"
dependencies = [
"check-fmt",
"clippy",
"clippy-tests",
]

[tasks.post-contract-build-env]
Expand Down Expand Up @@ -160,7 +174,7 @@ category = "Test"
command = "${CARGO}"
args = [
"test",
"test_migration",
# "test_migration",
"--features",
"${CARGO_FEATURES_TEST}",
"--",
Expand Down
50 changes: 25 additions & 25 deletions eth-connector-tests/src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -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!(
Expand All @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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();
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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
);
Expand All @@ -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
);
Expand Down Expand Up @@ -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
);
Expand Down
4 changes: 2 additions & 2 deletions eth-connector-tests/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 85c469c

Please sign in to comment.