Skip to content

Commit 44e0220

Browse files
committed
Use BTreeMap for DistributionQuerier field
1 parent e5ef873 commit 44e0220

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

packages/std/src/testing/mock.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ impl StakingQuerier {
990990
#[cfg(feature = "cosmwasm_1_3")]
991991
#[derive(Clone, Default)]
992992
pub struct DistributionQuerier {
993-
withdraw_addresses: HashMap<String, String>,
993+
withdraw_addresses: BTreeMap<String, String>,
994994
/// Mock of accumulated rewards, indexed first by delegator and then validator address.
995995
rewards: BTreeMap<String, BTreeMap<String, Vec<DecCoin>>>,
996996
/// Mock of validators that a delegator has bonded to.
@@ -2363,4 +2363,26 @@ mod tests {
23632363
fn making_an_address_with_empty_prefix_should_panic() {
23642364
MockApi::default().with_prefix("").addr_make("creator");
23652365
}
2366+
2367+
#[test]
2368+
fn distribution_querier_new_works() {
2369+
let addresses = [
2370+
("addr0000".to_string(), "addr0001".to_string()),
2371+
("addr0002".to_string(), "addr0001".to_string()),
2372+
];
2373+
let btree_map = BTreeMap::from(addresses.clone());
2374+
2375+
// should still work with HashMap
2376+
let hashmap = HashMap::from(addresses.clone());
2377+
let querier = DistributionQuerier::new(hashmap);
2378+
assert_eq!(querier.withdraw_addresses, btree_map);
2379+
2380+
// should work with BTreeMap
2381+
let querier = DistributionQuerier::new(btree_map.clone());
2382+
assert_eq!(querier.withdraw_addresses, btree_map);
2383+
2384+
// should work with array
2385+
let querier = DistributionQuerier::new(addresses);
2386+
assert_eq!(querier.withdraw_addresses, btree_map);
2387+
}
23662388
}

0 commit comments

Comments
 (0)