From a14486d9b263de64c82e83e73586453a57d23858 Mon Sep 17 00:00:00 2001 From: kaimen-sano Date: Sun, 7 Jan 2024 00:15:55 +1300 Subject: [PATCH] style: lint on all targets This lets us run clippy on our test suite and other targets. --- .github/workflows/ci-test-fmt-check.yaml | 2 +- .../fee_collector/src/tests/integration.rs | 168 +++++++-------- .../fee_distributor/src/tests/epoch.rs | 6 +- .../fee_distributor/src/tests/robot.rs | 2 +- .../fee_distributor/src/tests/testing.rs | 8 +- .../frontend_helper/src/testing.rs | 4 +- .../incentive/src/tests/integration.rs | 192 ++++++++---------- .../incentive/src/tests/mock_instantiate.rs | 2 +- .../pool-network/incentive/src/tests/mod.rs | 2 +- .../pool-network/incentive/src/tests/suite.rs | 50 ++--- .../src/stableswap_math/curve.rs | 18 +- .../src/tests/protocol_fees.rs | 4 +- .../src/tests/provide_liquidity.rs | 8 +- .../stableswap_3pool/src/tests/swap.rs | 4 +- .../stableswap_3pool/src/tests/testing.rs | 32 +-- .../stableswap_3pool/src/tests/withdrawals.rs | 2 +- .../terraswap_pair/src/tests/protocol_fees.rs | 4 +- .../src/tests/provide_liquidity.rs | 4 +- .../terraswap_pair/src/tests/swap.rs | 6 +- .../terraswap_pair/src/tests/testing.rs | 36 ++-- .../terraswap_pair/src/tests/withdrawals.rs | 2 +- .../vault_factory/src/contract.rs | 18 +- .../whale_lair/src/tests/instantiate.rs | 6 +- .../whale_lair/src/tests/robot.rs | 10 +- 24 files changed, 281 insertions(+), 309 deletions(-) diff --git a/.github/workflows/ci-test-fmt-check.yaml b/.github/workflows/ci-test-fmt-check.yaml index 590ff9b8..6e0b8c97 100644 --- a/.github/workflows/ci-test-fmt-check.yaml +++ b/.github/workflows/ci-test-fmt-check.yaml @@ -59,7 +59,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: clippy - args: --locked -- -D warnings + args: --locked --all-targets -- -D warnings #- name: Run cosmwasm linter # run: cargo dylint cw_lint --workspace diff --git a/contracts/liquidity_hub/fee_collector/src/tests/integration.rs b/contracts/liquidity_hub/fee_collector/src/tests/integration.rs index bb981213..cb089a59 100644 --- a/contracts/liquidity_hub/fee_collector/src/tests/integration.rs +++ b/contracts/liquidity_hub/fee_collector/src/tests/integration.rs @@ -305,7 +305,7 @@ fn collect_all_factories_cw20_fees_successfully() { AssetInfo::NativeToken { .. } => panic!("no native tokens in this test"), }; // fees are collected in the token opposite of the one you swap - asset_addr.to_string() != cw20_tokens[i as usize] + *asset_addr != cw20_tokens[i as usize] }) .unwrap(); @@ -333,7 +333,7 @@ fn collect_all_factories_cw20_fees_successfully() { AssetInfo::NativeToken { .. } => panic!("no native tokens in this test"), }; // fees are collected in the token opposite of the one you swap - asset_addr.to_string() != cw20_tokens[i as usize] + *asset_addr != cw20_tokens[i as usize] }) .unwrap(); @@ -367,7 +367,7 @@ fn collect_all_factories_cw20_fees_successfully() { factory_addr: pool_factory_address.to_string(), factory_type: FactoryType::Pool { start_after: None, - limit: Some(u32::try_from(TOKEN_AMOUNT).unwrap()), + limit: Some(u32::from(TOKEN_AMOUNT)), }, }, }, @@ -389,12 +389,12 @@ fn collect_all_factories_cw20_fees_successfully() { fee_distributor_id, creator.clone().sender, &white_whale::fee_distributor::InstantiateMsg { - bonding_contract_addr: "whale_lair".clone().to_string(), + bonding_contract_addr: "whale_lair".to_string(), fee_collector_addr: fee_collector_address.clone().to_string(), grace_period: Uint64::new(1), epoch_config: EpochConfig { duration: Uint64::new(86_400_000_000_000u64), // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }, distribution_asset: ask_asset.clone(), }, @@ -500,7 +500,7 @@ fn collect_all_factories_cw20_fees_successfully() { factory_addr: pool_factory_address.to_string(), factory_type: FactoryType::Pool { start_after: None, - limit: Some(u32::try_from(TOKEN_AMOUNT).unwrap()), + limit: Some(u32::from(TOKEN_AMOUNT)), }, }, }, @@ -798,7 +798,7 @@ fn collect_cw20_fees_for_specific_contracts_successfully() { AssetInfo::NativeToken { .. } => panic!("no native tokens in this test"), }; // fees are collected in the token opposite of the one you swap - asset_addr.to_string() != cw20_tokens[i] + *asset_addr != cw20_tokens[i] }) .unwrap(); @@ -826,7 +826,7 @@ fn collect_cw20_fees_for_specific_contracts_successfully() { AssetInfo::NativeToken { .. } => panic!("no native tokens in this test"), }; // fees are collected in the token opposite of the one you swap - asset_addr.to_string() != cw20_tokens[i] + *asset_addr != cw20_tokens[i] }) .unwrap(); @@ -1329,12 +1329,12 @@ fn collect_pools_native_fees_successfully() { fee_distributor_id, creator.clone().sender, &white_whale::fee_distributor::InstantiateMsg { - bonding_contract_addr: "whale_lair".clone().to_string(), + bonding_contract_addr: "whale_lair".to_string(), fee_collector_addr: fee_collector_address.clone().to_string(), grace_period: Uint64::new(1), epoch_config: EpochConfig { duration: Uint64::new(86_400_000_000_000u64), // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }, distribution_asset: ask_asset.clone(), }, @@ -1512,7 +1512,7 @@ fn collect_pools_native_fees_successfully() { factory_addr: pool_factory_address.to_string(), factory_type: FactoryType::Pool { start_after: None, - limit: Some(u32::try_from(TOKEN_AMOUNT).unwrap()), + limit: Some(u32::from(TOKEN_AMOUNT)), }, }, }, @@ -2252,12 +2252,12 @@ fn aggregate_fees_for_vault() { fee_distributor_id, creator.clone().sender, &white_whale::fee_distributor::InstantiateMsg { - bonding_contract_addr: "whale_lair".clone().to_string(), + bonding_contract_addr: "whale_lair".to_string(), fee_collector_addr: fee_collector_address.clone().to_string(), grace_period: Uint64::new(1), epoch_config: EpochConfig { duration: Uint64::new(86_400_000_000_000u64), // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }, distribution_asset: AssetInfo::NativeToken { denom: "uatom".to_string(), @@ -2959,7 +2959,7 @@ fn collect_and_distribute_fees_successfully() { grace_period: Uint64::new(2), epoch_config: EpochConfig { duration: Uint64::new(86_400_000_000_000u64), // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }, distribution_asset: AssetInfo::NativeToken { denom: "uwhale".to_string(), @@ -3071,7 +3071,7 @@ fn collect_and_distribute_fees_successfully() { denom: "uwhale".to_string(), }, AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, ], pool_fees: PoolFee { @@ -3121,7 +3121,7 @@ fn collect_and_distribute_fees_successfully() { }, Asset { info: AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, amount: Uint128::new(500_000u128), }, @@ -3135,7 +3135,7 @@ fn collect_and_distribute_fees_successfully() { amount: Uint128::new(500_000u128), }, Coin { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), amount: Uint128::new(500_000u128), }, ], @@ -3174,7 +3174,7 @@ fn collect_and_distribute_fees_successfully() { &pool_network::pair::ExecuteMsg::Swap { offer_asset: Asset { info: AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, amount: Uint128::new(200_000u128), }, @@ -3183,7 +3183,7 @@ fn collect_and_distribute_fees_successfully() { to: None, }, &[Coin { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), amount: Uint128::new(200_000u128), }], ) @@ -3202,7 +3202,7 @@ fn collect_and_distribute_fees_successfully() { assert_eq!(fee_distributor_current_epoch_query.epoch, Epoch::default()); app.set_block(BlockInfo { - time: Timestamp::from_nanos(1678802400_000000000u64), + time: Timestamp::from_nanos(1_678_802_400_000_000_000_u64), ..app.block_info() }); @@ -3352,7 +3352,7 @@ fn collect_and_dist_fees_where_one_bonder_is_increasing_weight_no_claims_until_e grace_period: Uint64::new(1), epoch_config: EpochConfig { duration: Uint64::new(86_400_000_000_000u64), // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }, distribution_asset: AssetInfo::NativeToken { denom: "uwhale".to_string(), @@ -3464,7 +3464,7 @@ fn collect_and_dist_fees_where_one_bonder_is_increasing_weight_no_claims_until_e denom: "uwhale".to_string(), }, AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, ], pool_fees: PoolFee { @@ -3514,7 +3514,7 @@ fn collect_and_dist_fees_where_one_bonder_is_increasing_weight_no_claims_until_e }, Asset { info: AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, amount: Uint128::new(500_000u128), }, @@ -3528,7 +3528,7 @@ fn collect_and_dist_fees_where_one_bonder_is_increasing_weight_no_claims_until_e amount: Uint128::new(500_000u128), }, Coin { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), amount: Uint128::new(500_000u128), }, ], @@ -3575,7 +3575,7 @@ fn collect_and_dist_fees_where_one_bonder_is_increasing_weight_no_claims_until_e // Get weight of both users and store as a vec for now let mut weights: Vec = Vec::new(); - for user in vec![creator.sender.clone(), Addr::unchecked("other")] { + for user in [creator.sender.clone(), Addr::unchecked("other")] { let weight: BondingWeightResponse = app .wrap() .query_wasm_smart( @@ -3618,7 +3618,7 @@ fn collect_and_dist_fees_where_one_bonder_is_increasing_weight_no_claims_until_e // advance the time to one day after the first epoch was created app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678888800_000000000u64), + time: Timestamp::from_nanos(1_678_888_800_000_000_000_u64), chain_id: "".to_string(), }); @@ -3667,7 +3667,7 @@ fn collect_and_dist_fees_where_one_bonder_is_increasing_weight_no_claims_until_e }] ); - for user in vec![creator.sender.clone(), Addr::unchecked("other")] { + for user in [creator.sender.clone(), Addr::unchecked("other")] { let weight: BondingWeightResponse = app .wrap() .query_wasm_smart( @@ -3725,7 +3725,7 @@ fn collect_and_dist_fees_where_one_bonder_is_increasing_weight_no_claims_until_e // advance the time to one day after the first epoch was created app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678888800_000000000u64), + time: Timestamp::from_nanos(1_678_888_800_000_000_000_u64), chain_id: "".to_string(), }); @@ -3919,7 +3919,7 @@ fn collect_and_dist_fees_where_one_bonder_is_increasing_weight_no_claims_until_e // advance the time to one day after the second epoch was created app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678888800_000000000u64 + 86400_000000000u64), + time: Timestamp::from_nanos(1_678_888_800_000_000_000_u64 + 86400_000000000u64), chain_id: "".to_string(), }); @@ -4031,7 +4031,7 @@ fn collect_and_dist_fees_where_one_bonder_is_increasing_weight_no_claims_until_e // Advance time one more time app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678888800_000000000u64 + (86400_000000000u64 * 2u64)), + time: Timestamp::from_nanos(1_678_888_800_000_000_000_u64 + (86400_000000000u64 * 2u64)), chain_id: "".to_string(), }); @@ -4295,7 +4295,7 @@ fn collect_and_distribute_fees_with_expiring_epoch_successfully() { grace_period: Uint64::new(1), epoch_config: EpochConfig { duration: Uint64::new(86_400_000_000_000u64), // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }, distribution_asset: AssetInfo::NativeToken { denom: "uwhale".to_string(), @@ -4406,7 +4406,7 @@ fn collect_and_distribute_fees_with_expiring_epoch_successfully() { denom: "uwhale".to_string(), }, AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, ], pool_fees: PoolFee { @@ -4456,7 +4456,7 @@ fn collect_and_distribute_fees_with_expiring_epoch_successfully() { }, Asset { info: AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, amount: Uint128::new(500_000u128), }, @@ -4470,7 +4470,7 @@ fn collect_and_distribute_fees_with_expiring_epoch_successfully() { amount: Uint128::new(500_000u128), }, Coin { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), amount: Uint128::new(500_000u128), }, ], @@ -4542,7 +4542,7 @@ fn collect_and_distribute_fees_with_expiring_epoch_successfully() { // advance the time to one day after the first epoch was created app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678888800_000000000u64), + time: Timestamp::from_nanos(1_678_888_800_000_000_000_u64), chain_id: "".to_string(), }); @@ -4596,7 +4596,7 @@ fn collect_and_distribute_fees_with_expiring_epoch_successfully() { // advance the time to one day after the first epoch was created app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678888800_000000000u64), + time: Timestamp::from_nanos(1_678_888_800_000_000_000_u64), chain_id: "".to_string(), }); @@ -4856,7 +4856,7 @@ fn collect_distribute_with_unbonders() { grace_period: Uint64::new(1), epoch_config: EpochConfig { duration: Uint64::new(86_400_000_000_000u64), // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }, distribution_asset: AssetInfo::NativeToken { denom: "uwhale".to_string(), @@ -4968,7 +4968,7 @@ fn collect_distribute_with_unbonders() { denom: "uwhale".to_string(), }, AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, ], pool_fees: PoolFee { @@ -5018,7 +5018,7 @@ fn collect_distribute_with_unbonders() { }, Asset { info: AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, amount: Uint128::new(500_000u128), }, @@ -5032,7 +5032,7 @@ fn collect_distribute_with_unbonders() { amount: Uint128::new(500_000u128), }, Coin { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), amount: Uint128::new(500_000u128), }, ], @@ -5105,7 +5105,7 @@ fn collect_distribute_with_unbonders() { // advance the time to one day after the first epoch was created app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678888800_000000000u64), + time: Timestamp::from_nanos(1_678_888_800_000_000_000_u64), chain_id: "".to_string(), }); @@ -5202,7 +5202,7 @@ fn collect_distribute_with_unbonders() { // advance the time to one day after the first epoch was created app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678888800_000000000u64), + time: Timestamp::from_nanos(1_678_888_800_000_000_000_u64), chain_id: "".to_string(), }); @@ -5358,7 +5358,7 @@ fn collect_distribute_with_unbonders() { // advance the time to one day after the second epoch was created app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(3357777600_000000000u64), + time: Timestamp::from_nanos(3_357_777_600_000_000_000_u64), chain_id: "".to_string(), }); @@ -5596,7 +5596,7 @@ fn create_epoch_unsuccessfully() { grace_period: Uint64::new(1), epoch_config: EpochConfig { duration: Uint64::new(86_400_000_000_000u64), // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }, distribution_asset: AssetInfo::NativeToken { denom: "uwhale".to_string(), @@ -5694,7 +5694,7 @@ fn create_epoch_unsuccessfully() { denom: "uwhale".to_string(), }, AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, ], pool_fees: PoolFee { @@ -5744,7 +5744,7 @@ fn create_epoch_unsuccessfully() { }, Asset { info: AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, amount: Uint128::new(500_000u128), }, @@ -5758,7 +5758,7 @@ fn create_epoch_unsuccessfully() { amount: Uint128::new(500_000u128), }, Coin { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), amount: Uint128::new(500_000u128), }, ], @@ -5792,7 +5792,7 @@ fn create_epoch_unsuccessfully() { app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678802400_000000000u64), + time: Timestamp::from_nanos(1_678_802_400_000_000_000_u64), chain_id: "".to_string(), }); @@ -5808,7 +5808,7 @@ fn create_epoch_unsuccessfully() { // advance some time, but not enough to create a new epoch app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678802500_000000000u64), //less than a day + time: Timestamp::from_nanos(1_678_802_500_000_000_000_u64), //less than a day chain_id: "".to_string(), }); @@ -6076,7 +6076,7 @@ fn decrease_grace_period_fee_distributor() { grace_period: Uint64::new(2), epoch_config: EpochConfig { duration: Uint64::new(86_400_000_000_000u64), // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }, distribution_asset: AssetInfo::NativeToken { denom: "uwhale".to_string(), @@ -6174,7 +6174,7 @@ fn decrease_grace_period_fee_distributor() { denom: "uwhale".to_string(), }, AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, ], pool_fees: PoolFee { @@ -6224,7 +6224,7 @@ fn decrease_grace_period_fee_distributor() { }, Asset { info: AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, amount: Uint128::new(500_000u128), }, @@ -6238,7 +6238,7 @@ fn decrease_grace_period_fee_distributor() { amount: Uint128::new(500_000u128), }, Coin { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), amount: Uint128::new(500_000u128), }, ], @@ -6273,7 +6273,7 @@ fn decrease_grace_period_fee_distributor() { // advance the time to one day after the first epoch was created app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678888800_000000000u64), + time: Timestamp::from_nanos(1_678_888_800_000_000_000_u64), chain_id: "".to_string(), }); @@ -6312,7 +6312,7 @@ fn decrease_grace_period_fee_distributor() { // advance the time to one day after the first epoch was created app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678888800_000000000u64), + time: Timestamp::from_nanos(1_678_888_800_000_000_000_u64), chain_id: "".to_string(), }); @@ -6473,7 +6473,7 @@ fn users_cannot_claim_rewards_from_past_epochs() { grace_period: Uint64::new(3u64), epoch_config: EpochConfig { duration: Uint64::new(86_400_000_000_000u64), // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }, distribution_asset: AssetInfo::NativeToken { denom: "uwhale".to_string(), @@ -6584,7 +6584,7 @@ fn users_cannot_claim_rewards_from_past_epochs() { denom: "uwhale".to_string(), }, AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, ], pool_fees: PoolFee { @@ -6634,7 +6634,7 @@ fn users_cannot_claim_rewards_from_past_epochs() { }, Asset { info: AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, amount: Uint128::new(500_000u128), }, @@ -6648,7 +6648,7 @@ fn users_cannot_claim_rewards_from_past_epochs() { amount: Uint128::new(500_000u128), }, Coin { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), amount: Uint128::new(500_000u128), }, ], @@ -6702,7 +6702,7 @@ fn users_cannot_claim_rewards_from_past_epochs() { // advance the time to one day after the first epoch was created app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678888800_000000000u64), + time: Timestamp::from_nanos(1_678_888_800_000_000_000_u64), chain_id: "".to_string(), }); @@ -6755,7 +6755,7 @@ fn users_cannot_claim_rewards_from_past_epochs() { // advance the time to one day after the first epoch was created app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678888800_000000000u64), + time: Timestamp::from_nanos(1_678_888_800_000_000_000_u64), chain_id: "".to_string(), }); @@ -6837,7 +6837,7 @@ fn users_cannot_claim_rewards_from_past_epochs() { // advance the time to one day after the first epoch was created app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678978800_000000000u64), + time: Timestamp::from_nanos(1_678_978_800_000_000_000_u64), chain_id: "".to_string(), }); @@ -7015,7 +7015,7 @@ fn user_can_claim_even_when_his_weight_increases_for_past_epochs() { grace_period: Uint64::new(3u64), epoch_config: EpochConfig { duration: Uint64::new(86_400_000_000_000u64), // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }, distribution_asset: AssetInfo::NativeToken { denom: "uwhale".to_string(), @@ -7126,7 +7126,7 @@ fn user_can_claim_even_when_his_weight_increases_for_past_epochs() { denom: "uwhale".to_string(), }, AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, ], pool_fees: PoolFee { @@ -7176,7 +7176,7 @@ fn user_can_claim_even_when_his_weight_increases_for_past_epochs() { }, Asset { info: AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, amount: Uint128::new(500_000u128), }, @@ -7190,7 +7190,7 @@ fn user_can_claim_even_when_his_weight_increases_for_past_epochs() { amount: Uint128::new(500_000u128), }, Coin { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), amount: Uint128::new(500_000u128), }, ], @@ -7262,7 +7262,7 @@ fn user_can_claim_even_when_his_weight_increases_for_past_epochs() { // advance the time to one day after the first epoch was created app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678888800_000000000u64), + time: Timestamp::from_nanos(1_678_888_800_000_000_000_u64), chain_id: "".to_string(), }); @@ -7315,7 +7315,7 @@ fn user_can_claim_even_when_his_weight_increases_for_past_epochs() { // advance the time to one day after the first epoch was created app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678888800_000000000u64), + time: Timestamp::from_nanos(1_678_888_800_000_000_000_u64), chain_id: "".to_string(), }); @@ -7462,7 +7462,7 @@ fn user_can_claim_even_when_his_weight_increases_for_past_epochs() { app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678978800_000000000u64), + time: Timestamp::from_nanos(1_678_978_800_000_000_000_u64), chain_id: "".to_string(), }); @@ -7649,7 +7649,7 @@ fn user_weight_accounts_for_unbondings() { grace_period: Uint64::new(3u64), epoch_config: EpochConfig { duration: Uint64::new(86_400_000_000_000u64), // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }, distribution_asset: AssetInfo::NativeToken { denom: "uwhale".to_string(), @@ -7760,7 +7760,7 @@ fn user_weight_accounts_for_unbondings() { denom: "uwhale".to_string(), }, AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, ], pool_fees: PoolFee { @@ -7810,7 +7810,7 @@ fn user_weight_accounts_for_unbondings() { }, Asset { info: AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, amount: Uint128::new(500_000u128), }, @@ -7824,7 +7824,7 @@ fn user_weight_accounts_for_unbondings() { amount: Uint128::new(500_000u128), }, Coin { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), amount: Uint128::new(500_000u128), }, ], @@ -7916,7 +7916,7 @@ fn user_weight_accounts_for_unbondings() { // advance the time to one day after the first epoch was created app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678888800_000000000u64), + time: Timestamp::from_nanos(1_678_888_800_000_000_000_u64), chain_id: "".to_string(), }); @@ -7969,7 +7969,7 @@ fn user_weight_accounts_for_unbondings() { // advance the time to one day after the first epoch was created app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678888800_000000000u64), + time: Timestamp::from_nanos(1_678_888_800_000_000_000_u64), chain_id: "".to_string(), }); @@ -8117,7 +8117,7 @@ fn user_weight_accounts_for_unbondings() { // advance the time app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678978800_000000000u64), + time: Timestamp::from_nanos(1_678_978_800_000_000_000_u64), chain_id: "".to_string(), }); @@ -8291,7 +8291,7 @@ fn user_weight_accounts_for_unbondings() { // advance the time app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1679065200_000000000u64), + time: Timestamp::from_nanos(1_679_065_200_000_000_000_u64), chain_id: "".to_string(), }); @@ -8481,7 +8481,7 @@ fn users_can_claim_even_when_global_index_was_taken_after_epoch_was_created() { grace_period: Uint64::new(3u64), epoch_config: EpochConfig { duration: Uint64::new(86_400_000_000_000u64), // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }, distribution_asset: AssetInfo::NativeToken { denom: "uwhale".to_string(), @@ -8592,7 +8592,7 @@ fn users_can_claim_even_when_global_index_was_taken_after_epoch_was_created() { denom: "uwhale".to_string(), }, AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, ], pool_fees: PoolFee { @@ -8642,7 +8642,7 @@ fn users_can_claim_even_when_global_index_was_taken_after_epoch_was_created() { }, Asset { info: AssetInfo::NativeToken { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), }, amount: Uint128::new(500_000u128), }, @@ -8656,7 +8656,7 @@ fn users_can_claim_even_when_global_index_was_taken_after_epoch_was_created() { amount: Uint128::new(500_000u128), }, Coin { - denom: native_token.clone().to_string(), + denom: native_token.to_string(), amount: Uint128::new(500_000u128), }, ], @@ -8667,7 +8667,7 @@ fn users_can_claim_even_when_global_index_was_taken_after_epoch_was_created() { // // "enable" bonding on 10 March 2023 15:00:00 app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678460400_000000000u64), + time: Timestamp::from_nanos(1_678_460_400_000_000_000_u64), chain_id: "".to_string(), }); @@ -8717,7 +8717,7 @@ fn users_can_claim_even_when_global_index_was_taken_after_epoch_was_created() { // advance the time until the point when the first epoch was created app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678888800_000000000u64), + time: Timestamp::from_nanos(1_678_888_800_000_000_000_u64), chain_id: "".to_string(), }); @@ -8776,7 +8776,7 @@ fn users_can_claim_even_when_global_index_was_taken_after_epoch_was_created() { // advance just a bit more after the new epoch can be created app.set_block(BlockInfo { height: 123456789u64, - time: Timestamp::from_nanos(1678888900_000000000u64), + time: Timestamp::from_nanos(1_678_888_900_000_000_000_u64), chain_id: "".to_string(), }); diff --git a/contracts/liquidity_hub/fee_distributor/src/tests/epoch.rs b/contracts/liquidity_hub/fee_distributor/src/tests/epoch.rs index ff847b43..e9feadde 100644 --- a/contracts/liquidity_hub/fee_distributor/src/tests/epoch.rs +++ b/contracts/liquidity_hub/fee_distributor/src/tests/epoch.rs @@ -43,10 +43,10 @@ fn test_create_genesis_epoch() { }; let epoch_config = EpochConfig { duration: Uint64::new(86_400_000_000_000u64), // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }; - robot.env.block.time = Timestamp::from_nanos(1678802300_000000000u64); // before genesis epoch + robot.env.block.time = Timestamp::from_nanos(1_678_802_300_000_000_000_u64); // before genesis epoch robot .instantiate( @@ -63,7 +63,7 @@ fn test_create_genesis_epoch() { }); // set the time at genesis epoch - robot.env.block.time = Timestamp::from_nanos(1678802400_000000000u64); // before genesis epoch + robot.env.block.time = Timestamp::from_nanos(1_678_802_400_000_000_000_u64); // before genesis epoch robot.create_new_epoch(mock_info("owner", &[]), |res| { // all good now diff --git a/contracts/liquidity_hub/fee_distributor/src/tests/robot.rs b/contracts/liquidity_hub/fee_distributor/src/tests/robot.rs index c3432b4c..56fb2fde 100644 --- a/contracts/liquidity_hub/fee_distributor/src/tests/robot.rs +++ b/contracts/liquidity_hub/fee_distributor/src/tests/robot.rs @@ -34,7 +34,7 @@ impl TestingRobot { grace_period: Uint64::new(2), epoch_config: EpochConfig { duration: Uint64::new(86_400_000_000_000u64), // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }, distribution_asset: AssetInfo::NativeToken { denom: "uwhale".to_string(), diff --git a/contracts/liquidity_hub/fee_distributor/src/tests/testing.rs b/contracts/liquidity_hub/fee_distributor/src/tests/testing.rs index 7764e816..5defe2c8 100644 --- a/contracts/liquidity_hub/fee_distributor/src/tests/testing.rs +++ b/contracts/liquidity_hub/fee_distributor/src/tests/testing.rs @@ -17,7 +17,7 @@ fn instantiate_successfully() { }; let epoch_config = EpochConfig { duration: Uint64::new(86_400_000_000_000u64), // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }; robot @@ -48,7 +48,7 @@ fn instantiate_unsuccessfully() { }; let epoch_config = EpochConfig { duration: Uint64::new(86_400_000_000_000u64), // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }; robot.instantiate_err( @@ -78,7 +78,7 @@ fn instantiate_unsuccessfully() { Uint64::one(), EpochConfig { duration: invalid_epoch_duration, // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }, distribution_asset.clone(), ); @@ -95,7 +95,7 @@ fn test_update_config() { grace_period: Uint64::new(3), epoch_config: EpochConfig { duration: Uint64::new(86_400_000_000_000u64), // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }, distribution_asset: AssetInfo::NativeToken { denom: "uwhale".to_string(), diff --git a/contracts/liquidity_hub/pool-network/frontend_helper/src/testing.rs b/contracts/liquidity_hub/pool-network/frontend_helper/src/testing.rs index d9cfb155..be3a69f2 100644 --- a/contracts/liquidity_hub/pool-network/frontend_helper/src/testing.rs +++ b/contracts/liquidity_hub/pool-network/frontend_helper/src/testing.rs @@ -236,7 +236,7 @@ mod tests { incentive_factory_addr: Some("new_factory".to_string()), owner: Some("new_owner".to_string()), }, - &vec![], + &[], ); let err = result.unwrap_err().downcast::().unwrap(); @@ -253,7 +253,7 @@ mod tests { incentive_factory_addr: Some("new_factory".to_string()), owner: Some("new_owner".to_string()), }, - &vec![], + &[], ) .unwrap(); diff --git a/contracts/liquidity_hub/pool-network/incentive/src/tests/integration.rs b/contracts/liquidity_hub/pool-network/incentive/src/tests/integration.rs index 6e2aa1aa..e6b201b7 100644 --- a/contracts/liquidity_hub/pool-network/incentive/src/tests/integration.rs +++ b/contracts/liquidity_hub/pool-network/incentive/src/tests/integration.rs @@ -288,7 +288,7 @@ fn try_open_more_flows_than_allowed() { amount: Uint128::new(i * 2_000u128), }, None, - &vec![coin(i * 2_000u128, "uwhale".to_string())], + &[coin(i * 2_000u128, "uwhale".to_string())], |result| { if i > 7 { // this should fail as only 7 incentives can be opened as specified in `instantiate_default` @@ -401,16 +401,16 @@ fn try_open_flows_with_wrong_epochs() { alice.clone(), incentive_addr.clone().into_inner(), None, - Some(past_epoch.clone()), + Some(past_epoch), Some(Curve::Linear), Asset { info: AssetInfo::NativeToken { - denom: "uwhale".clone().to_string(), + denom: "uwhale".to_string(), }, amount: Uint128::new(2_000u128), }, None, - &vec![coin(2_000u128, "uwhale".to_string())], + &[coin(2_000u128, "uwhale".to_string())], |result| { let err = result.unwrap_err().downcast::().unwrap(); @@ -425,17 +425,17 @@ fn try_open_flows_with_wrong_epochs() { .open_incentive_flow( alice.clone(), incentive_addr.clone().into_inner(), - Some(future_future_epoch.clone()), - Some(future_epoch.clone()), + Some(future_future_epoch), + Some(future_epoch), Some(Curve::Linear), Asset { info: AssetInfo::NativeToken { - denom: "uwhale".clone().to_string(), + denom: "uwhale".to_string(), }, amount: Uint128::new(2_000u128), }, None, - &vec![coin(2_000u128, "uwhale".to_string())], + &[coin(2_000u128, "uwhale".to_string())], |result| { let err = result.unwrap_err().downcast::().unwrap(); @@ -457,12 +457,12 @@ fn try_open_flows_with_wrong_epochs() { Some(Curve::Linear), Asset { info: AssetInfo::NativeToken { - denom: "uwhale".clone().to_string(), + denom: "uwhale".to_string(), }, amount: Uint128::new(2_000u128), }, None, - &vec![coin(2_000u128, "uwhale".to_string())], + &[coin(2_000u128, "uwhale".to_string())], |result| { let err = result.unwrap_err().downcast::().unwrap(); @@ -476,16 +476,16 @@ fn try_open_flows_with_wrong_epochs() { alice.clone(), incentive_addr.clone().into_inner(), None, - Some(future_epoch.clone()), + Some(future_epoch), Some(Curve::Linear), Asset { info: AssetInfo::NativeToken { - denom: "uwhale".clone().to_string(), + denom: "uwhale".to_string(), }, amount: Uint128::new(2_000u128), }, None, - &vec![coin(2_000u128, "uwhale".to_string())], + &[coin(2_000u128, "uwhale".to_string())], |result| { result.unwrap(); }, @@ -536,12 +536,12 @@ fn open_flow_with_fee_native_token_and_flow_same_native_token() { Some(Curve::Linear), Asset { info: AssetInfo::NativeToken { - denom: "uwhale".clone().to_string(), + denom: "uwhale".to_string(), }, amount: Uint128::new(0u128), }, None, - &vec![coin(1_000u128, "uwhale".to_string())], + &[coin(1_000u128, "uwhale".to_string())], |result| { // this should fail as not enough funds were sent let err = result.unwrap_err().downcast::().unwrap(); @@ -560,12 +560,12 @@ fn open_flow_with_fee_native_token_and_flow_same_native_token() { Some(Curve::Linear), Asset { info: AssetInfo::NativeToken { - denom: "uwhale".clone().to_string(), + denom: "uwhale".to_string(), }, amount: Uint128::new(1_000u128), }, None, - &vec![coin(1_000u128, "uwhale".to_string())], + &[coin(1_000u128, "uwhale".to_string())], |result| { // this should fail as not enough funds were sent to cover for fee + MIN_FLOW_AMOUNT let err = result.unwrap_err().downcast::().unwrap(); @@ -583,12 +583,12 @@ fn open_flow_with_fee_native_token_and_flow_same_native_token() { Some(Curve::Linear), Asset { info: AssetInfo::NativeToken { - denom: "uwhale".clone().to_string(), + denom: "uwhale".to_string(), }, amount: Uint128::new(1_000u128), }, None, - &vec![coin(100u128, "uwhale".to_string())], + &[coin(100u128, "uwhale".to_string())], |result| { // this should fail as not enough funds were sent to cover for fee + MIN_FLOW_AMOUNT let err = result.unwrap_err().downcast::().unwrap(); @@ -606,12 +606,12 @@ fn open_flow_with_fee_native_token_and_flow_same_native_token() { Some(Curve::Linear), Asset { info: AssetInfo::NativeToken { - denom: "uwhale".clone().to_string(), + denom: "uwhale".to_string(), }, amount: Uint128::new(2_000u128), }, None, - &vec![coin(500u128, "uwhale".to_string())], + &[coin(500u128, "uwhale".to_string())], |result| { // this should fail as we didn't send enough funds to cover for the fee let err = result.unwrap_err().downcast::().unwrap(); @@ -629,12 +629,12 @@ fn open_flow_with_fee_native_token_and_flow_same_native_token() { Some(Curve::Linear), Asset { info: AssetInfo::NativeToken { - denom: "uwhale".clone().to_string(), + denom: "uwhale".to_string(), }, amount: Uint128::new(2_000u128), }, None, - &vec![coin(2_000u128, "uwhale".to_string())], + &[coin(2_000u128, "uwhale".to_string())], |result| { // this should succeed as we sent enough funds to cover for fee + MIN_FLOW_AMOUNT result.unwrap(); @@ -747,12 +747,12 @@ fn open_flow_with_fee_native_token_and_flow_different_native_token() { Some(Curve::Linear), Asset { info: AssetInfo::NativeToken { - denom: "ampWHALE".clone().to_string(), + denom: "ampWHALE".to_string(), }, amount: Uint128::new(500u128), }, None, - &vec![coin(1_000u128, "uwhale".to_string())], + &[coin(1_000u128, "uwhale".to_string())], |result| { // this should fail as MIN_FLOW_AMOUNT is not met let err = result.unwrap_err().downcast::().unwrap(); @@ -771,12 +771,12 @@ fn open_flow_with_fee_native_token_and_flow_different_native_token() { Some(Curve::Linear), Asset { info: AssetInfo::NativeToken { - denom: "ampWHALE".clone().to_string(), + denom: "ampWHALE".to_string(), }, amount: Uint128::new(1_000u128), }, None, - &vec![coin(1_000u128, "uwhale".to_string())], + &[coin(1_000u128, "uwhale".to_string())], |result| { // this should fail as the flow asset was not sent let err = result.unwrap_err().downcast::().unwrap(); @@ -794,15 +794,13 @@ fn open_flow_with_fee_native_token_and_flow_different_native_token() { Some(Curve::Linear), Asset { info: AssetInfo::NativeToken { - denom: "ampWHALE".clone().to_string(), + denom: "ampWHALE".to_string(), }, amount: Uint128::new(1_000u128), }, None, - &vec![ - coin(1_000u128, "uwhale".to_string()), - coin(500u128, "ampWHALE".to_string()), - ], + &[coin(1_000u128, "uwhale".to_string()), + coin(500u128, "ampWHALE".to_string())], |result| { // this should fail as the flow asset amount doesn't match the one sent to the contract let err = result.unwrap_err().downcast::().unwrap(); @@ -820,15 +818,13 @@ fn open_flow_with_fee_native_token_and_flow_different_native_token() { Some(Curve::Linear), Asset { info: AssetInfo::NativeToken { - denom: "ampWHALE".clone().to_string(), + denom: "ampWHALE".to_string(), }, amount: Uint128::new(1_000u128), }, None, - &vec![ - coin(100u128, "uwhale".to_string()), - coin(1_00u128, "ampWHALE".to_string()), - ], + &[coin(100u128, "uwhale".to_string()), + coin(1_00u128, "ampWHALE".to_string())], |result| { // this should fail as not enough funds were sent to cover for fee let err = result.unwrap_err().downcast::().unwrap(); @@ -846,15 +842,13 @@ fn open_flow_with_fee_native_token_and_flow_different_native_token() { Some(Curve::Linear), Asset { info: AssetInfo::NativeToken { - denom: "ampWHALE".clone().to_string(), + denom: "ampWHALE".to_string(), }, amount: Uint128::new(1_000u128), }, None, - &vec![ - coin(1_000u128, "uwhale".to_string()), - coin(1_000u128, "ampWHALE".to_string()), - ], + &[coin(1_000u128, "uwhale".to_string()), + coin(1_000u128, "ampWHALE".to_string())], |result| { // this should succeed as both the fee was paid in full and the flow asset amount // matches the one sent to the contract @@ -943,7 +937,7 @@ fn open_flow_with_fee_native_token_and_flow_different_native_token() { .query_funds( carol.clone(), AssetInfo::NativeToken { - denom: "uwhale".clone().to_string(), + denom: "uwhale".to_string(), }, |result| { *carol_original_uwhale_funds.borrow_mut() = result; @@ -958,15 +952,13 @@ fn open_flow_with_fee_native_token_and_flow_different_native_token() { Some(Curve::Linear), Asset { info: AssetInfo::NativeToken { - denom: "ampWHALE".clone().to_string(), + denom: "ampWHALE".to_string(), }, amount: Uint128::new(1_000u128), }, None, - &vec![ - coin(50_000u128, "uwhale".to_string()), - coin(1_000u128, "ampWHALE".to_string()), - ], + &[coin(50_000u128, "uwhale".to_string()), + coin(1_000u128, "ampWHALE".to_string())], |result| { // this should succeed as we sent enough funds to cover for fee + MIN_FLOW_AMOUNT result.unwrap(); @@ -975,7 +967,7 @@ fn open_flow_with_fee_native_token_and_flow_different_native_token() { .query_funds( carol.clone(), AssetInfo::NativeToken { - denom: "uwhale".clone().to_string(), + denom: "uwhale".to_string(), }, |result| { // the current balance should be the original minus the fee only, which is 1_000uwhale @@ -1040,7 +1032,7 @@ fn open_flow_with_fee_native_token_and_flow_cw20_token() { amount: Uint128::new(500u128), }, None, - &vec![coin(1_000u128, "uwhale".to_string())], + &[coin(1_000u128, "uwhale".to_string())], |result| { // this should fail as MIN_FLOW_AMOUNT is not met let err = result.unwrap_err().downcast::().unwrap(); @@ -1062,7 +1054,7 @@ fn open_flow_with_fee_native_token_and_flow_cw20_token() { amount: Uint128::new(1_000u128), }, None, - &vec![coin(1_000u128, "uwhale".to_string())], + &[coin(1_000u128, "uwhale".to_string())], |result| { // this should fail as the flow asset was not sent, i.e. Allowance was not increased let err = result.unwrap_err().downcast::().unwrap(); @@ -1090,7 +1082,7 @@ fn open_flow_with_fee_native_token_and_flow_cw20_token() { amount: Uint128::new(1_000u128), }, None, - &vec![coin(1_000u128, "uwhale".to_string())], + &[coin(1_000u128, "uwhale".to_string())], |result| { // this should succeed as the allowance was increased result.unwrap(); @@ -1215,7 +1207,7 @@ fn open_flow_with_fee_cw20_token_and_flow_same_cw20_token() { amount: Uint128::new(500u128), }, None, - &vec![], + &[], |result| { // this should fail as not enough funds were sent let err = result.unwrap_err().downcast::().unwrap(); @@ -1237,7 +1229,7 @@ fn open_flow_with_fee_cw20_token_and_flow_same_cw20_token() { amount: Uint128::new(1_000u128), }, None, - &vec![], + &[], |result| { // this should fail as not enough funds were sent to cover for fee let err = result.unwrap_err().downcast::().unwrap(); @@ -1266,7 +1258,7 @@ fn open_flow_with_fee_cw20_token_and_flow_same_cw20_token() { amount: Uint128::new(1_500u128), }, None, - &vec![], + &[], |result| { // this should fail as not enough funds were sent to cover for fee and MIN_FLOW_AMOUNT let err = result.unwrap_err().downcast::().unwrap(); @@ -1294,7 +1286,7 @@ fn open_flow_with_fee_cw20_token_and_flow_same_cw20_token() { amount: Uint128::new(2_000u128), }, None, - &vec![], + &[], |result| { // this should succeed as enough funds were sent to cover for fee and MIN_FLOW_AMOUNT result.unwrap(); @@ -1401,7 +1393,7 @@ fn open_flow_with_fee_cw20_token_and_flow_different_cw20_token() { amount: Uint128::new(500u128), }, None, - &vec![], + &[], |result| { // this should fail as not enough funds were sent let err = result.unwrap_err().downcast::().unwrap(); @@ -1423,7 +1415,7 @@ fn open_flow_with_fee_cw20_token_and_flow_different_cw20_token() { amount: Uint128::new(1_000u128), }, None, - &vec![], + &[], |result| { // this should fail as the asset to pay for the fee was not transferred let err = result.unwrap_err().downcast::().unwrap(); @@ -1452,7 +1444,7 @@ fn open_flow_with_fee_cw20_token_and_flow_different_cw20_token() { amount: Uint128::new(1_000u128), }, None, - &vec![], + &[], |result| { // this should fail as not enough funds were sent to cover for fee let err = result.unwrap_err().downcast::().unwrap(); @@ -1481,7 +1473,7 @@ fn open_flow_with_fee_cw20_token_and_flow_different_cw20_token() { amount: Uint128::new(1_000u128), }, None, - &vec![], + &[], |result| { // this should fail as not enough funds were sent to cover the flow asset let err = result.unwrap_err().downcast::().unwrap(); @@ -1510,7 +1502,7 @@ fn open_flow_with_fee_cw20_token_and_flow_different_cw20_token() { amount: Uint128::new(1_000u128), }, None, - &vec![], + &[], |result| { // this should succeed as both the fee was paid in full and the flow asset amount // matches the one sent to the contract @@ -1638,7 +1630,7 @@ fn open_flow_with_fee_cw20_token_and_flow_native_token() { amount: Uint128::new(500u128), }, None, - &vec![], + &[], |result| { // this should fail as not enough funds were sent let err = result.unwrap_err().downcast::().unwrap(); @@ -1662,7 +1654,7 @@ fn open_flow_with_fee_cw20_token_and_flow_native_token() { amount: Uint128::new(1_000u128), }, None, - &vec![], + &[], |result| { // this should fail as the asset to pay for the fee was not transferred let err = result.unwrap_err().downcast::().unwrap(); @@ -1693,7 +1685,7 @@ fn open_flow_with_fee_cw20_token_and_flow_native_token() { amount: Uint128::new(1_000u128), }, None, - &vec![], + &[], |result| { // this should fail as not enough funds were sent to cover for fee let err = result.unwrap_err().downcast::().unwrap(); @@ -1724,7 +1716,7 @@ fn open_flow_with_fee_cw20_token_and_flow_native_token() { amount: Uint128::new(1_000u128), }, None, - &vec![], + &[], |result| { // this should fail as the flow asset was not sent to the contract let err = result.unwrap_err().downcast::().unwrap(); @@ -1748,7 +1740,7 @@ fn open_flow_with_fee_cw20_token_and_flow_native_token() { amount: Uint128::new(1_000u128), }, None, - &vec![coin(900u128, "usdc".to_string())], + &[coin(900u128, "usdc".to_string())], |result| { // this should fail as the flow asset was not sent to the contract let err = result.unwrap_err().downcast::().unwrap(); @@ -1772,7 +1764,7 @@ fn open_flow_with_fee_cw20_token_and_flow_native_token() { amount: Uint128::new(1_000u128), }, None, - &vec![coin(1_000u128, "usdc".to_string())], + &[coin(1_000u128, "usdc".to_string())], |result| { // this should succeed as the flow asset was sent to the contract result.unwrap(); @@ -1900,12 +1892,12 @@ fn close_native_token_flows() { Some(Curve::Linear), Asset { info: AssetInfo::NativeToken { - denom: "uwhale".clone().to_string(), + denom: "uwhale".to_string(), }, amount: Uint128::new(2_000u128), }, None, - &vec![coin(2_000u128, "uwhale".to_string())], + &[coin(2_000u128, "uwhale".to_string())], |result| { result.unwrap(); }, @@ -1918,12 +1910,12 @@ fn close_native_token_flows() { Some(Curve::Linear), Asset { info: AssetInfo::NativeToken { - denom: "uwhale".clone().to_string(), + denom: "uwhale".to_string(), }, amount: Uint128::new(11_000u128), }, None, - &vec![coin(11_000u128, "uwhale".to_string())], + &[coin(11_000u128, "uwhale".to_string())], |result| { result.unwrap(); }, @@ -2122,12 +2114,12 @@ fn close_native_token_flows() { Some(Curve::Linear), Asset { info: AssetInfo::NativeToken { - denom: "uwhale".clone().to_string(), + denom: "uwhale".to_string(), }, amount: Uint128::new(5_000u128), }, None, - &vec![coin(5_000u128, "uwhale".to_string())], + &[coin(5_000u128, "uwhale".to_string())], |result| { result.unwrap(); }, @@ -2217,7 +2209,7 @@ fn close_cw20_token_flows() { amount: Uint128::new(1_000u128), }, None, - &vec![coin(1_000u128, "uwhale".to_string())], + &[coin(1_000u128, "uwhale".to_string())], |result| { result.unwrap(); }, @@ -2239,7 +2231,7 @@ fn close_cw20_token_flows() { amount: Uint128::new(10_000u128), }, None, - &vec![coin(1_000u128, "uwhale".to_string())], + &[coin(1_000u128, "uwhale".to_string())], |result| { result.unwrap(); }, @@ -2417,7 +2409,7 @@ fn close_cw20_token_flows() { amount: Uint128::new(5_000u128), }, None, - &vec![coin(1_000u128, "uwhale".to_string())], + &[coin(1_000u128, "uwhale".to_string())], |result| { result.unwrap(); }, @@ -2694,7 +2686,7 @@ fn open_flow_positions_and_claim_native_token_incentive() { amount: Uint128::new(1_000_000_000u128), }, None, - &vec![coin(1_000_000_000u128, "usdc"), coin(1_000u128, "uwhale")], + &[coin(1_000_000_000u128, "usdc"), coin(1_000u128, "uwhale")], |result| { result.unwrap(); }, @@ -3103,7 +3095,7 @@ fn open_flow_positions_claim_cw20_token_incentive() { amount: Uint128::new(1_000_000_000u128), }, None, - &vec![coin(1_000u128, "uwhale")], + &[coin(1_000u128, "uwhale")], |result| { result.unwrap(); }, @@ -3325,10 +3317,8 @@ fn open_expand_close_flows_positions_and_claim_native_token_incentive() { amount: Uint128::new(1_000_000_000u128), }, None, - &vec![ - coin(1_000_000_000u128, "ampWHALE"), - coin(1_000u128, "uwhale"), - ], + &[coin(1_000_000_000u128, "ampWHALE"), + coin(1_000u128, "uwhale")], |result| { result.unwrap(); }, @@ -3344,7 +3334,7 @@ fn open_expand_close_flows_positions_and_claim_native_token_incentive() { amount: Uint128::new(10_000_000_000u128), }, None, - &vec![coin(10_000_000_000u128, "usdc"), coin(1_000u128, "uwhale")], + &[coin(10_000_000_000u128, "usdc"), coin(1_000u128, "uwhale")], |result| { result.unwrap(); }, @@ -3860,8 +3850,8 @@ fn open_expand_close_flows_positions_and_claim_native_token_incentive() { .expand_incentive_position( alice.clone(), incentive_addr.clone().into_inner(), - alice_position_1.amount.clone(), - alice_position_1.unbonding_duration.clone() + 4, + alice_position_1.amount, + alice_position_1.unbonding_duration + 4, None, vec![], |result| { @@ -3879,8 +3869,8 @@ fn open_expand_close_flows_positions_and_claim_native_token_incentive() { .expand_incentive_position( alice.clone(), incentive_addr.clone().into_inner(), - alice_position_1.amount.clone(), - alice_position_1.unbonding_duration.clone(), + alice_position_1.amount, + alice_position_1.unbonding_duration, None, vec![], |result| { @@ -4152,8 +4142,8 @@ fn open_expand_close_flows_positions_and_claim_native_token_incentive() { .open_incentive_position( bob.clone(), incentive_addr.clone().into_inner(), - bob_position_2.amount.clone(), - bob_position_2.unbonding_duration.clone(), + bob_position_2.amount, + bob_position_2.unbonding_duration, None, vec![], |result| { @@ -4233,7 +4223,7 @@ fn open_expand_close_flows_positions_and_claim_native_token_incentive() { .flow_asset .amount; let claimed = flow_response.clone().unwrap().flow.unwrap().claimed_amount; - let expected_claimed = total_rewards.clone(); + let expected_claimed = total_rewards; assert!(total_rewards > claimed); assert!(expected_claimed >= claimed); @@ -4391,10 +4381,8 @@ fn open_expand_position_with_optional_receiver() { amount: Uint128::new(1_000_000_000u128), }, None, - &vec![ - coin(1_000_000_000u128, "ampWHALE"), - coin(1_000u128, "uwhale"), - ], + &[coin(1_000_000_000u128, "ampWHALE"), + coin(1_000u128, "uwhale")], |result| { result.unwrap(); }, @@ -4534,7 +4522,7 @@ fn close_position_if_empty_rewards() { amount: Uint128::new(1_000u128), }, None, - &vec![coin(1_000u128, "ampWHALE"), coin(1_000u128, "uwhale")], + &[coin(1_000u128, "ampWHALE"), coin(1_000u128, "uwhale")], |result| { result.unwrap(); }, @@ -4879,12 +4867,12 @@ fn open_expand_flow_with_native_token() { Some(Curve::Linear), Asset { info: AssetInfo::NativeToken { - denom: "uwhale".clone().to_string(), + denom: "uwhale".to_string(), }, amount: Uint128::new(2_000u128), }, None, - &vec![coin(2_000u128, "uwhale".to_string())], + &[coin(2_000u128, "uwhale".to_string())], |result| { // this should succeed as we sent enough funds to cover for fee + MIN_FLOW_AMOUNT result.unwrap(); @@ -5187,7 +5175,7 @@ fn open_expand_flow_with_cw20_token() { amount: Uint128::new(2_000u128), }, None, - &vec![coin(1_000u128, "uwhale".to_string())], + &[coin(1_000u128, "uwhale".to_string())], |result| { // this should succeed as we sent enough funds to cover for fee + MIN_FLOW_AMOUNT result.unwrap(); @@ -5455,7 +5443,7 @@ fn fail_expand_ended_flow() { amount: Uint128::new(2_000u128), }, None, - &vec![coin(1_000u128, "uwhale".to_string())], + &[coin(1_000u128, "uwhale".to_string())], |result| { // this should succeed as we sent enough funds to cover for fee + MIN_FLOW_AMOUNT result.unwrap(); @@ -5598,7 +5586,7 @@ fn open_expand_flow_with_default_values() { amount: Uint128::new(1_000_000_000u128), }, Some("alias".to_string()), - &vec![coin(1_000_000_000u128, "usdc"), coin(1_000u128, "uwhale")], + &[coin(1_000_000_000u128, "usdc"), coin(1_000u128, "uwhale")], |result| { result.unwrap(); }, @@ -5961,7 +5949,7 @@ fn open_expand_flow_verify_rewards() { amount: Uint128::new(10_000u128), }, Some("alias".to_string()), - &vec![coin(10_000u128, "usdc"), coin(1_000u128, "uwhale")], + &[coin(10_000u128, "usdc"), coin(1_000u128, "uwhale")], |result| { result.unwrap(); }, @@ -6466,7 +6454,7 @@ fn open_expand_flow_over_expand_limit() { amount: Uint128::new(10_000u128), }, Some("alias".to_string()), - &vec![coin(10_000u128, "usdc"), coin(1_000u128, "uwhale")], + &[coin(10_000u128, "usdc"), coin(1_000u128, "uwhale")], |result| { result.unwrap(); }, diff --git a/contracts/liquidity_hub/pool-network/incentive/src/tests/mock_instantiate.rs b/contracts/liquidity_hub/pool-network/incentive/src/tests/mock_instantiate.rs index 3cc8e797..14bc0f11 100644 --- a/contracts/liquidity_hub/pool-network/incentive/src/tests/mock_instantiate.rs +++ b/contracts/liquidity_hub/pool-network/incentive/src/tests/mock_instantiate.rs @@ -87,7 +87,7 @@ pub fn app_mock_instantiate(app: &mut App, lp_balance: Uint128) -> AppInstantiat grace_period: Uint64::one(), epoch_config: EpochConfig { duration: Uint64::new(86400_000000000u64), - genesis_epoch: Uint64::new(1685458800_000000000u64), + genesis_epoch: Uint64::new(1_685_458_800_000_000_000_u64), }, distribution_asset: AssetInfo::NativeToken { denom: "uwhale".to_string(), diff --git a/contracts/liquidity_hub/pool-network/incentive/src/tests/mod.rs b/contracts/liquidity_hub/pool-network/incentive/src/tests/mod.rs index f662e117..9abf7d12 100644 --- a/contracts/liquidity_hub/pool-network/incentive/src/tests/mod.rs +++ b/contracts/liquidity_hub/pool-network/incentive/src/tests/mod.rs @@ -15,5 +15,5 @@ pub mod store_code; mod suite; mod suite_contracts; -pub use mock_execute::mock_execute; + pub use mock_info::mock_creator; diff --git a/contracts/liquidity_hub/pool-network/incentive/src/tests/suite.rs b/contracts/liquidity_hub/pool-network/incentive/src/tests/suite.rs index 77ef069a..053ccfd7 100644 --- a/contracts/liquidity_hub/pool-network/incentive/src/tests/suite.rs +++ b/contracts/liquidity_hub/pool-network/incentive/src/tests/suite.rs @@ -57,7 +57,7 @@ impl TestingSuite { }; self.app - .execute_contract(sender, cw20contract, &msg, &vec![]) + .execute_contract(sender, cw20contract, &msg, &[]) .unwrap(); self @@ -229,6 +229,7 @@ impl TestingSuite { } #[track_caller] + #[allow(clippy::too_many_arguments)] pub(crate) fn instantiate( &mut self, fee_collector_addr: String, @@ -261,6 +262,7 @@ impl TestingSuite { } #[track_caller] + #[allow(clippy::too_many_arguments)] pub(crate) fn instantiate_err( &mut self, fee_collector_addr: String, @@ -347,16 +349,15 @@ impl TestingSuite { lp_asset: lp_address, }; - result(self.app.execute_contract( - sender, - self.incentive_factory_addr.clone(), - &msg, - &vec![], - )); + result( + self.app + .execute_contract(sender, self.incentive_factory_addr.clone(), &msg, &[]), + ); self } + #[allow(clippy::too_many_arguments)] pub(crate) fn open_incentive_flow( &mut self, sender: Addr, @@ -366,7 +367,7 @@ impl TestingSuite { curve: Option, flow_asset: Asset, flow_label: Option, - funds: &Vec, + funds: &[Coin], result: impl Fn(Result), ) -> &mut Self { let msg = white_whale::pool_network::incentive::ExecuteMsg::OpenFlow { @@ -394,14 +395,12 @@ impl TestingSuite { ) -> &mut Self { let msg = white_whale::pool_network::incentive::ExecuteMsg::CloseFlow { flow_identifier }; - result( - self.app - .execute_contract(sender, incentive_addr, &msg, &vec![]), - ); + result(self.app.execute_contract(sender, incentive_addr, &msg, &[])); self } + #[allow(clippy::too_many_arguments)] pub(crate) fn open_incentive_position( &mut self, sender: Addr, @@ -436,14 +435,12 @@ impl TestingSuite { let msg = white_whale::pool_network::incentive::ExecuteMsg::ClosePosition { unbonding_duration }; - result( - self.app - .execute_contract(sender, incentive_addr, &msg, &vec![]), - ); + result(self.app.execute_contract(sender, incentive_addr, &msg, &[])); self } + #[allow(clippy::too_many_arguments)] pub(crate) fn expand_incentive_position( &mut self, sender: Addr, @@ -476,10 +473,7 @@ impl TestingSuite { ) -> &mut Self { let msg = white_whale::pool_network::incentive::ExecuteMsg::Claim {}; println!("-------------- claiming {}", sender); - result( - self.app - .execute_contract(sender, incentive_addr, &msg, &vec![]), - ); + result(self.app.execute_contract(sender, incentive_addr, &msg, &[])); self } @@ -491,10 +485,7 @@ impl TestingSuite { result: impl Fn(Result), ) -> &mut Self { let msg = white_whale::pool_network::incentive::ExecuteMsg::Withdraw {}; - result( - self.app - .execute_contract(sender, incentive_addr, &msg, &vec![]), - ); + result(self.app.execute_contract(sender, incentive_addr, &msg, &[])); self } @@ -512,7 +503,7 @@ impl TestingSuite { self.senders[0].clone(), self.fee_distributor_addr.clone(), &msg, - &vec![], + &[], ) .unwrap(); @@ -540,7 +531,7 @@ impl TestingSuite { self.senders[0].clone(), self.fee_distributor_addr.clone(), &msg, - &vec![], + &[], ) .unwrap(); } @@ -559,12 +550,13 @@ impl TestingSuite { self.senders[0].clone(), incentive_addr.clone(), &msg, - &vec![], + &[], )); self } + #[allow(clippy::too_many_arguments)] pub(crate) fn expand_flow( &mut self, sender: Addr, @@ -650,7 +642,7 @@ impl TestingSuite { ) -> &mut Self { let global_weight_response: StdResult = self.app.wrap().query_wasm_smart( - &incentive_addr, + incentive_addr, &white_whale::pool_network::incentive::QueryMsg::GlobalWeight { epoch_id }, ); @@ -667,7 +659,7 @@ impl TestingSuite { ) -> &mut Self { let current_epoch_rewards_share: StdResult = self.app.wrap().query_wasm_smart( - &incentive_addr, + incentive_addr, &white_whale::pool_network::incentive::QueryMsg::CurrentEpochRewardsShare { address: address.to_string(), }, diff --git a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/stableswap_math/curve.rs b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/stableswap_math/curve.rs index 97811d70..3aec253e 100644 --- a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/stableswap_math/curve.rs +++ b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/stableswap_math/curve.rs @@ -376,7 +376,7 @@ impl StableSwap { #[cfg(test)] #[allow( clippy::unwrap_used, - clippy::integer_arithmetic, + clippy::arithmetic_side_effects, clippy::too_many_arguments )] mod tests { @@ -634,7 +634,7 @@ mod tests { start_ramp_ts: ZERO_TS, stop_ramp_ts: ZERO_TS }; - let mut t = SwapTest { stable_swap: stable_swap, swap_reserve_balance_a: MAX_TOKENS_IN, swap_reserve_balance_b: MAX_TOKENS_IN, + let mut t = SwapTest { stable_swap, swap_reserve_balance_a: MAX_TOKENS_IN, swap_reserve_balance_b: MAX_TOKENS_IN, swap_reserve_balance_c: MAX_TOKENS_IN, user_token_balance_a: Uint128::new(initial_user_token_a_amount), user_token_balance_b:Uint128::new(initial_user_token_b_amount), @@ -680,7 +680,7 @@ mod tests { }; let mut t = SwapTest { - stable_swap: stable_swap, + stable_swap, swap_reserve_balance_a: INITIAL_SWAP_RESERVE_AMOUNT, swap_reserve_balance_b: INITIAL_SWAP_RESERVE_AMOUNT, swap_reserve_balance_c: INITIAL_SWAP_RESERVE_AMOUNT, @@ -712,7 +712,7 @@ mod tests { }; let mut t = SwapTest { - stable_swap: stable_swap, + stable_swap, swap_reserve_balance_a: INITIAL_SWAP_RESERVE_AMOUNT, swap_reserve_balance_b: INITIAL_SWAP_RESERVE_AMOUNT, swap_reserve_balance_c: INITIAL_SWAP_RESERVE_AMOUNT, @@ -743,7 +743,7 @@ mod tests { }; let mut t = SwapTest { - stable_swap: stable_swap, + stable_swap, swap_reserve_balance_a: INITIAL_SWAP_RESERVE_AMOUNT, swap_reserve_balance_b: INITIAL_SWAP_RESERVE_AMOUNT, swap_reserve_balance_c: INITIAL_SWAP_RESERVE_AMOUNT, @@ -773,14 +773,6 @@ mod tests { swap_token_c_amount in 0..MAX_TOKENS_IN.u128(), pool_token_supply in 0..MAX_TOKENS_IN.u128(), ) { - let deposit_amount_a = deposit_amount_a; - let deposit_amount_b = deposit_amount_b; - let deposit_amount_c = deposit_amount_c; - let swap_token_a_amount = swap_token_a_amount; - let swap_token_b_amount = swap_token_b_amount; - let swap_token_c_amount = swap_token_c_amount; - let pool_token_supply = pool_token_supply; - let start_ramp_ts = cmp::max(0, current_ts - MIN_RAMP_DURATION); let stop_ramp_ts = cmp::min(u64::MAX, current_ts + MIN_RAMP_DURATION); let invariant = StableSwap::new(amp_factor, amp_factor, current_ts, start_ramp_ts, stop_ramp_ts); diff --git a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/protocol_fees.rs b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/protocol_fees.rs index efdfb6d1..2454e2c7 100644 --- a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/protocol_fees.rs +++ b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/protocol_fees.rs @@ -409,7 +409,7 @@ fn test_collect_protocol_fees_successful() { // make sure two messages were sent, one for the native token and one for the cw20 assert_eq!(res.messages.len(), 3); - let transfer_native_token_msg = res.messages.get(0).expect("no message"); + let transfer_native_token_msg = res.messages.first().expect("no message"); let transfer_asset0000_token_msg = res.messages.get(1).expect("no message"); let transfer_asset0001_token_msg = res.messages.get(2).expect("no message"); assert_eq!( @@ -637,7 +637,7 @@ fn test_collect_protocol_fees_successful_1_fee_only() { // make sure one message was sent, as there is only one fee to collect, the other one is zero assert_eq!(res.messages.len(), 1); - let transfer_cw20_token_msg = res.messages.get(0).expect("no message"); + let transfer_cw20_token_msg = res.messages.first().expect("no message"); assert_eq!( transfer_cw20_token_msg, &SubMsg::new(CosmosMsg::Wasm(WasmMsg::Execute { diff --git a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/provide_liquidity.rs b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/provide_liquidity.rs index 3bacf2de..c1fd1980 100644 --- a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/provide_liquidity.rs +++ b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/provide_liquidity.rs @@ -162,7 +162,7 @@ fn provide_liquidity_cw20_lp() { assert_eq!(res.messages.len(), 4usize); - let transfer_from_msg = res.messages.get(0).expect("no message"); + let transfer_from_msg = res.messages.first().expect("no message"); let mint_initial_lp_msg = res.messages.get(2).expect("no message"); let mint_msg = res.messages.get(3).expect("no message"); assert_eq!( @@ -268,7 +268,7 @@ fn provide_liquidity_cw20_lp() { let res: Response = execute(deps.as_mut(), env, info, msg).unwrap(); assert_eq!(res.messages.len(), 3usize); - let transfer_from_msg = res.messages.get(0).expect("no message"); + let transfer_from_msg = res.messages.first().expect("no message"); let mint_msg = res.messages.get(2).expect("no message"); assert_eq!( transfer_from_msg, @@ -870,7 +870,7 @@ fn provide_liquidity_invalid_minimum_lp_amount() { info: AssetInfo::Token { contract_addr: "asset0000".to_string(), }, - amount: Uint128::from(MINIMUM_LIQUIDITY_AMOUNT - Uint128::one()), + amount: (MINIMUM_LIQUIDITY_AMOUNT - Uint128::one()), }, Asset { info: AssetInfo::NativeToken { @@ -882,7 +882,7 @@ fn provide_liquidity_invalid_minimum_lp_amount() { info: AssetInfo::Token { contract_addr: "asset0001".to_string(), }, - amount: Uint128::from(MINIMUM_LIQUIDITY_AMOUNT - Uint128::one()), + amount: (MINIMUM_LIQUIDITY_AMOUNT - Uint128::one()), }, ], slippage_tolerance: None, diff --git a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/swap.rs b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/swap.rs index 69f66581..4fddf1f9 100644 --- a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/swap.rs +++ b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/swap.rs @@ -156,7 +156,7 @@ fn try_native_to_token() { ); let res = execute(deps.as_mut(), env, info, msg).unwrap(); assert_eq!(res.messages.len(), 2); - let msg_transfer = res.messages.get(0).expect("no message"); + let msg_transfer = res.messages.first().expect("no message"); //Expected return on a stable swap should about the same as input, // swap fee will be approximately 1_500_000_000 * 0.003 4_500_000 @@ -641,7 +641,7 @@ fn try_token_to_native() { let res = execute(deps.as_mut(), env, info, msg).unwrap(); assert_eq!(res.messages.len(), 2); - let msg_transfer = res.messages.get(0).expect("no message"); + let msg_transfer = res.messages.first().expect("no message"); let expected_spread_amount = Uint128::new(830_233u128); //Expected return on a stable swap should about the same as input, diff --git a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/testing.rs b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/testing.rs index d70bc0af..4cb83dcd 100644 --- a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/testing.rs +++ b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/testing.rs @@ -497,9 +497,9 @@ fn can_migrate_contract() { #[test] fn test_max_spread() { assert_max_spread( - Some(Decimal::from_ratio(1200_000_000u128, 1_000_000u128)), + Some(Decimal::from_ratio(1_200_000_000_u128, 1_000_000u128)), Some(Decimal::percent(1)), - Uint128::from(1200_000_000u128), + Uint128::from(1_200_000_000_u128), Uint128::from(989_999u128), Uint128::zero(), ) @@ -508,38 +508,38 @@ fn test_max_spread() { // same example as above but using 6 and 18 decimal places assert_max_spread( Some(Decimal::from_ratio( - 1200_000_000u128, + 1_200_000_000_u128, 1_000_000_000_000_000_000u128, )), Some(Decimal::percent(1)), - Uint128::from(1200_000_000u128), + Uint128::from(1_200_000_000_u128), Uint128::from(989_999_900_000_000_000u128), Uint128::zero(), ) .unwrap_err(); assert_max_spread( - Some(Decimal::from_ratio(1200_000_000u128, 1_000_000u128)), + Some(Decimal::from_ratio(1_200_000_000_u128, 1_000_000u128)), None, // defaults to 0.5% - Uint128::from(1200_000_000u128), + Uint128::from(1_200_000_000_u128), Uint128::from(995_000u128), // all good Uint128::zero(), ) .unwrap(); assert_max_spread( - Some(Decimal::from_ratio(1200_000_000u128, 1_000_000u128)), + Some(Decimal::from_ratio(1_200_000_000_u128, 1_000_000u128)), None, // defaults to 0.1% - Uint128::from(1200_000_000u128), + Uint128::from(1_200_000_000_u128), Uint128::from(989_000u128), // fails Uint128::zero(), ) .unwrap_err(); assert_max_spread( - Some(Decimal::from_ratio(1200_000_000u128, 1_000_000u128)), + Some(Decimal::from_ratio(1_200_000_000_u128, 1_000_000u128)), Some(Decimal::percent(1)), - Uint128::from(1200_000_000u128), + Uint128::from(1_200_000_000_u128), Uint128::from(990_000u128), Uint128::zero(), ) @@ -548,12 +548,12 @@ fn test_max_spread() { // same example as above but using 6 and 18 decimal place assert_max_spread( Some(Decimal::from_ratio( - 1200_000_000u128, + 1_200_000_000_u128, 1_000_000_000_000_000_000u128, )), Some(Decimal::percent(1)), - Uint128::from(1200_000_000u128), - Uint128::from(990_000__000_000_000_000u128), + Uint128::from(1_200_000_000_u128), + Uint128::from(990_000_000_000_000_000_u128), Uint128::zero(), ) .unwrap(); @@ -603,9 +603,9 @@ fn test_max_spread() { .unwrap(); assert_max_spread( - Some(Decimal::from_ratio(1200_000_000u128, 1_000_000u128)), + Some(Decimal::from_ratio(1_200_000_000_u128, 1_000_000u128)), Some(Decimal::percent(60)), // this will default to 50% - Uint128::from(1200_000_000u128), + Uint128::from(1_200_000_000_u128), Uint128::from(989_999u128), Uint128::zero(), ) @@ -757,7 +757,7 @@ fn test_update_config_successful() { // check for original config assert_eq!(config.owner, Addr::unchecked("addr0000")); - assert_eq!(config.feature_toggle.swaps_enabled, true); + assert!(config.feature_toggle.swaps_enabled); assert_eq!(config.pool_fees.swap_fee.share, Decimal::zero()); let update_config_message = UpdateConfig { diff --git a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/withdrawals.rs b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/withdrawals.rs index 2d0d6d15..af13bcc9 100644 --- a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/withdrawals.rs +++ b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/withdrawals.rs @@ -119,7 +119,7 @@ fn withdraw_liquidity_cw20_lp() { let res = execute(deps.as_mut(), env.clone(), info, msg).unwrap(); let log_withdrawn_share = res.attributes.get(2).expect("no log"); let log_refund_assets = res.attributes.get(3).expect("no log"); - let msg_refund_0 = res.messages.get(0).expect("no message"); + let msg_refund_0 = res.messages.first().expect("no message"); let msg_refund_1 = res.messages.get(1).expect("no message"); let msg_refund_2 = res.messages.get(2).expect("no message"); let msg_burn_liquidity = res.messages.get(3).expect("no message"); diff --git a/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/protocol_fees.rs b/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/protocol_fees.rs index 242c7711..a79c2d36 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/protocol_fees.rs +++ b/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/protocol_fees.rs @@ -350,7 +350,7 @@ fn test_collect_protocol_fees_successful() { // make sure two messages were sent, one for the native token and one for the cw20 assert_eq!(res.messages.len(), 2); - let transfer_native_token_msg = res.messages.get(0).expect("no message"); + let transfer_native_token_msg = res.messages.first().expect("no message"); let transfer_cw20_token_msg = res.messages.get(1).expect("no message"); assert_eq!( transfer_native_token_msg, @@ -543,7 +543,7 @@ fn test_collect_protocol_fees_successful_1_fee_only() { // make sure one message was sent, as there is only one fee to collect, the other one is zero assert_eq!(res.messages.len(), 1); - let transfer_cw20_token_msg = res.messages.get(0).expect("no message"); + let transfer_cw20_token_msg = res.messages.first().expect("no message"); assert_eq!( transfer_cw20_token_msg, &SubMsg::new(CosmosMsg::Wasm(WasmMsg::Execute { diff --git a/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/provide_liquidity.rs b/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/provide_liquidity.rs index 6102c0e8..6536507a 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/provide_liquidity.rs +++ b/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/provide_liquidity.rs @@ -159,7 +159,7 @@ fn provide_liquidity_cw20_lp() { assert_eq!(res.messages.len(), 3usize); - let transfer_from_msg = res.messages.get(0).expect("no message"); + let transfer_from_msg = res.messages.first().expect("no message"); let mint_initial_lp_msg = res.messages.get(1).expect("no message"); let mint_msg = res.messages.get(2).expect("no message"); assert_eq!( @@ -255,7 +255,7 @@ fn provide_liquidity_cw20_lp() { let res: Response = execute(deps.as_mut(), env, info, msg).unwrap(); assert_eq!(res.messages.len(), 2usize); - let transfer_from_msg = res.messages.get(0).expect("no message"); + let transfer_from_msg = res.messages.first().expect("no message"); let mint_msg = res.messages.get(1).expect("no message"); assert_eq!( transfer_from_msg, diff --git a/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/swap.rs b/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/swap.rs index c6a4001a..181a2b83 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/swap.rs +++ b/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/swap.rs @@ -146,7 +146,7 @@ fn try_native_to_token() { ); let res = execute(deps.as_mut(), env, info, msg).unwrap(); assert_eq!(res.messages.len(), 2); - let msg_transfer = res.messages.get(0).expect("no message"); + let msg_transfer = res.messages.first().expect("no message"); // current price is 1.5, so expected return without spread is 1000 // ask_amount = ((ask_pool - accrued protocol fees) * offer_amount / (offer_pool - accrued protocol fees + offer_amount)) @@ -607,7 +607,7 @@ fn try_token_to_native() { let res = execute(deps.as_mut(), env, info, msg).unwrap(); assert_eq!(res.messages.len(), 2); - let msg_transfer = res.messages.get(0).expect("no message"); + let msg_transfer = res.messages.first().expect("no message"); // current price is 1.5, so expected return without spread is 1000 // ask_amount = (ask_pool * offer_amount / (offer_pool + offer_amount)) @@ -1169,7 +1169,7 @@ fn stableswap_with_different_precisions() { }], ); let res = execute(deps.as_mut(), env, info, msg).unwrap(); - let msg_transfer = res.messages.get(0).expect("no message"); + let msg_transfer = res.messages.first().expect("no message"); let expected_spread_amount = Uint128::new(0); let expected_swap_fee_amount = asset_return_amount.multiply_ratio(1u128, 400u128); // 0.25% diff --git a/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/testing.rs b/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/testing.rs index 01f1fb4c..7c3bfc09 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/testing.rs +++ b/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/testing.rs @@ -350,9 +350,9 @@ fn test_initialization_invalid_fees() { #[test] fn test_max_spread() { assert_max_spread( - Some(Decimal::from_ratio(1200_000_000u128, 1_000_000u128)), + Some(Decimal::from_ratio(1_200_000_000_u128, 1_000_000u128)), Some(Decimal::percent(1)), - Uint128::from(1200_000_000u128), + Uint128::from(1_200_000_000_u128), Uint128::from(989_999u128), Uint128::zero(), ) @@ -361,38 +361,38 @@ fn test_max_spread() { // same example as above but using 6 and 18 decimal places assert_max_spread( Some(Decimal::from_ratio( - 1200_000_000u128, + 1_200_000_000_u128, 1_000_000_000_000_000_000u128, )), Some(Decimal::percent(1)), - Uint128::from(1200_000_000u128), + Uint128::from(1_200_000_000_u128), Uint128::from(989_999_900_000_000_000u128), Uint128::zero(), ) .unwrap_err(); assert_max_spread( - Some(Decimal::from_ratio(1200_000_000u128, 1_000_000u128)), + Some(Decimal::from_ratio(1_200_000_000_u128, 1_000_000u128)), None, // defaults to 0.5% - Uint128::from(1200_000_000u128), + Uint128::from(1_200_000_000_u128), Uint128::from(995_000u128), // all good Uint128::zero(), ) .unwrap(); assert_max_spread( - Some(Decimal::from_ratio(1200_000_000u128, 1_000_000u128)), + Some(Decimal::from_ratio(1_200_000_000_u128, 1_000_000u128)), None, // defaults to 0.1% - Uint128::from(1200_000_000u128), + Uint128::from(1_200_000_000_u128), Uint128::from(989_000u128), // fails Uint128::zero(), ) .unwrap_err(); assert_max_spread( - Some(Decimal::from_ratio(1200_000_000u128, 1_000_000u128)), + Some(Decimal::from_ratio(1_200_000_000_u128, 1_000_000u128)), Some(Decimal::percent(1)), - Uint128::from(1200_000_000u128), + Uint128::from(1_200_000_000_u128), Uint128::from(990_000u128), Uint128::zero(), ) @@ -401,12 +401,12 @@ fn test_max_spread() { // same example as above but using 6 and 18 decimal place assert_max_spread( Some(Decimal::from_ratio( - 1200_000_000u128, + 1_200_000_000_u128, 1_000_000_000_000_000_000u128, )), Some(Decimal::percent(1)), - Uint128::from(1200_000_000u128), - Uint128::from(990_000__000_000_000_000u128), + Uint128::from(1_200_000_000_u128), + Uint128::from(990_000_000_000_000_000_u128), Uint128::zero(), ) .unwrap(); @@ -456,18 +456,18 @@ fn test_max_spread() { .unwrap(); assert_max_spread( - Some(Decimal::from_ratio(1200_000_000u128, 1_000_000u128)), + Some(Decimal::from_ratio(1_200_000_000_u128, 1_000_000u128)), Some(Decimal::percent(60)), // this will default to 50% - Uint128::from(1200_000_000u128), + Uint128::from(1_200_000_000_u128), Uint128::from(989_999u128), Uint128::zero(), ) .unwrap(); assert_max_spread( - Some(Decimal::from_ratio(1200_000_000u128, 1_000_000u128)), + Some(Decimal::from_ratio(1_200_000_000_u128, 1_000_000u128)), Some(Decimal::percent(60)), // this will default to 50% - Uint128::from(1200_000_000u128), + Uint128::from(1_200_000_000_u128), Uint128::from(989_999u128), Uint128::zero(), ) @@ -614,7 +614,7 @@ fn test_update_config_successful() { instantiate(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); let config: Config = - from_json(&query(deps.as_ref(), mock_env(), QueryMsg::Config {}).unwrap()).unwrap(); + from_json(query(deps.as_ref(), mock_env(), QueryMsg::Config {}).unwrap()).unwrap(); // check for original config assert_eq!(config.owner, Addr::unchecked("addr0000")); diff --git a/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/withdrawals.rs b/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/withdrawals.rs index e8b25c76..feb3bb71 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/withdrawals.rs +++ b/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/withdrawals.rs @@ -116,7 +116,7 @@ fn withdraw_xyk_liquidity_cw20_lp() { let res = execute(deps.as_mut(), env, info, msg).unwrap(); let log_withdrawn_share = res.attributes.get(2).expect("no log"); let log_refund_assets = res.attributes.get(3).expect("no log"); - let msg_refund_0 = res.messages.get(0).expect("no message"); + let msg_refund_0 = res.messages.first().expect("no message"); let msg_refund_1 = res.messages.get(1).expect("no message"); let msg_burn_liquidity = res.messages.get(2).expect("no message"); diff --git a/contracts/liquidity_hub/vault-network/vault_factory/src/contract.rs b/contracts/liquidity_hub/vault-network/vault_factory/src/contract.rs index 9a3e439d..ea24a196 100644 --- a/contracts/liquidity_hub/vault-network/vault_factory/src/contract.rs +++ b/contracts/liquidity_hub/vault-network/vault_factory/src/contract.rs @@ -93,6 +93,15 @@ pub fn migrate(mut deps: DepsMut, _env: Env, _msg: MigrateMsg) -> StdResult StdResult { + match msg { + QueryMsg::Config {} => get_config(deps), + QueryMsg::Vault { asset_info } => get_vault(deps, asset_info), + QueryMsg::Vaults { start_after, limit } => get_vaults(deps, start_after, limit), + } +} + #[cfg(test)] mod test { use white_whale::vault_network::vault_factory::MigrateMsg; @@ -116,12 +125,3 @@ mod test { } } } - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { - match msg { - QueryMsg::Config {} => get_config(deps), - QueryMsg::Vault { asset_info } => get_vault(deps, asset_info), - QueryMsg::Vaults { start_after, limit } => get_vaults(deps, start_after, limit), - } -} diff --git a/contracts/liquidity_hub/whale_lair/src/tests/instantiate.rs b/contracts/liquidity_hub/whale_lair/src/tests/instantiate.rs index 8acb12ba..f6c1fec5 100644 --- a/contracts/liquidity_hub/whale_lair/src/tests/instantiate.rs +++ b/contracts/liquidity_hub/whale_lair/src/tests/instantiate.rs @@ -20,7 +20,7 @@ fn test_instantiate_successfully() { denom: "bWHALE".to_string(), }, ], - &vec![], + &[], ) .assert_config(Config { owner: Addr::unchecked("owner"), @@ -57,7 +57,7 @@ fn test_instantiate_unsuccessfully() { denom: "uwhale".to_string(), }, ], - &vec![], + &[], |error| { println!("1 --{error:?}"); println!("2 --{:?}", error.root_cause()); @@ -75,7 +75,7 @@ fn test_instantiate_unsuccessfully() { vec![AssetInfo::Token { contract_addr: "contract123".to_string(), }], - &vec![], + &[], |error| { println!("1 --{error:?}"); println!("2 --{:?}", error.root_cause()); diff --git a/contracts/liquidity_hub/whale_lair/src/tests/robot.rs b/contracts/liquidity_hub/whale_lair/src/tests/robot.rs index b6b95967..76206f29 100644 --- a/contracts/liquidity_hub/whale_lair/src/tests/robot.rs +++ b/contracts/liquidity_hub/whale_lair/src/tests/robot.rs @@ -74,7 +74,7 @@ impl TestingRobot { denom: "bWHALE".to_string(), }, ], - &vec![], + &[], ) } @@ -83,7 +83,7 @@ impl TestingRobot { unbonding_period: Uint64, growth_rate: Decimal, bonding_assets: Vec, - funds: &Vec, + funds: &[Coin], ) -> &mut Self { let fee_collector_id = store_fee_collector_code(&mut self.app); let fee_distributor_id = store_fee_distributor_code(&mut self.app); @@ -116,7 +116,7 @@ impl TestingRobot { grace_period: Uint64::new(1), epoch_config: EpochConfig { duration: Uint64::new(86_400_000_000_000u64), // a day - genesis_epoch: Uint64::new(1678802400_000000000u64), // March 14, 2023 2:00:00 PM + genesis_epoch: Uint64::new(1_678_802_400_000_000_000_u64), // March 14, 2023 2:00:00 PM }, distribution_asset: AssetInfo::NativeToken { denom: "uwhale".to_string(), @@ -148,7 +148,7 @@ impl TestingRobot { unbonding_period: Uint64, growth_rate: Decimal, bonding_assets: Vec, - funds: &Vec, + funds: &[Coin], error: impl Fn(anyhow::Error), ) -> &mut Self { error( @@ -237,7 +237,7 @@ fn instantiate_contract( unbonding_period: Uint64, growth_rate: Decimal, bonding_assets: Vec, - funds: &Vec, + funds: &[Coin], ) -> anyhow::Result { let msg = InstantiateMsg { unbonding_period,