@@ -22,11 +22,11 @@ use tower_http::cors::CorsLayer;
22
22
use adapter:: { client:: Locked , Adapter , Dummy , Ethereum } ;
23
23
use primitives:: {
24
24
config:: Environment , sentry:: campaign_create:: CreateCampaign , test_util:: CAMPAIGNS ,
25
- unified_num:: FromWhole , Campaign , ChainOf , Deposit , UnifiedNum , ValidatorId ,
25
+ unified_num:: FromWhole , Campaign , ChainOf , Deposit , UnifiedNum , ValidatorId , spender :: Spendable ,
26
26
} ;
27
27
28
28
use crate :: {
29
- db:: { CampaignRemaining , DbPool } ,
29
+ db:: { CampaignRemaining , DbPool , campaign :: insert_campaign , insert_channel , spendable :: insert_spendable } ,
30
30
middleware:: auth:: authenticate,
31
31
platform:: PlatformApi ,
32
32
routes:: {
@@ -393,48 +393,21 @@ pub async fn seed_ethereum(app: Application<Ethereum>) -> Result<(), Box<dyn std
393
393
app : Application < Ethereum > ,
394
394
campaign : & ChainOf < Campaign > ,
395
395
) -> Result < ( ) , Box < dyn std:: error:: Error > > {
396
- let campaign_to_create = CreateCampaign :: from_campaign ( campaign. context . clone ( ) ) ;
397
- let auth = Auth {
398
- era : 0 ,
399
- uid : ValidatorId :: from ( campaign_to_create. creator ) ,
400
- chain : campaign. chain . clone ( ) ,
401
- } ;
402
- let _result = create_campaign (
403
- Json ( campaign_to_create) ,
404
- Extension ( auth) ,
405
- Extension ( Arc :: new ( app) ) ,
406
- )
407
- . await
408
- . expect ( "Should create seed campaigns" ) ;
409
- Ok ( ( ) )
410
- }
411
- async fn deposit (
412
- app : Application < Ethereum > ,
413
- campaign : & ChainOf < Campaign > ,
414
- ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
415
- let channel = campaign. context . channel ;
416
- let auth = Auth {
417
- era : 0 ,
418
- uid : ValidatorId :: from ( campaign. context . creator ) ,
419
- chain : campaign. chain . clone ( ) ,
420
- } ;
421
- let request = ChannelDummyDeposit {
422
- channel,
396
+ let channel_context = ChainOf :: of_channel ( & campaign) ;
397
+
398
+ let spendable = Spendable {
399
+ spender : campaign. context . creator ,
400
+ channel : campaign. context . channel ,
423
401
deposit : Deposit {
424
- total : UnifiedNum :: from_whole ( 1_000_000 ) ,
425
- } ,
402
+ total : UnifiedNum :: from_u64 ( 10_000_000 ) ,
403
+ }
426
404
} ;
427
- let result =
428
- channel_dummy_deposit ( Extension ( Arc :: new ( app) ) , Extension ( auth) , Json ( request) ) . await ;
429
- assert ! ( result. is_ok( ) ) ;
405
+ insert_channel ( & app. pool , & channel_context) . await . expect ( "Should insert channel of seed campaign" ) ;
406
+ insert_campaign ( & app. pool , & campaign. context ) . await . expect ( "Should insert seed campaign" ) ;
407
+ insert_spendable ( app. pool . clone ( ) , & spendable) . await . expect ( "Should insert spendable for campaign creator" ) ;
408
+
430
409
Ok ( ( ) )
431
410
}
432
- // chain 1337
433
- deposit ( app. clone ( ) , & campaign_1) . await ?;
434
- // chain 1337
435
- deposit ( app. clone ( ) , & campaign_2) . await ?;
436
- // chain 1
437
- deposit ( app. clone ( ) , & campaign_3) . await ?;
438
411
439
412
create_seed_campaign ( app. clone ( ) , & campaign_1) . await ?;
440
413
create_seed_campaign ( app. clone ( ) , & campaign_2) . await ?;
0 commit comments