-
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
Conversation
I assume we want to get this in before the .43 update so we'll have to eventually get these changes in that branch. |
Yes, and later, my idea is to create another "branch" where I update this over 9.43 before I leave and alleviate you from issues here. But I'm not sure if I'll get time! |
e3842cc
to
573a2d7
Compare
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) | ||
} | ||
|
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.
@cdamian I need your fudge wisdom on this.
What I'm doing with the JumpBySeconds
in the RuntimeEnv
is jumping to a block in the future where it has passed SECONDS_PER_YEAR
. This works quite well to "emulate" a state in the future, only creating one block. It's not as accurate as passing all blocks equivalent to a year, but it's much much faster and unlocks these tests for CI.
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 comment
The 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 evolve
logic, but I'm still lacking knowledge on the topic. @mustermeiszer Might know more.
573a2d7
to
83a5095
Compare
Thanks for the approval @cdamian! |
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.
Shoot, I am a bit too late. Luckily, I only had non-blocking nitpicks. Great work @luis! Thanks so much for the README, it really helps!
|
||
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. |
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:
- `FudgeEnv`: Advanced environment that use a client and connect the runtime to a relay chain. | |
- `FudgeEnv`: Advanced environment that uses a client and connects the runtime to a relay chain. |
- `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 comment
The reason will be displayed to describe this comment to others. Learn more.
Nit
Both environment uses the same interface so jumping from one to the another should be something "smooth". | |
Both environment use the same interface, so jumping from one to the another should be somewhat "smooth". |
|
||
Both environment uses the same interface so jumping from one to the another should be something "smooth". | ||
|
||
## Where I start? |
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
## Where I start? | |
## Where do I start? |
@@ -42,112 +47,323 @@ use crate::{ | |||
const POOL_ADMIN: Keyring = Keyring::Admin; | |||
const INVESTOR: Keyring = Keyring::Alice; | |||
const BORROWER: Keyring = Keyring::Bob; | |||
const LOAN_ADMIN: Keyring = Keyring::Charlie; | |||
const ANY: Keyring = Keyring::Dave; |
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: We should make it clear this refers to a substrate address
const ANY: Keyring = Keyring::Dave; | |
const ANYONE: Keyring = Keyring::Dave; |
Written down as doc-debt! 😆 |
Fixes #1458 #1375
Changes and Descriptions
generic/src/cases/loans.rs
):Check all kind of mutations based on different restriction.This is blocked since there is no way to pass one week without burning the computer during 15-minute computing blocks.BySeconds
Block::JumpBySeconds
see comment