Skip to content

Commit

Permalink
integration-tests: Add default constructor for generic envs
Browse files Browse the repository at this point in the history
  • Loading branch information
cdamian committed Nov 29, 2023
1 parent 3b68221 commit b081918
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 181 deletions.
17 changes: 5 additions & 12 deletions runtime/integration-tests/src/generic/cases/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ fn transfer_balance<T: Runtime>() {
// Set up all GenesisConfig for your initial state
// You can choose `RuntimeEnv` by `FudgeEnv` to make it working with fudge
// environment.
let mut env = RuntimeEnv::<T>::from_storage(
Default::default(),
let mut env = RuntimeEnv::<T>::from_parachain_storage(
Genesis::default()
.add(pallet_balances::GenesisConfig::<T> {
balances: vec![(
Expand All @@ -33,7 +32,6 @@ fn transfer_balance<T: Runtime>() {
)],
})
.storage(),
Genesis::<T>::default().storage(),
);

// Call an extrinsic that would be processed immediately
Expand Down Expand Up @@ -76,8 +74,7 @@ fn fudge_transfer_balance<T: Runtime + FudgeSupport>() {
const TRANSFER: Balance = 1000 * CFG;
const FOR_FEES: Balance = 1 * CFG;

let mut env = FudgeEnv::<T>::from_storage(
Default::default(),
let mut env = FudgeEnv::<T>::from_parachain_storage(
Genesis::default()
.add(pallet_balances::GenesisConfig::<T> {
balances: vec![(
Expand All @@ -86,7 +83,6 @@ fn fudge_transfer_balance<T: Runtime + FudgeSupport>() {
)],
})
.storage(),
Genesis::<T>::default().storage(),
);

env.submit_later(
Expand Down Expand Up @@ -133,8 +129,7 @@ fn fudge_transfer_balance<T: Runtime + FudgeSupport>() {
}

fn call_api<T: Runtime>() {
let env =
RuntimeEnv::<T>::from_storage(Default::default(), Default::default(), Default::default());
let env = RuntimeEnv::<T>::default();

env.parachain_state(|| {
// If imported the trait: sp_api::runtime_decl_for_core::CoreV4,
Expand All @@ -147,8 +142,7 @@ fn call_api<T: Runtime>() {
}

fn fudge_call_api<T: Runtime + FudgeSupport>() {
let env =
FudgeEnv::<T>::from_storage(Default::default(), Default::default(), Default::default());
let env = FudgeEnv::<T>::default();

// Exclusive from fudge environment.
// It uses a client to access the runtime api.
Expand All @@ -164,8 +158,7 @@ fn fudge_call_api<T: Runtime + FudgeSupport>() {
}

fn pass_time_one_block<T: Runtime>() {
let mut env =
RuntimeEnv::<T>::from_storage(Default::default(), Default::default(), Default::default());
let mut env = RuntimeEnv::<T>::default();

let before = env.parachain_state(|| pallet_timestamp::Pallet::<T>::get());

Expand Down
4 changes: 1 addition & 3 deletions runtime/integration-tests/src/generic/cases/investments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@ mod common {
use super::*;

pub fn initialize_state_for_investments<E: Env<T>, T: Runtime>() -> E {
let mut env = E::from_storage(
Default::default(),
let mut env = E::from_parachain_storage(
Genesis::<T>::default()
.add(genesis::balances(T::ExistentialDeposit::get() + FOR_FEES))
.add(genesis::assets(vec![Usd6::ID]))
.add(genesis::tokens(vec![(Usd6::ID, Usd6::ED)]))
.storage(),
Genesis::<T>::default().storage(),
);

env.parachain_state_mut(|| {
Expand Down
Loading

0 comments on commit b081918

Please sign in to comment.