|
@@ -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,12 +15,14 @@ fn offer_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();
|
|
|
|
|
|
// 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(),
|
|
@@ -31,9 +36,9 @@ fn offer_nft() {
|
|
|
|
|
|
// Offer nft
|
|
|
assert_ok!(Content::offer_nft(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
video_id,
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
SECOND_MEMBER_ID,
|
|
|
None,
|
|
|
));
|
|
@@ -52,15 +57,16 @@ fn offer_nft() {
|
|
|
})
|
|
|
));
|
|
|
|
|
|
- let offer_started_event = get_test_event(RawEvent::OfferStarted(
|
|
|
- video_id,
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
- SECOND_MEMBER_ID,
|
|
|
- None,
|
|
|
- ));
|
|
|
-
|
|
|
// Last event checked
|
|
|
- assert_event(offer_started_event, number_of_events_before_call + 1);
|
|
|
+ assert_event(
|
|
|
+ MetaEvent::content(RawEvent::OfferStarted(
|
|
|
+ video_id,
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
+ SECOND_MEMBER_ID,
|
|
|
+ None,
|
|
|
+ )),
|
|
|
+ number_of_events_before_call + 1,
|
|
|
+ );
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -74,9 +80,9 @@ fn offer_nft_video_does_not_exist() {
|
|
|
|
|
|
// Make an attempt to offer nft which corresponding video does not exist
|
|
|
let offer_nft_result = Content::offer_nft(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
video_id,
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
SECOND_MEMBER_ID,
|
|
|
None,
|
|
|
);
|
|
@@ -94,13 +100,15 @@ fn offer_nft_not_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();
|
|
|
|
|
|
// Make an attempt to offer nft which is not issued yet
|
|
|
let offer_nft_result = Content::offer_nft(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
video_id,
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
SECOND_MEMBER_ID,
|
|
|
None,
|
|
|
);
|
|
@@ -118,12 +126,14 @@ fn offer_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();
|
|
|
|
|
|
// 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(),
|
|
@@ -132,9 +142,9 @@ fn offer_nft_auth_failed() {
|
|
|
|
|
|
// Make an attempt to offer nft with wrong credentials
|
|
|
let offer_nft_result = Content::offer_nft(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
+ Origin::signed(UNAUTHORIZED_MEMBER_ACCOUNT_ID),
|
|
|
video_id,
|
|
|
- ContentActor::Member(UNKNOWN_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
SECOND_MEMBER_ID,
|
|
|
None,
|
|
|
);
|
|
@@ -152,12 +162,14 @@ fn offer_nft_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();
|
|
|
|
|
|
// 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(),
|
|
@@ -166,10 +178,10 @@ fn offer_nft_not_authorized() {
|
|
|
|
|
|
// Make an attempt to offer nft if actor is not authorized
|
|
|
let offer_nft_result = Content::offer_nft(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
+ Origin::signed(UNAUTHORIZED_MEMBER_ACCOUNT_ID),
|
|
|
video_id,
|
|
|
- ContentActor::Member(SECOND_MEMBER_ID),
|
|
|
- SECOND_MEMBER_ID,
|
|
|
+ ContentActor::Member(UNAUTHORIZED_MEMBER_ID),
|
|
|
+ UNAUTHORIZED_MEMBER_ID,
|
|
|
None,
|
|
|
);
|
|
|
|
|
@@ -186,12 +198,14 @@ fn offer_nft_transactional_status_is_not_idle() {
|
|
|
|
|
|
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(),
|
|
@@ -200,18 +214,18 @@ fn offer_nft_transactional_status_is_not_idle() {
|
|
|
|
|
|
// Offer nft
|
|
|
assert_ok!(Content::offer_nft(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
video_id,
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
SECOND_MEMBER_ID,
|
|
|
None,
|
|
|
));
|
|
|
|
|
|
// Make an attempt to offer nft when it is already offered
|
|
|
let offer_nft_result = Content::offer_nft(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
video_id,
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
SECOND_MEMBER_ID,
|
|
|
None,
|
|
|
);
|