11#![ cfg( test) ]
2+ use crate :: tests:: curators;
23use crate :: tests:: fixtures:: {
34 create_default_member_owned_channel_with_video, create_initial_storage_buckets_helper,
4- increase_account_balance_helper, UpdateChannelFixture ,
5+ increase_account_balance_helper, CreateChannelFixture , CreateVideoFixture ,
56} ;
67use crate :: tests:: mock:: * ;
78use crate :: * ;
@@ -180,45 +181,50 @@ fn accept_incoming_offer_no_incoming_offers() {
180181}
181182
182183#[ test]
183- fn accept_incoming_offer_reward_account_is_not_set_succeeds_with_member_owner_channel ( ) {
184+ fn accept_incoming_offer_ok_with_reward_account_not_set_succeeds_with_member_owner_channel ( ) {
185+ let video_id = 1u64 ;
184186 with_default_mock_builder ( || {
185187 // Run to block one to see emitted events
186188 run_to_block ( 1 ) ;
187-
188- let video_id = NextVideoId :: < Test > :: get ( ) ;
189- create_initial_storage_buckets_helper ( ) ;
190- increase_account_balance_helper ( DEFAULT_MEMBER_ACCOUNT_ID , INITIAL_BALANCE ) ;
191- create_default_member_owned_channel_with_video ( ) ;
192-
193- UpdateChannelFixture :: default ( )
189+ // channel with no reward account
190+ CreateChannelFixture :: default ( )
191+ . with_sender ( DEFAULT_MEMBER_ACCOUNT_ID )
192+ . with_actor ( ContentActor :: Member ( DEFAULT_MEMBER_ID ) )
193+ . call ( ) ;
194+ CreateVideoFixture :: default ( )
194195 . with_sender ( DEFAULT_MEMBER_ACCOUNT_ID )
195196 . with_actor ( ContentActor :: Member ( DEFAULT_MEMBER_ID ) )
196- . with_reward_account ( Some ( None ) )
197- . call_and_assert ( Ok ( ( ) ) ) ;
197+ . call ( ) ;
198198
199- // Issue nft
200199 assert_ok ! ( Content :: issue_nft(
201200 Origin :: signed( DEFAULT_MEMBER_ACCOUNT_ID ) ,
202201 ContentActor :: Member ( DEFAULT_MEMBER_ID ) ,
203202 video_id,
204203 NftIssuanceParameters :: <Test >:: default ( ) ,
205204 ) ) ;
206205
206+ increase_account_balance_helper ( SECOND_MEMBER_ACCOUNT_ID , DEFAULT_NFT_PRICE ) ;
207+
207208 // Offer nft
208209 assert_ok ! ( Content :: offer_nft(
209210 Origin :: signed( DEFAULT_MEMBER_ACCOUNT_ID ) ,
210211 video_id,
211212 ContentActor :: Member ( DEFAULT_MEMBER_ID ) ,
212213 SECOND_MEMBER_ID ,
213- None ,
214+ Some ( 100u64 ) , // price
214215 ) ) ;
215216
216217 // Make an attempt to accept incoming nft offer if sender is owner and reward account is not set
217- let accept_incoming_offer_result =
218- Content :: accept_incoming_offer ( Origin :: signed ( SECOND_MEMBER_ACCOUNT_ID ) , video_id) ;
218+ assert_ok ! ( Content :: accept_incoming_offer(
219+ Origin :: signed( SECOND_MEMBER_ACCOUNT_ID ) ,
220+ video_id
221+ ) ) ;
219222
220- // Failure checked
221- assert_ok ! ( accept_incoming_offer_result, ) ;
223+ // check owner balance increased by net profit
224+ assert_eq ! (
225+ Balances :: <Test >:: usable_balance( DEFAULT_MEMBER_ACCOUNT_ID ) ,
226+ 100u64 - ( Content :: platform_fee_percentage( ) * 100u64 )
227+ ) ;
222228 } )
223229}
224230
@@ -228,31 +234,31 @@ fn accept_incoming_offer_reward_account_burns_token_with_curator_owner_channel()
228234 // Run to block one to see emitted events
229235 run_to_block ( 1 ) ;
230236
231- let video_id = NextVideoId :: < Test > :: get ( ) ;
232- create_initial_storage_buckets_helper ( ) ;
233- increase_account_balance_helper ( DEFAULT_MEMBER_ACCOUNT_ID , INITIAL_BALANCE ) ;
234- increase_account_balance_helper ( SECOND_MEMBER_ACCOUNT_ID , DEFAULT_NFT_PRICE ) ;
235- create_default_member_owned_channel_with_video ( ) ;
237+ let curator_group_id = curators:: add_curator_to_new_group ( DEFAULT_CURATOR_ID ) ;
238+ let video_id = Content :: next_video_id ( ) ;
239+ let curator_actor = ContentActor :: Curator ( curator_group_id, DEFAULT_CURATOR_ID ) ;
240+ CreateChannelFixture :: default ( )
241+ . with_sender ( DEFAULT_CURATOR_ACCOUNT_ID )
242+ . with_actor ( curator_actor)
243+ . call ( ) ;
244+ CreateVideoFixture :: default ( )
245+ . with_sender ( DEFAULT_CURATOR_ACCOUNT_ID )
246+ . with_actor ( ContentActor :: Curator ( curator_group_id, DEFAULT_CURATOR_ID ) )
247+ . call ( ) ;
236248
237- UpdateChannelFixture :: default ( )
238- . with_sender ( DEFAULT_MEMBER_ACCOUNT_ID )
239- . with_actor ( ContentActor :: Member ( DEFAULT_MEMBER_ID ) )
240- . with_reward_account ( Some ( None ) )
241- . call_and_assert ( Ok ( ( ) ) ) ;
242-
243- // Issue nft
244249 assert_ok ! ( Content :: issue_nft(
245- Origin :: signed( DEFAULT_MEMBER_ACCOUNT_ID ) ,
246- ContentActor :: Member ( DEFAULT_MEMBER_ID ) ,
250+ Origin :: signed( DEFAULT_CURATOR_ACCOUNT_ID ) ,
251+ curator_actor ,
247252 video_id,
248253 NftIssuanceParameters :: <Test >:: default ( ) ,
249254 ) ) ;
250255
256+ increase_account_balance_helper ( SECOND_MEMBER_ACCOUNT_ID , DEFAULT_NFT_PRICE ) ;
251257 // Offer nft
252258 assert_ok ! ( Content :: offer_nft(
253- Origin :: signed( DEFAULT_MEMBER_ACCOUNT_ID ) ,
259+ Origin :: signed( DEFAULT_CURATOR_ACCOUNT_ID ) ,
254260 video_id,
255- ContentActor :: Member ( DEFAULT_MEMBER_ID ) ,
261+ curator_actor ,
256262 SECOND_MEMBER_ID ,
257263 Some ( DEFAULT_NFT_PRICE ) ,
258264 ) ) ;
0 commit comments