Skip to content

Commit

Permalink
Fix bank mock querier
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Jun 22, 2023
1 parent 0a9b745 commit c5717a7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/std/src/testing/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,10 @@ impl<C: DeserializeOwned> MockQuerier<C> {
self.bank.update_balance(addr, balance)
}

pub fn set_denom_metadata(&mut self, denom_metadata: &[DenomMetadata]) {
self.bank.set_denom_metadata(denom_metadata);
}

#[cfg(feature = "staking")]
pub fn update_staking(
&mut self,
Expand Down Expand Up @@ -635,6 +639,8 @@ impl BankQuerier {

pub fn set_denom_metadata(&mut self, denom_metadata: &[DenomMetadata]) {
self.denom_metadata = denom_metadata.to_vec();
self.denom_metadata
.sort_unstable_by(|a, b| a.symbol.cmp(&b.symbol));
}

fn calculate_supplies(balances: &HashMap<String, Vec<Coin>>) -> HashMap<String, Uint128> {
Expand Down Expand Up @@ -1376,6 +1382,10 @@ mod tests {
let res2: AllDenomMetadataResponse = from_binary(&res2).unwrap();
assert_eq!(res2.metadata.len(), 10);
assert_ne!(res.metadata.last(), res2.metadata.first());
// should have no overlap
for m in res.metadata {
assert!(!res2.metadata.contains(&m));
}

// querying all 100 should work
let res = bank
Expand Down

0 comments on commit c5717a7

Please sign in to comment.