1
use crate::{
2
    admin::set_route,
3
    queries::estimate_single_swap_execution,
4
    state::CONFIG,
5
    testing::test_utils::{mock_deps_eth_inj, str_coin, Decimals, MultiplierQueryBehavior, TEST_USER_ADDR},
6
    types::{Config, FPCoin, SwapEstimationAmount},
7
};
8

            
9
use cosmwasm_std::{testing::mock_env, Addr};
10
use injective_cosmwasm::{MarketId, OwnedDepsExt, TEST_MARKET_ID_1, TEST_MARKET_ID_2};
11

            
12
#[test]
13
2
fn it_reverts_if_atomic_fee_multiplier_query_fails() {
14
2
    let env = mock_env();
15
2
    let deps_binding = mock_deps_eth_inj(MultiplierQueryBehavior::Fail);
16
2
    let mut deps = deps_binding;
17
2

            
18
2
    let config = Config {
19
2
        fee_recipient: Addr::unchecked(TEST_USER_ADDR),
20
2
        admin: Addr::unchecked(TEST_USER_ADDR),
21
2
    };
22
2
    CONFIG.save(deps.as_mut_deps().storage, &config).expect("could not save config");
23
2

            
24
2
    set_route(
25
2
        deps.as_mut_deps(),
26
2
        &Addr::unchecked(TEST_USER_ADDR),
27
2
        "eth".to_string(),
28
2
        "inj".to_string(),
29
2
        vec![TEST_MARKET_ID_1.into(), TEST_MARKET_ID_2.into()],
30
2
    )
31
2
    .unwrap();
32
2

            
33
2
    let response_1 = estimate_single_swap_execution(
34
2
        &deps.as_mut_deps().as_ref(),
35
2
        &env,
36
2
        &MarketId::unchecked(TEST_MARKET_ID_1.to_string()),
37
2
        SwapEstimationAmount::InputQuantity(FPCoin::from(str_coin("1", "eth", Decimals::Eighteen))),
38
2
        true, // is_simulation
39
2
    );
40
2

            
41
2
    assert!(response_1.is_err(), "should have failed");
42
2
    assert!(
43
2
        response_1.unwrap_err().to_string().contains("Querier system error: Unknown system error"),
44
        "wrong error message"
45
    );
46
2
}