Skip to content

Commit f31e905

Browse files
committed
test(law): add test for program query
1 parent fe4b0da commit f31e905

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

contracts/cw-law-stone/src/contract.rs

+28-1
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,16 @@ pub mod reply {
168168
#[cfg(test)]
169169
mod tests {
170170
use super::*;
171+
use crate::msg::ProgramResponse;
171172
use crate::state::{Object, DEPENDENCIES, PROGRAM};
172173
use cosmwasm_std::testing::{mock_env, mock_info, MockQuerierCustomHandlerResult};
173174
use cosmwasm_std::{
174175
from_binary, to_binary, CosmosMsg, Event, Order, SubMsgResponse, SubMsgResult, SystemError,
175176
SystemResult,
176177
};
177-
use logic_bindings::testing::mock::mock_dependencies_with_logic_handler;
178+
use logic_bindings::testing::mock::{
179+
mock_dependencies_with_logic_and_balance, mock_dependencies_with_logic_handler,
180+
};
178181
use logic_bindings::{
179182
Answer, AskResponse, LogicCustomQuery, Result as LogicResult, Substitution, Term,
180183
};
@@ -267,6 +270,30 @@ mod tests {
267270
INSTANTIATE_CONTEXT.load(&deps.storage).unwrap()
268271
);
269272
}
273+
#[test]
274+
fn program() {
275+
let mut deps = mock_dependencies_with_logic_and_balance(&[]);
276+
277+
let object_id =
278+
"4cbe36399aabfcc7158ee7a66cbfffa525bb0ceab33d1ff2cff08759fe0a9b05".to_string();
279+
let storage_addr =
280+
"okp41ffzp0xmjhwkltuxcvccl0z9tyfuu7txp5ke0tpkcjpzuq9fcj3pqrteqt3".to_string();
281+
PROGRAM
282+
.save(
283+
deps.as_mut().storage,
284+
&Object {
285+
object_id: object_id.clone(),
286+
storage_address: storage_addr.clone(),
287+
},
288+
)
289+
.unwrap();
290+
291+
let res = query(deps.as_ref(), mock_env(), QueryMsg::Program {}).unwrap();
292+
let result: ProgramResponse = from_binary(&res).unwrap();
293+
294+
assert_eq!(object_id, result.object_id);
295+
assert_eq!(storage_addr, result.storage_address);
296+
}
270297

271298
#[derive(Clone)]
272299
struct StoreTestCase {

0 commit comments

Comments
 (0)