|
@@ -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 pick_open_auction_winner() {
|
|
|
|
|
|
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(),
|
|
@@ -37,8 +42,8 @@ fn pick_open_auction_winner() {
|
|
|
|
|
|
// Start nft auction
|
|
|
assert_ok!(Content::start_nft_auction(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
video_id,
|
|
|
auction_params.clone(),
|
|
|
));
|
|
@@ -46,11 +51,11 @@ fn pick_open_auction_winner() {
|
|
|
// deposit initial balance
|
|
|
let bid = Content::min_starting_price();
|
|
|
|
|
|
- let _ = balances::Module::<Test>::deposit_creating(&SECOND_MEMBER_ORIGIN, bid);
|
|
|
+ let _ = balances::Module::<Test>::deposit_creating(&SECOND_MEMBER_ACCOUNT_ID, bid);
|
|
|
|
|
|
// Make nft auction bid
|
|
|
assert_ok!(Content::make_bid(
|
|
|
- Origin::signed(SECOND_MEMBER_ORIGIN),
|
|
|
+ Origin::signed(SECOND_MEMBER_ACCOUNT_ID),
|
|
|
SECOND_MEMBER_ID,
|
|
|
video_id,
|
|
|
bid,
|
|
@@ -63,8 +68,8 @@ fn pick_open_auction_winner() {
|
|
|
|
|
|
// Pick open auction winner
|
|
|
assert_ok!(Content::pick_open_auction_winner(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
video_id,
|
|
|
));
|
|
|
|
|
@@ -79,15 +84,13 @@ fn pick_open_auction_winner() {
|
|
|
})
|
|
|
));
|
|
|
|
|
|
- let pick_open_auction_winner_event = get_test_event(RawEvent::OpenAuctionBidAccepted(
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
- video_id,
|
|
|
- ));
|
|
|
-
|
|
|
// Last event checked
|
|
|
assert_event(
|
|
|
- pick_open_auction_winner_event,
|
|
|
- number_of_events_before_call + 3,
|
|
|
+ MetaEvent::content(RawEvent::OpenAuctionBidAccepted(
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
+ video_id,
|
|
|
+ )),
|
|
|
+ number_of_events_before_call + 1,
|
|
|
);
|
|
|
})
|
|
|
}
|
|
@@ -100,12 +103,14 @@ fn pick_open_auction_winner_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(),
|
|
@@ -125,8 +130,8 @@ fn pick_open_auction_winner_auth_failed() {
|
|
|
|
|
|
// Start nft auction
|
|
|
assert_ok!(Content::start_nft_auction(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
video_id,
|
|
|
auction_params.clone(),
|
|
|
));
|
|
@@ -134,11 +139,11 @@ fn pick_open_auction_winner_auth_failed() {
|
|
|
// deposit initial balance
|
|
|
let bid = Content::min_starting_price();
|
|
|
|
|
|
- let _ = balances::Module::<Test>::deposit_creating(&SECOND_MEMBER_ORIGIN, bid);
|
|
|
+ let _ = balances::Module::<Test>::deposit_creating(&SECOND_MEMBER_ACCOUNT_ID, bid);
|
|
|
|
|
|
// Make nft auction bid
|
|
|
assert_ok!(Content::make_bid(
|
|
|
- Origin::signed(SECOND_MEMBER_ORIGIN),
|
|
|
+ Origin::signed(SECOND_MEMBER_ACCOUNT_ID),
|
|
|
SECOND_MEMBER_ID,
|
|
|
video_id,
|
|
|
bid,
|
|
@@ -149,8 +154,8 @@ fn pick_open_auction_winner_auth_failed() {
|
|
|
|
|
|
// Make an attempt to pick open auction winner with wrong credentials
|
|
|
let pick_open_auction_winner_result = Content::pick_open_auction_winner(
|
|
|
- Origin::signed(SECOND_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(UNKNOWN_ID),
|
|
|
+ Origin::signed(UNAUTHORIZED_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(SECOND_MEMBER_ID),
|
|
|
video_id,
|
|
|
);
|
|
|
|
|
@@ -170,12 +175,14 @@ fn pick_open_auction_winner_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();
|
|
|
|
|
|
// 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(),
|
|
@@ -195,8 +202,8 @@ fn pick_open_auction_winner_actor_not_authorized() {
|
|
|
|
|
|
// Start nft auction
|
|
|
assert_ok!(Content::start_nft_auction(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
video_id,
|
|
|
auction_params.clone(),
|
|
|
));
|
|
@@ -204,11 +211,11 @@ fn pick_open_auction_winner_actor_not_authorized() {
|
|
|
// deposit initial balance
|
|
|
let bid = Content::min_starting_price();
|
|
|
|
|
|
- let _ = balances::Module::<Test>::deposit_creating(&SECOND_MEMBER_ORIGIN, bid);
|
|
|
+ let _ = balances::Module::<Test>::deposit_creating(&SECOND_MEMBER_ACCOUNT_ID, bid);
|
|
|
|
|
|
// Make nft auction bid
|
|
|
assert_ok!(Content::make_bid(
|
|
|
- Origin::signed(SECOND_MEMBER_ORIGIN),
|
|
|
+ Origin::signed(SECOND_MEMBER_ACCOUNT_ID),
|
|
|
SECOND_MEMBER_ID,
|
|
|
video_id,
|
|
|
bid,
|
|
@@ -219,7 +226,7 @@ fn pick_open_auction_winner_actor_not_authorized() {
|
|
|
|
|
|
// Make an attempt to pick open auction winner if actor is not authorized to do this
|
|
|
let pick_open_auction_winner_result = Content::pick_open_auction_winner(
|
|
|
- Origin::signed(SECOND_MEMBER_ORIGIN),
|
|
|
+ Origin::signed(SECOND_MEMBER_ACCOUNT_ID),
|
|
|
ContentActor::Member(SECOND_MEMBER_ID),
|
|
|
video_id,
|
|
|
);
|
|
@@ -242,7 +249,7 @@ fn pick_open_auction_winner_video_does_not_exist() {
|
|
|
|
|
|
// Make an attempt to pick open auction winner which corresponding video does not exist
|
|
|
let pick_open_auction_winner_result = Content::pick_open_auction_winner(
|
|
|
- Origin::signed(SECOND_MEMBER_ORIGIN),
|
|
|
+ Origin::signed(SECOND_MEMBER_ACCOUNT_ID),
|
|
|
ContentActor::Member(SECOND_MEMBER_ID),
|
|
|
video_id,
|
|
|
);
|
|
@@ -263,11 +270,13 @@ fn pick_open_auction_winner_nft_is_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 pick open auction winner for nft which is not issued yet
|
|
|
let pick_open_auction_winner_result = Content::pick_open_auction_winner(
|
|
|
- Origin::signed(SECOND_MEMBER_ORIGIN),
|
|
|
+ Origin::signed(SECOND_MEMBER_ACCOUNT_ID),
|
|
|
ContentActor::Member(SECOND_MEMBER_ID),
|
|
|
video_id,
|
|
|
);
|
|
@@ -288,12 +297,14 @@ fn pick_open_auction_winner_not_in_auction_state() {
|
|
|
|
|
|
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(),
|
|
@@ -302,8 +313,8 @@ fn pick_open_auction_winner_not_in_auction_state() {
|
|
|
|
|
|
// Make an attempt to pick open auction winner for nft which is not in auction state
|
|
|
let pick_open_auction_winner_result = Content::pick_open_auction_winner(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
video_id,
|
|
|
);
|
|
|
|
|
@@ -323,12 +334,14 @@ fn pick_open_auction_winner_is_not_open_auction_type() {
|
|
|
|
|
|
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(),
|
|
@@ -349,8 +362,8 @@ fn pick_open_auction_winner_is_not_open_auction_type() {
|
|
|
|
|
|
// Start nft auction
|
|
|
assert_ok!(Content::start_nft_auction(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
video_id,
|
|
|
auction_params.clone(),
|
|
|
));
|
|
@@ -358,11 +371,11 @@ fn pick_open_auction_winner_is_not_open_auction_type() {
|
|
|
// deposit initial balance
|
|
|
let bid = Content::min_starting_price();
|
|
|
|
|
|
- let _ = balances::Module::<Test>::deposit_creating(&SECOND_MEMBER_ORIGIN, bid);
|
|
|
+ let _ = balances::Module::<Test>::deposit_creating(&SECOND_MEMBER_ACCOUNT_ID, bid);
|
|
|
|
|
|
// Make nft auction bid
|
|
|
assert_ok!(Content::make_bid(
|
|
|
- Origin::signed(SECOND_MEMBER_ORIGIN),
|
|
|
+ Origin::signed(SECOND_MEMBER_ACCOUNT_ID),
|
|
|
SECOND_MEMBER_ID,
|
|
|
video_id,
|
|
|
bid,
|
|
@@ -370,8 +383,8 @@ fn pick_open_auction_winner_is_not_open_auction_type() {
|
|
|
|
|
|
// Make an attempt to pick open auction winner for nft which is in english auction state
|
|
|
let pick_open_auction_winner_result = Content::pick_open_auction_winner(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
video_id,
|
|
|
);
|
|
|
|
|
@@ -391,12 +404,14 @@ fn pick_open_auction_winner_last_bid_does_not_exist() {
|
|
|
|
|
|
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(),
|
|
@@ -416,8 +431,8 @@ fn pick_open_auction_winner_last_bid_does_not_exist() {
|
|
|
|
|
|
// Start nft auction
|
|
|
assert_ok!(Content::start_nft_auction(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
video_id,
|
|
|
auction_params.clone(),
|
|
|
));
|
|
@@ -427,8 +442,8 @@ fn pick_open_auction_winner_last_bid_does_not_exist() {
|
|
|
|
|
|
// Make an attempt to pick open auction winner if last bid does not exist
|
|
|
let pick_open_auction_winner_result = Content::pick_open_auction_winner(
|
|
|
- Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
- ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ ContentActor::Member(DEFAULT_MEMBER_ID),
|
|
|
video_id,
|
|
|
);
|
|
|
|