-
Notifications
You must be signed in to change notification settings - Fork 385
rust runtime integration tests #339
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
Changes from 1 commit
832726b
f179e91
737c0fd
69a32b7
71d5660
1f10d75
97fc054
688a324
b3abf42
f154f50
270ea2d
fbb9852
15aae62
a46d404
481f43d
ca44e43
9e6c7f8
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 |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
|
|
||
| #![cfg(test)] | ||
|
|
||
| use cumulus_primitives_parachain_inherent::ParachainInherentData; | ||
| use frame_support::{ | ||
| assert_noop, assert_ok, | ||
| dispatch::Dispatchable, | ||
|
|
@@ -116,6 +117,10 @@ fn origin_of(account_id: AccountId) -> <Runtime as frame_system::Config>::Origin | |
| <Runtime as frame_system::Config>::Origin::signed(account_id) | ||
| } | ||
|
|
||
| fn inherent_origin() -> <Runtime as frame_system::Config>::Origin { | ||
| <Runtime as frame_system::Config>::Origin::none() | ||
| } | ||
|
|
||
| #[test] | ||
| fn join_collator_candidates() { | ||
| ExtBuilder::default() | ||
|
|
@@ -228,5 +233,69 @@ fn transfer_through_evm_to_stake() { | |
|
|
||
| #[test] | ||
| fn reward_block_authors() { | ||
| assert!(true); | ||
| ExtBuilder::default() | ||
| .balances(vec![ | ||
| (AccountId::from(ALICE), 2_000 * GLMR), | ||
| (AccountId::from(BOB), 1_000 * GLMR), | ||
| ]) | ||
| .staking(vec![ | ||
| // collator | ||
| (AccountId::from(ALICE), None, 1_000 * GLMR), | ||
| // nominators | ||
| ( | ||
| AccountId::from(BOB), | ||
| Some(AccountId::from(ALICE)), | ||
| 500 * GLMR, | ||
| ), | ||
| ]) | ||
| .build() | ||
| .execute_with(|| { | ||
| // set parachain inherent data | ||
| use cumulus_primitives_core::PersistedValidationData; | ||
| use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; | ||
| let sproof_builder = RelayStateSproofBuilder::default(); | ||
| let (relay_parent_storage_root, relay_chain_state) = | ||
| sproof_builder.into_state_root_and_proof(); | ||
| let vfp = PersistedValidationData { | ||
| relay_parent_number: 1u32, | ||
| relay_parent_storage_root, | ||
| ..Default::default() | ||
| }; | ||
| let parachain_inherent_data = ParachainInherentData { | ||
| validation_data: vfp, | ||
| relay_chain_state: relay_chain_state, | ||
| downward_messages: Default::default(), | ||
| horizontal_messages: Default::default(), | ||
| }; | ||
| assert_ok!( | ||
| Call::ParachainSystem(ParachainSystemCall::set_validation_data( | ||
| parachain_inherent_data | ||
| )) | ||
| .dispatch(inherent_origin()) | ||
| ); | ||
| fn set_alice_as_author() { | ||
| assert_ok!( | ||
| Call::AuthorInherent(AuthorInherentCall::set_author(AccountId::from(ALICE))) | ||
| .dispatch(inherent_origin()) | ||
| ); | ||
| } | ||
| for x in 2..1201 { | ||
| set_alice_as_author(); | ||
|
||
| run_to_block(x); | ||
| } | ||
| // no rewards doled out yet | ||
| assert_eq!(Balances::free_balance(AccountId::from(ALICE)), 1_000 * GLMR,); | ||
| assert_eq!(Balances::free_balance(AccountId::from(BOB)), 500 * GLMR,); | ||
| set_alice_as_author(); | ||
| run_to_block(1201); | ||
| // rewards minted and distributed | ||
| assert_eq!( | ||
| Balances::free_balance(AccountId::from(ALICE)), | ||
| 1000010038599992699200, | ||
| ); | ||
| assert_eq!( | ||
| Balances::free_balance(AccountId::from(BOB)), | ||
| 500003650399996349600, | ||
| ); | ||
| }); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.