Skip to content

Commit ec2b971

Browse files
committed
Expose sub-queriers directly in MockQuerier
1 parent b14e902 commit ec2b971

File tree

6 files changed

+15
-48
lines changed

6 files changed

+15
-48
lines changed

contracts/cyberpunk/src/contract.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ mod tests {
254254
fn query_denoms_works() {
255255
let mut deps = setup();
256256

257-
deps.querier.set_denom_metadata(
257+
deps.querier.bank.set_denom_metadata(
258258
&(0..98)
259259
.map(|i| DenomMetadata {
260260
symbol: format!("FOO{i}"),

contracts/hackatom/src/contract.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,9 @@ mod tests {
444444
assert_eq!(init_res.messages.len(), 0);
445445

446446
// balance changed in init
447-
deps.querier.update_balance(MOCK_CONTRACT_ADDR, init_amount);
447+
deps.querier
448+
.bank
449+
.update_balance(MOCK_CONTRACT_ADDR, init_amount);
448450

449451
// beneficiary can release it
450452
let execute_info = mock_info(verifier.as_str(), &[]);
@@ -490,7 +492,9 @@ mod tests {
490492
assert_eq!(init_res.messages.len(), 0);
491493

492494
// balance changed in init
493-
deps.querier.update_balance(MOCK_CONTRACT_ADDR, init_amount);
495+
deps.querier
496+
.bank
497+
.update_balance(MOCK_CONTRACT_ADDR, init_amount);
494498

495499
// beneficiary cannot release it
496500
let execute_info = mock_info(beneficiary.as_str(), &[]);

contracts/ibc-reflect/src/contract.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ mod tests {
614614
connect(deps.as_mut(), channel_id, &account);
615615
// assign it some funds
616616
let funds = vec![coin(123456, "uatom"), coin(7654321, "tgrd")];
617-
deps.querier.update_balance(&account, funds.clone());
617+
deps.querier.bank.update_balance(&account, funds.clone());
618618

619619
// channel should be listed and have balance
620620
let raw = query(deps.as_ref(), mock_env(), QueryMsg::ListAccounts {}).unwrap();

contracts/staking/src/contract.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ mod tests {
608608
let rebond_msg = ExecuteMsg::_BondAllTokens {};
609609
let info = mock_info(MOCK_CONTRACT_ADDR, &[]);
610610
deps.querier
611+
.bank
611612
.update_balance(MOCK_CONTRACT_ADDR, coins(500, "ustake"));
612613
let _ = execute(deps.as_mut(), mock_env(), info, rebond_msg).unwrap();
613614

@@ -699,12 +700,13 @@ mod tests {
699700
let rebond_msg = ExecuteMsg::_BondAllTokens {};
700701
let info = mock_info(MOCK_CONTRACT_ADDR, &[]);
701702
deps.querier
703+
.bank
702704
.update_balance(MOCK_CONTRACT_ADDR, coins(500, "ustake"));
703705
let _ = execute(deps.as_mut(), mock_env(), info, rebond_msg).unwrap();
704706

705707
// update the querier with new bond, lower balance
706708
set_delegation(&mut deps.querier, 1500, "ustake");
707-
deps.querier.update_balance(MOCK_CONTRACT_ADDR, vec![]);
709+
deps.querier.bank.update_balance(MOCK_CONTRACT_ADDR, vec![]);
708710

709711
// creator now tries to unbond these tokens - this must fail
710712
let unbond_msg = ExecuteMsg::Unbond {

packages/std/src/testing/mock.rs

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,11 @@ pub type MockQuerierCustomHandlerResult = SystemResult<ContractResult<Binary>>;
462462
/// MockQuerier holds an immutable table of bank balances
463463
/// and configurable handlers for Wasm queries and custom queries.
464464
pub struct MockQuerier<C: DeserializeOwned = Empty> {
465-
bank: BankQuerier,
465+
pub bank: BankQuerier,
466466
#[cfg(feature = "staking")]
467467
staking: StakingQuerier,
468468
#[cfg(feature = "cosmwasm_1_3")]
469-
distribution: DistributionQuerier,
469+
pub distribution: DistributionQuerier,
470470
wasm: WasmQuerier,
471471
#[cfg(feature = "stargate")]
472472
ibc: IbcQuerier,
@@ -497,46 +497,6 @@ impl<C: DeserializeOwned> MockQuerier<C> {
497497
}
498498
}
499499

500-
// set a new balance for the given address and return the old balance
501-
pub fn update_balance(
502-
&mut self,
503-
addr: impl Into<String>,
504-
balance: Vec<Coin>,
505-
) -> Option<Vec<Coin>> {
506-
self.bank.update_balance(addr, balance)
507-
}
508-
509-
pub fn set_denom_metadata(&mut self, denom_metadata: &[DenomMetadata]) {
510-
self.bank.set_denom_metadata(denom_metadata);
511-
}
512-
513-
#[cfg(feature = "cosmwasm_1_3")]
514-
pub fn set_withdraw_address(
515-
&mut self,
516-
delegator_address: impl Into<String>,
517-
withdraw_address: impl Into<String>,
518-
) {
519-
self.distribution
520-
.set_withdraw_address(delegator_address, withdraw_address);
521-
}
522-
523-
/// Sets multiple withdraw addresses.
524-
///
525-
/// This allows passing multiple tuples of `(delegator_address, withdraw_address)`.
526-
/// It does not overwrite existing entries.
527-
#[cfg(feature = "cosmwasm_1_3")]
528-
pub fn set_withdraw_addresses(
529-
&mut self,
530-
withdraw_addresses: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>,
531-
) {
532-
self.distribution.set_withdraw_addresses(withdraw_addresses);
533-
}
534-
535-
#[cfg(feature = "cosmwasm_1_3")]
536-
pub fn clear_withdraw_addresses(&mut self) {
537-
self.distribution.clear_withdraw_addresses();
538-
}
539-
540500
#[cfg(feature = "staking")]
541501
pub fn update_staking(
542502
&mut self,
@@ -690,6 +650,7 @@ impl BankQuerier {
690650
}
691651
}
692652

653+
/// set a new balance for the given address and return the old balance
693654
pub fn update_balance(
694655
&mut self,
695656
addr: impl Into<String>,

packages/vm/src/testing/querier.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl<C: CustomQuery + DeserializeOwned> MockQuerier<C> {
3232
addr: impl Into<String>,
3333
balance: Vec<Coin>,
3434
) -> Option<Vec<Coin>> {
35-
self.querier.update_balance(addr, balance)
35+
self.querier.bank.update_balance(addr, balance)
3636
}
3737

3838
#[cfg(feature = "staking")]

0 commit comments

Comments
 (0)