-
Notifications
You must be signed in to change notification settings - Fork 369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Envs
, a factory for making mock Env
s
#2442
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice idea! That way we could even extend it if we need more configurability in the future.
packages/std/src/testing/mock.rs
Outdated
|
||
pub fn make(&mut self) -> Env { | ||
let height = self.last_height + 1; | ||
let time = self.last_time.plus_seconds(5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to make the time increment configurable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of things are configurable now. See EnvsOptions
/// assert_eq!(env.block.time, Timestamp::from_nanos(1_571_797_419_879_305_533).plus_seconds((index*5) as u64)); | ||
/// } | ||
/// ``` | ||
pub struct Envs { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a more specific name would be better? Envs sounds very generic and doesn't really indicate that this is for testing only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy for suggestions. But I doubt this will be used in the majority of test code.
You have to import it through cosmwasm_std::testing::Envs
, so testing is implied here
A potential solution for #2218. Not necessarily ready yet but I wonder if this looks good.
Closes #2218