|
@@ -1,5 +1,8 @@
|
|
|
#![cfg(test)]
|
|
|
-
|
|
|
+use crate::tests::fixtures::{
|
|
|
+ create_default_member_owned_channel_with_video, create_initial_storage_buckets_helper,
|
|
|
+ increase_account_balance_helper,
|
|
|
+};
|
|
|
use crate::tests::mock::*;
|
|
|
use crate::*;
|
|
|
use frame_support::{assert_err, assert_ok};
|
|
@@ -12,7 +15,9 @@ fn issue_nft() {
|
|
|
|
|
|
let video_id = NextVideoId::<Test>::get();
|
|
|
|
|
|
- create_simple_channel_and_video(FIRST_MEMBER_ORIGIN, FIRST_MEMBER_ID);
|
|
|
+ create_initial_storage_buckets_helper();
|
|
|
+ increase_account_balance_helper(DEFAULT_MEMBER_ACCOUNT_ID, INITIAL_BALANCE);
|
|
|
+ create_default_member_owned_channel_with_video();
|
|
|
|
|
|
// Video does not have an nft
|
|
|
assert_eq!(None, Content::video_by_id(video_id).nft_status);
|
|
@@ -24,8 +29,8 @@ fn issue_nft() {
|
|
|
|
|
|
// Issue nft
|
|
|
assert_ok!(Content::issue_nft(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
video_id,
|
|
|
None,
|
|
|
b"metablob".to_vec(),
|
|
@@ -38,16 +43,17 @@ fn issue_nft() {
|
|
|
let nft_status = Some(OwnedNFT::new(NFTOwner::ChannelOwner, None));
|
|
|
assert_eq!(nft_status, Content::video_by_id(video_id).nft_status);
|
|
|
|
|
|
- let nft_issued_event = get_test_event(RawEvent::NftIssued(
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
- video_id,
|
|
|
- None,
|
|
|
- b"metablob".to_vec(),
|
|
|
- None,
|
|
|
- ));
|
|
|
-
|
|
|
// Last event checked
|
|
|
- assert_event(nft_issued_event, number_of_events_before_call + 1);
|
|
|
+ assert_event(
|
|
|
+ MetaEvent::content(RawEvent::NftIssued(
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
+ video_id,
|
|
|
+ None,
|
|
|
+ b"metablob".to_vec(),
|
|
|
+ None,
|
|
|
+ )),
|
|
|
+ number_of_events_before_call + 1,
|
|
|
+ );
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -61,8 +67,8 @@ fn issue_nft_video_does_not_exist() {
|
|
|
|
|
|
// Make an attempt to issue nft for non existent video
|
|
|
let issue_nft_result = Content::issue_nft(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
video_id,
|
|
|
None,
|
|
|
b"metablob".to_vec(),
|
|
@@ -82,12 +88,14 @@ fn issue_nft_already_issued() {
|
|
|
|
|
|
let video_id = NextVideoId::<Test>::get();
|
|
|
|
|
|
- create_simple_channel_and_video(FIRST_MEMBER_ORIGIN, FIRST_MEMBER_ID);
|
|
|
+ create_initial_storage_buckets_helper();
|
|
|
+ increase_account_balance_helper(DEFAULT_MEMBER_ACCOUNT_ID, INITIAL_BALANCE);
|
|
|
+ create_default_member_owned_channel_with_video();
|
|
|
|
|
|
// Issue nft
|
|
|
assert_ok!(Content::issue_nft(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
video_id,
|
|
|
None,
|
|
|
b"metablob".to_vec(),
|
|
@@ -96,8 +104,8 @@ fn issue_nft_already_issued() {
|
|
|
|
|
|
// Make an attempt to issue nft once again for the same video
|
|
|
let issue_nft_result = Content::issue_nft(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
video_id,
|
|
|
None,
|
|
|
b"metablob".to_vec(),
|
|
@@ -117,12 +125,14 @@ fn issue_nft_auth_failed() {
|
|
|
|
|
|
let video_id = NextVideoId::<Test>::get();
|
|
|
|
|
|
- create_simple_channel_and_video(FIRST_MEMBER_ORIGIN, FIRST_MEMBER_ID);
|
|
|
+ create_initial_storage_buckets_helper();
|
|
|
+ increase_account_balance_helper(DEFAULT_MEMBER_ACCOUNT_ID, INITIAL_BALANCE);
|
|
|
+ create_default_member_owned_channel_with_video();
|
|
|
|
|
|
// Make an attempt to issue nft with wrong credentials
|
|
|
let issue_nft_result = Content::issue_nft(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(UNKNOWN_ID),
|
|
|
+ Origin::signed(UNAUTHORIZED_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
video_id,
|
|
|
None,
|
|
|
b"metablob".to_vec(),
|
|
@@ -142,12 +152,14 @@ fn issue_nft_actor_not_authorized() {
|
|
|
|
|
|
let video_id = NextVideoId::<Test>::get();
|
|
|
|
|
|
- create_simple_channel_and_video(FIRST_MEMBER_ORIGIN, FIRST_MEMBER_ID);
|
|
|
+ create_initial_storage_buckets_helper();
|
|
|
+ increase_account_balance_helper(DEFAULT_MEMBER_ACCOUNT_ID, INITIAL_BALANCE);
|
|
|
+ create_default_member_owned_channel_with_video();
|
|
|
|
|
|
// Make an attempt to issue nft if actor is not authorized
|
|
|
let issue_nft_result = Content::issue_nft(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(SECOND_MEMBER_ID),
|
|
|
+ Origin::signed(UNAUTHORIZED_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(UNAUTHORIZED_MEMBER_ID),
|
|
|
video_id,
|
|
|
None,
|
|
|
b"metablob".to_vec(),
|
|
@@ -167,12 +179,14 @@ fn issue_nft_royalty_bounds_violated() {
|
|
|
|
|
|
let video_id = NextVideoId::<Test>::get();
|
|
|
|
|
|
- create_simple_channel_and_video(FIRST_MEMBER_ORIGIN, FIRST_MEMBER_ID);
|
|
|
+ create_initial_storage_buckets_helper();
|
|
|
+ increase_account_balance_helper(DEFAULT_MEMBER_ACCOUNT_ID, INITIAL_BALANCE);
|
|
|
+ create_default_member_owned_channel_with_video();
|
|
|
|
|
|
// Make an attempt to issue nft with wrong credentials
|
|
|
let issue_nft_result = Content::issue_nft(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
video_id,
|
|
|
Some(Perbill::one()),
|
|
|
b"metablob".to_vec(),
|
|
@@ -184,8 +198,8 @@ fn issue_nft_royalty_bounds_violated() {
|
|
|
|
|
|
// Make an attempt to issue nft with wrong credentials
|
|
|
let issue_nft_result = Content::issue_nft(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
video_id,
|
|
|
Some(Perbill::from_perthousand(1)),
|
|
|
b"metablob".to_vec(),
|