-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
68 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use std::marker::PhantomData; | ||
use std::ops::Deref; | ||
|
||
use axelar_core_std::nexus::query::QueryMsg; | ||
use axelar_core_std::query::AxelarQueryMsg; | ||
use cosmwasm_std::testing::{MockApi, MockQuerier, MockQuerierCustomHandlerResult, MockStorage}; | ||
use cosmwasm_std::{ContractResult, Deps, DepsMut, Empty, OwnedDeps, QuerierWrapper, SystemResult}; | ||
use serde_json::json; | ||
|
||
pub fn mock_axelar_dependencies( | ||
) -> OwnedDeps<MockStorage, MockApi, MockQuerier<AxelarQueryMsg>, AxelarQueryMsg> { | ||
OwnedDeps { | ||
storage: MockStorage::default(), | ||
api: MockApi::default(), | ||
querier: MockQuerier::<AxelarQueryMsg>::new(&[("contract", &[])]), | ||
custom_query_type: PhantomData, | ||
} | ||
} | ||
|
||
pub fn axelar_query_handler( | ||
tx_hash: [u8; 32], | ||
nonce: u32, | ||
is_chain_registered: bool, | ||
) -> impl Fn(&AxelarQueryMsg) -> MockQuerierCustomHandlerResult { | ||
move |query| { | ||
let result = match query { | ||
AxelarQueryMsg::Nexus(nexus_query) => match nexus_query { | ||
QueryMsg::TxHashAndNonce {} => json!({ | ||
"tx_hash": tx_hash, | ||
"nonce": nonce, | ||
}), | ||
QueryMsg::IsChainRegistered { chain: _ } => json!({ | ||
"is_registered": is_chain_registered | ||
}), | ||
_ => unreachable!("unexpected nexus query {:?}", nexus_query), | ||
}, | ||
_ => unreachable!("unexpected query request {:?}", query), | ||
} | ||
.to_string() | ||
.as_bytes() | ||
.into(); | ||
|
||
SystemResult::Ok(ContractResult::Ok(result)) | ||
} | ||
} | ||
|
||
pub fn emptying_deps_mut<'a>(deps: &'a mut DepsMut<AxelarQueryMsg>) -> DepsMut<'a, Empty> { | ||
DepsMut { | ||
storage: deps.storage, | ||
api: deps.api, | ||
querier: QuerierWrapper::new(deps.querier.deref()), | ||
} | ||
} | ||
|
||
pub fn emptying_deps<'a>(deps: &'a Deps<AxelarQueryMsg>) -> Deps<'a, Empty> { | ||
Deps { | ||
storage: deps.storage, | ||
api: deps.api, | ||
querier: QuerierWrapper::new(deps.querier.deref()), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters