Skip to content

Commit

Permalink
Merge branch 'master' into aj-memory-crate
Browse files Browse the repository at this point in the history
  • Loading branch information
ascjones committed Jul 23, 2019
2 parents bf52609 + 7d19156 commit 64b9e85
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions core/src/env/test.rs
Expand Up @@ -37,6 +37,21 @@ pub fn set_caller<T: EnvTypes>(address: T::AccountId) {
ContractEnv::<T>::set_caller(address)
}

/// Sets the timestamp for the next contract invocation.
pub fn set_now<T: EnvTypes>(timestamp: T::Moment) {
ContractEnv::<T>::set_now(timestamp)
}

/// Sets the current block number for the next contract invocation.
pub fn set_block_number<T: EnvTypes>(block_number: T::BlockNumber) {
ContractEnv::<T>::set_block_number(block_number)
}

/// Sets the contract balance for the next contract invocation.
pub fn set_balance<T: EnvTypes>(balance: T::Balance) {
ContractEnv::<T>::set_balance(balance)
}

/// Returns an iterator over the uninterpreted bytes of all past emitted events.
pub fn emitted_events<T: EnvTypes>() -> impl Iterator<Item = Vec<u8>> {
ContractEnv::<T>::emitted_events().into_iter()
Expand Down
4 changes: 2 additions & 2 deletions core/src/env/test_env.rs
Expand Up @@ -295,7 +295,7 @@ impl TestEnvData {
}

/// Returns an iterator over all emitted events.
pub fn emitted_events(&self) -> impl Iterator<Item = &[u8]> {
pub fn emitted_events(&self) -> impl DoubleEndedIterator<Item = &[u8]> {
self.events
.iter()
.map(|event_data| event_data.data_as_bytes())
Expand Down Expand Up @@ -460,7 +460,7 @@ impl<T> TestEnv<T> where T: EnvTypes {
);

/// Returns an iterator over all emitted events.
pub fn emitted_events() -> impl Iterator<Item = Vec<u8>> {
pub fn emitted_events() -> impl DoubleEndedIterator<Item = Vec<u8>> {
TEST_ENV_DATA.with(|test_env| {
test_env
.borrow()
Expand Down

0 comments on commit 64b9e85

Please sign in to comment.