-
Notifications
You must be signed in to change notification settings - Fork 86
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
Loans: Integration tests #1600
Loans: Integration tests #1600
Changes from all commits
dada23c
0ea63aa
fb0c847
693d9e3
f8be6d8
eff5303
c434bf7
d699e1c
4ab6412
5b264e0
83a5095
8fc7858
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,7 +99,7 @@ package policy { | |
} | ||
|
||
enum WriteOffTrigger { | ||
PrincipalOverdueDays, | ||
PrincipalOverdue, | ||
PriceOutdated, | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,23 @@ | ||||||
# Runtime Generic tests | ||||||
|
||||||
The aim of this module is to make integration-tests independently for all runtimes at once. | ||||||
|
||||||
You can choose the environment for each of your use cases: | ||||||
- `RuntimeEnv`: Simple environment that acts as a wrapper over the runtime | ||||||
- `FudgeEnv`: Advanced environment that use a client and connect the runtime to a relay chain. | ||||||
|
||||||
Both environment uses the same interface so jumping from one to the another should be something "smooth". | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit
Suggested change
|
||||||
|
||||||
## Where I start? | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit
Suggested change
|
||||||
- Create a new file in `cases/<file.rs>` for the use case you want to test. | ||||||
- Maybe you need to update the `Runtime` trait in `config.rs` file with extra information from your new pallet. | ||||||
This could imply: | ||||||
- Adding bounds to the `Runtime` trait with your new pallet. | ||||||
- Adding bounds to `T::RuntimeCallExt` to support calls from your pallet. | ||||||
- Adding bounds to `T::EventExt` to support events from your pallet. | ||||||
- Adding bounds to `T::Api` to support new api calls. | ||||||
- You can add `GenesisBuild` builders for setting the initial state of your pallet for others in `utils/genesis.rs`. | ||||||
Please be as generic and simple as possible to leave others to compose its own requirement using your method, | ||||||
without hidden initializations. | ||||||
- You can add any utility that helps to initialize states for others under `utils` folder. | ||||||
Again, focus in simplity but without side effects or hidden / non-obvious state changes. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
use cfg_primitives::{Balance, CFG}; | ||
use cfg_primitives::{Balance, CFG, SECONDS_PER_YEAR}; | ||
use cfg_traits::IntoSeconds; | ||
use frame_support::traits::Get; | ||
use sp_api::runtime_decl_for_Core::CoreV4; | ||
|
||
use crate::{ | ||
generic::{ | ||
environment::{Blocks, Env}, | ||
config::Runtime, | ||
env::{Blocks, Env}, | ||
envs::{ | ||
fudge_env::{FudgeEnv, FudgeSupport}, | ||
runtime_env::RuntimeEnv, | ||
}, | ||
runtime::Runtime, | ||
utils::genesis::Genesis, | ||
}, | ||
utils::accounts::Keyring, | ||
|
@@ -156,7 +157,21 @@ fn fudge_call_api<T: Runtime + FudgeSupport>() { | |
}) | ||
} | ||
|
||
fn pass_time_one_block<T: Runtime>() { | ||
let mut env = RuntimeEnv::<T>::from_storage(Default::default()); | ||
|
||
let before = env.state(|| pallet_timestamp::Pallet::<T>::get()); | ||
|
||
// Not supported in fudge | ||
env.pass(Blocks::JumpBySeconds(SECONDS_PER_YEAR)); | ||
|
||
let after = env.state(|| pallet_timestamp::Pallet::<T>::get()); | ||
|
||
assert_eq!((after - before).into_seconds(), SECONDS_PER_YEAR) | ||
} | ||
|
||
crate::test_for_runtimes!([development, altair, centrifuge], transfer_balance); | ||
Comment on lines
+160
to
+172
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cdamian I need your fudge wisdom on this. What I'm doing with the Do you think we can modify fudge to add this behavior, jumping to a block in the future without computing the intermediate blocks? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for missing this. I don't think that will be feasible given our |
||
crate::test_for_runtimes!(all, call_api); | ||
crate::test_for_runtimes!(all, fudge_transfer_balance); | ||
crate::test_for_runtimes!(all, fudge_call_api); | ||
crate::test_for_runtimes!(all, pass_time_one_block); |
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.
Nit: