|
@@ -1,9 +1,7 @@
|
|
|
#![cfg(test)]
|
|
|
-
|
|
|
+use super::fixtures::*;
|
|
|
use super::mock::*;
|
|
|
-use crate::sp_api_hidden_includes_decl_storage::hidden_include::traits::Currency;
|
|
|
use crate::*;
|
|
|
-use std::ops::Rem;
|
|
|
|
|
|
fn assert_video_and_channel_existrinsics_with(result: DispatchResult) {
|
|
|
let params = VideoCreationParametersRecord {
|
|
@@ -27,12 +25,13 @@ fn assert_video_and_channel_existrinsics_with(result: DispatchResult) {
|
|
|
|
|
|
assert_eq!(
|
|
|
Content::create_channel(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
ChannelCreationParametersRecord {
|
|
|
assets: None,
|
|
|
meta: Some(vec![]),
|
|
|
reward_account: None,
|
|
|
+ collaborators: BTreeSet::new(),
|
|
|
},
|
|
|
),
|
|
|
result
|
|
@@ -40,8 +39,8 @@ fn assert_video_and_channel_existrinsics_with(result: DispatchResult) {
|
|
|
|
|
|
assert_eq!(
|
|
|
Content::create_video(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
channel_id.clone(),
|
|
|
params.clone()
|
|
|
),
|
|
@@ -49,22 +48,23 @@ fn assert_video_and_channel_existrinsics_with(result: DispatchResult) {
|
|
|
);
|
|
|
assert_eq!(
|
|
|
Content::update_channel(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
channel_id.clone(),
|
|
|
ChannelUpdateParametersRecord {
|
|
|
assets_to_upload: None,
|
|
|
new_meta: Some(vec![]),
|
|
|
reward_account: None,
|
|
|
assets_to_remove: BTreeSet::new(),
|
|
|
+ collaborators: None,
|
|
|
},
|
|
|
),
|
|
|
result
|
|
|
);
|
|
|
assert_eq!(
|
|
|
Content::update_video(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
video_id.clone(),
|
|
|
VideoUpdateParametersRecord {
|
|
|
assets_to_upload: None,
|
|
@@ -77,8 +77,8 @@ fn assert_video_and_channel_existrinsics_with(result: DispatchResult) {
|
|
|
|
|
|
assert_eq!(
|
|
|
Content::update_channel_censorship_status(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
channel_id.clone(),
|
|
|
false,
|
|
|
b"test".to_vec()
|
|
@@ -88,8 +88,8 @@ fn assert_video_and_channel_existrinsics_with(result: DispatchResult) {
|
|
|
|
|
|
assert_eq!(
|
|
|
Content::update_video_censorship_status(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
video_id.clone(),
|
|
|
false,
|
|
|
b"test".to_vec()
|
|
@@ -99,8 +99,8 @@ fn assert_video_and_channel_existrinsics_with(result: DispatchResult) {
|
|
|
|
|
|
assert_eq!(
|
|
|
Content::delete_video(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
video_id.clone(),
|
|
|
BTreeSet::new(),
|
|
|
),
|
|
@@ -108,8 +108,8 @@ fn assert_video_and_channel_existrinsics_with(result: DispatchResult) {
|
|
|
);
|
|
|
assert_eq!(
|
|
|
Content::delete_channel(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
channel_id.clone(),
|
|
|
0u64,
|
|
|
),
|
|
@@ -117,58 +117,6 @@ fn assert_video_and_channel_existrinsics_with(result: DispatchResult) {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-fn setup_scenario_with(n_videos: u64, n_channels: u64) -> (u64, u64) {
|
|
|
- let _ = balances::Module::<Test>::deposit_creating(
|
|
|
- &FIRST_MEMBER_ORIGIN,
|
|
|
- <Test as balances::Trait>::Balance::from(10_000u32),
|
|
|
- );
|
|
|
-
|
|
|
- // create n_channels channels
|
|
|
- for _ in 0..n_channels {
|
|
|
- create_channel_mock(
|
|
|
- FIRST_MEMBER_ORIGIN,
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
- ChannelCreationParametersRecord {
|
|
|
- assets: None,
|
|
|
- meta: Some(vec![]),
|
|
|
- reward_account: None,
|
|
|
- },
|
|
|
- Ok(()),
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- let params = VideoCreationParametersRecord {
|
|
|
- assets: None,
|
|
|
- meta: None,
|
|
|
- };
|
|
|
-
|
|
|
- // create n_videos videos
|
|
|
- for i in 0..n_videos {
|
|
|
- create_video_mock(
|
|
|
- FIRST_MEMBER_ORIGIN,
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
- i.rem(n_channels) + 1,
|
|
|
- params.clone(),
|
|
|
- Ok(()),
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- // assert that the specified channels have been created
|
|
|
- assert_eq!(VideoById::<Test>::iter().count() as u64, n_videos);
|
|
|
- assert_eq!(ChannelById::<Test>::iter().count() as u64, n_channels);
|
|
|
-
|
|
|
- let channels_migrations_per_block = <Test as Trait>::ChannelsMigrationsEachBlock::get();
|
|
|
- let videos_migrations_per_block = <Test as Trait>::VideosMigrationsEachBlock::get();
|
|
|
-
|
|
|
- // return the number of blocks required for migration
|
|
|
- let divide_with_ceiling =
|
|
|
- |x: u64, y: u64| (x / y) + ((x.checked_rem(y).unwrap_or_default() > 0u64) as u64);
|
|
|
- (
|
|
|
- divide_with_ceiling(n_channels, channels_migrations_per_block),
|
|
|
- divide_with_ceiling(n_videos, videos_migrations_per_block),
|
|
|
- )
|
|
|
-}
|
|
|
-
|
|
|
#[test]
|
|
|
fn migration_test() {
|
|
|
with_default_mock_builder(|| {
|
|
@@ -176,7 +124,10 @@ fn migration_test() {
|
|
|
run_to_block(START_MIGRATION_AT_BLOCK);
|
|
|
|
|
|
// setup scenario
|
|
|
- let (blocks_channels, blocks_videos) = setup_scenario_with(100u64, 100u64);
|
|
|
+ increase_account_balance_helper(DEFAULT_MEMBER_ACCOUNT_ID, INITIAL_BALANCE);
|
|
|
+ create_initial_storage_buckets_helper();
|
|
|
+ let (blocks_channels, blocks_videos) =
|
|
|
+ create_default_member_owned_channels_with_videos(NUMBER_OF_CHANNELS_VIDEOS);
|
|
|
|
|
|
// block at which all migrations should be completed
|
|
|
let last_migration_block = std::cmp::max(blocks_channels, blocks_videos);
|