hpl_interface/
macros.rs

1#[macro_export]
2macro_rules! build_test_querier {
3    ($handler:expr) => {
4        fn test_query<
5            S: cosmwasm_schema::serde::Serialize,
6            T: cosmwasm_schema::serde::de::DeserializeOwned,
7        >(
8            deps: cosmwasm_std::Deps,
9            msg: S,
10        ) -> T {
11            let res = $handler(
12                deps,
13                cosmwasm_std::testing::mock_env(),
14                cosmwasm_std::from_json(cosmwasm_std::to_json_binary(&msg).unwrap()).unwrap(),
15            )
16            .map_err(|e| e.to_string())
17            .unwrap();
18            cosmwasm_std::from_json(&res).unwrap()
19        }
20    };
21}
22
23#[macro_export]
24macro_rules! build_test_executor {
25    ($handler:expr) => {
26        fn test_execute<S: cosmwasm_schema::serde::Serialize>(
27            deps: cosmwasm_std::DepsMut,
28            sender: &cosmwasm_std::Addr,
29            msg: S,
30            funds: Vec<cosmwasm_std::Coin>,
31        ) -> cosmwasm_std::Response {
32            $handler(
33                deps,
34                cosmwasm_std::testing::mock_env(),
35                cosmwasm_std::testing::mock_info(sender.as_str(), &funds),
36                cosmwasm_std::from_json(cosmwasm_std::to_json_binary(&msg).unwrap()).unwrap(),
37            )
38            .map_err(|e| e.to_string())
39            .unwrap()
40        }
41    };
42}