Skip to content

Commit 5c94866

Browse files
committed
Make EnvsOptions non_exhaustive and add soem docs
1 parent 780319b commit 5c94866

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

packages/std/src/testing/mock.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,27 @@ pub struct Envs {
449449
last_time: Timestamp,
450450
}
451451

452+
/// Options to create an `Envs` instance.
453+
///
454+
/// ## Examples
455+
///
456+
/// Must be constructed with the help of `Default` since new options might be added later.
457+
///
458+
/// ```
459+
/// # use cosmwasm_std::Timestamp;
460+
/// use cosmwasm_std::testing::{Envs, EnvsOptions};
461+
///
462+
/// let mut options = EnvsOptions::default();
463+
/// options.chain_id = "megachain".to_string();
464+
/// options.bech32_prefix = "mega";
465+
/// let mut envs = Envs::with_options(options);
466+
///
467+
/// let env = envs.make();
468+
/// assert_eq!(env.block.chain_id, "megachain");
469+
/// assert_eq!(env.contract.address.as_str(), "mega1jpev2csrppg792t22rn8z8uew8h3sjcpglcd0qv9g8gj8ky922ts7vnj8h");
470+
/// ```
452471
#[derive(Clone)]
472+
#[non_exhaustive]
453473
pub struct EnvsOptions {
454474
pub bech32_prefix: &'static str, /* static due to MockApi's Copy requirement. No better idea for now. */
455475
pub block_time: u64,

0 commit comments

Comments
 (0)