Skip to content

Commit

Permalink
This testcase for new multitest query should work
Browse files Browse the repository at this point in the history
  • Loading branch information
ueco-jb committed Nov 16, 2021
1 parent 27e9712 commit a1fe17b
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions packages/multi-test/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ impl<ExecC, QueryC> WasmKeeper<ExecC, QueryC> {
}

pub fn load_contract(&self, storage: &dyn Storage, address: &Addr) -> AnyResult<ContractData> {
println!("loading contract: {:?}", address.to_string());
CONTRACTS
.load(&prefixed_read(storage, NAMESPACE_WASM), address)
.map_err(Into::into)
Expand Down Expand Up @@ -600,6 +601,7 @@ where
label,
created,
};
println!("Saving the contract: {:?}", addr.to_string());
self.save_contract(storage, &addr, &info)?;
Ok(addr)
}
Expand Down Expand Up @@ -1031,6 +1033,43 @@ mod test {
);
}

#[test]
fn query_contract_into() {
let api = MockApi::default();
let mut keeper = WasmKeeper::<Empty, Empty>::new();
let block = mock_env().block;
let code_id = keeper.store_code(payout::contract());

let wasm_storage = MockStorage::new();
let mut cache = StorageTransaction::new(&wasm_storage);

let contract_addr = keeper
.register_contract(
&mut cache,
code_id,
Addr::unchecked("foobar"),
Addr::unchecked("admin"),
"label".to_owned(),
1000,
)
.unwrap();

let querier: MockQuerier<Empty> = MockQuerier::new(&[]);
println!("Try to load contract: {:?}", contract_addr.to_string());
let query = WasmQuery::ContractInfo { contract_addr: contract_addr.to_string() };
let info = keeper
.query(&api, &wasm_storage, &querier, &block, query).unwrap();

let expected = ContractInfoResponse {
code_id: code_id as u64,
creator: "foobar".to_owned(),
admin: Some("admin".to_owned()),
pinned: false,
ibc_port: None
};
assert_eq!(expected, from_slice(&info).unwrap());
}

#[test]
fn contract_send_coins() {
let api = MockApi::default();
Expand Down

0 comments on commit a1fe17b

Please sign in to comment.