33using System . Numerics ;
44using System . Threading . Tasks ;
55using NUnit . Framework ;
6+ using PlayFab ;
7+ using PlayFab . ClientModels ;
68using Sequence . Contracts ;
79using Sequence . EmbeddedWallet ;
810using Sequence . EmbeddedWallet . Tests ;
@@ -17,91 +19,161 @@ public class MarketplaceSeeder
1719
1820 // [Test]
1921 [ Timeout ( 1800000 ) ]
20- public async Task SeedMarketplace ( )
22+ public async Task SeedMarketplace_Playfab ( )
2123 {
2224 throw new Exception ( "Please only run this when you need to seed the marketplace for testing as it will create a lot of listings and offers, using a fair amount of gas and credits." ) ;
2325 EndToEndTestHarness testHarness = new EndToEndTestHarness ( ) ;
2426 bool done = false ;
25- testHarness . Login ( async wallet =>
26- {
27- Address collection = new Address ( "0x079294e6ffec16234578c672fa3fbfd4b6c48640" ) ;
28- ERC1155 universallyMintableNft = new ERC1155 ( collection ) ;
29-
30- Address erc20UniversallyMintable = new Address ( "0x88e57238a23e2619fd42f479d546560b44c698fe" ) ;
31- ERC20 universallyMintableToken = new ERC20 ( erc20UniversallyMintable ) ;
32-
33- TransactionReturn mintResult = await wallet . SendTransaction ( _chain , new Transaction [ ]
34- {
35- new RawTransaction ( collection , "0" ,
36- universallyMintableNft . MintBatch ( wallet . GetWalletAddress ( ) , new BigInteger [ ] { 1 , 2 , 3 , 4 , 5 } , new BigInteger [ ] { 100000 , 100000 , 100000 , 100000 , 100000 } ) . CallData ) ,
37- new RawTransaction ( erc20UniversallyMintable , "0" ,
38- universallyMintableToken . Mint ( wallet . GetWalletAddress ( ) , 1000000000000 ) . CallData )
39- } ) ;
40- Assert . IsNotNull ( mintResult ) ;
41- Assert . IsTrue ( mintResult is SuccessfulTransactionReturn ) ;
4227
43- List < Step > finalSteps = new List < Step > ( ) ;
44- Address USDC = new Address ( "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359" ) ;
45- Address [ ] possibleCurrencyAddresses = new Address [ ]
46- { USDC } ;
47- Checkout checkout = new Checkout ( wallet , _chain ) ;
48- for ( int i = 0 ; i < 10 ; i ++ )
28+ WaaSEndToEndTestConfig config = WaaSEndToEndTestConfig . GetConfig ( ) ;
29+
30+ string email = config . PlayFabEmail ;
31+ var request = new LoginWithEmailAddressRequest { Email = email , Password = config . PlayFabPassword } ;
32+ PlayFabClientAPI . LoginWithEmailAddress ( request , result =>
33+ {
34+ testHarness . LoginWithPlayFab ( result , email , async wallet =>
4935 {
50- Step [ ] steps = await checkout . GenerateListingTransaction ( collection , ( i % 5 + 1 ) . ToString ( ) , i + 1 ,
51- ContractType . ERC1155 , possibleCurrencyAddresses . GetRandomObjectFromArray ( ) , 1 ,
52- DateTime . Now + TimeSpan . FromDays ( 365 ) ) ;
53- if ( i % 5 == 3 )
36+ try
5437 {
55- await Task . Delay ( 1000 ) ;
38+ await DoSeedMarketplace ( wallet ) ;
5639 }
57- foreach ( var step in steps )
40+ catch ( Exception e )
5841 {
59- finalSteps . Add ( step ) ;
42+ Assert . Fail ( e . Message ) ;
6043 }
61- }
62-
63- for ( int i = 0 ; i < 10 ; i ++ )
64- {
65- Step [ ] steps = await checkout . GenerateOfferTransaction ( collection , ( i % 5 + 1 ) . ToString ( ) , i + 1 ,
66- ContractType . ERC1155 , possibleCurrencyAddresses . GetRandomObjectFromArray ( ) , 1 ,
67- DateTime . Now + TimeSpan . FromDays ( 365 ) ) ;
68- if ( i % 5 == 3 )
44+ finally
6945 {
70- await Task . Delay ( 1000 ) ;
71- }
72- foreach ( var step in steps )
73- {
74- finalSteps . Add ( step ) ;
46+ done = true ;
7547 }
48+ } , ( error , method , email , methods ) =>
49+ {
50+ Assert . Fail ( error ) ;
51+ done = true ;
52+ } ) ;
53+ } , error =>
54+ {
55+ Assert . Fail ( error . ErrorMessage ) ;
56+ done = true ;
57+ } ) ;
58+
59+
60+ while ( ! done )
61+ {
62+ await Task . Yield ( ) ;
63+ }
64+ }
65+
66+ // [Test]
67+ [ Timeout ( 1800000 ) ]
68+ public async Task SeedMarketplace_Guest ( )
69+ {
70+ throw new Exception ( "Please only run this when you need to seed the marketplace for testing as it will create a lot of listings and offers, using a fair amount of gas and credits." ) ;
71+ EndToEndTestHarness testHarness = new EndToEndTestHarness ( ) ;
72+ bool done = false ;
73+
74+ testHarness . Login ( async wallet =>
75+ {
76+ try
77+ {
78+ await DoSeedMarketplace ( wallet ) ;
7679 }
77-
78- Transaction [ ] transactions = new Transaction [ 10 ] ;
79- for ( int j = 0 ; j < finalSteps . Count ; j += 10 )
80+ catch ( Exception e )
8081 {
81- for ( int i = 0 ; i < 10 ; i ++ )
82- {
83- transactions [ i ] = new RawTransaction ( finalSteps [ j + i ] . to , finalSteps [ j + i ] . value , finalSteps [ j + i ] . data ) ;
84- }
85- TransactionReturn result = await wallet . SendTransaction ( _chain , transactions ) ;
86- Assert . IsNotNull ( result ) ;
87- // Assert.IsTrue(result is SuccessfulTransactionReturn);
88- if ( result is SuccessfulTransactionReturn success )
89- {
90- Debug . Log ( ChainDictionaries . BlockExplorerOf [ _chain ] . AppendTrailingSlashIfNeeded ( ) + "tx/" + success . txHash ) ;
91- // Application.OpenURL(ChainDictionaries.BlockExplorerOf[_chain].AppendTrailingSlashIfNeeded() + "tx/" + success.txHash);
92- }
82+ Assert . Fail ( e . Message ) ;
83+ }
84+ finally
85+ {
86+ done = true ;
9387 }
94-
95- done = true ;
9688 } , ( error , method , email , methods ) =>
9789 {
9890 Assert . Fail ( error ) ;
9991 done = true ;
10092 } ) ;
93+
10194 while ( ! done )
10295 {
10396 await Task . Yield ( ) ;
10497 }
10598 }
99+
100+ private async Task DoSeedMarketplace ( IWallet wallet )
101+ {
102+ Address collection = new Address ( "0x079294e6ffec16234578c672fa3fbfd4b6c48640" ) ;
103+ ERC1155 universallyMintableNft = new ERC1155 ( collection ) ;
104+
105+ Address erc20UniversallyMintable = new Address ( "0x88e57238a23e2619fd42f479d546560b44c698fe" ) ;
106+ ERC20 universallyMintableToken = new ERC20 ( erc20UniversallyMintable ) ;
107+
108+ TransactionReturn mintResult = await wallet . SendTransaction ( _chain , new Transaction [ ]
109+ {
110+ new RawTransaction ( collection , "0" ,
111+ universallyMintableNft . MintBatch ( wallet . GetWalletAddress ( ) ,
112+ new BigInteger [ ] { 1 , 2 , 3 , 4 , 5 } ,
113+ new BigInteger [ ] { 100000 , 100000 , 100000 , 100000 , 100000 } ) . CallData ) ,
114+ new RawTransaction ( erc20UniversallyMintable , "0" ,
115+ universallyMintableToken . Mint ( wallet . GetWalletAddress ( ) , 1000000000000 ) . CallData )
116+ } ) ;
117+ Assert . IsNotNull ( mintResult ) ;
118+ Assert . IsTrue ( mintResult is SuccessfulTransactionReturn ) ;
119+
120+ List < Step > finalSteps = new List < Step > ( ) ;
121+ Address USDC = new Address ( "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359" ) ;
122+ Address [ ] possibleCurrencyAddresses = new Address [ ] { USDC } ;
123+ Checkout checkout = new Checkout ( wallet , _chain ) ;
124+ for ( int i = 0 ; i < 10 ; i ++ )
125+ {
126+ Step [ ] steps = await checkout . GenerateListingTransaction ( collection , ( i % 5 + 1 ) . ToString ( ) ,
127+ i + 1 ,
128+ ContractType . ERC1155 , possibleCurrencyAddresses . GetRandomObjectFromArray ( ) , 1 ,
129+ DateTime . Now + TimeSpan . FromDays ( 365 ) ) ;
130+ if ( i % 5 == 3 )
131+ {
132+ await Task . Delay ( 1000 ) ;
133+ }
134+
135+ foreach ( var step in steps )
136+ {
137+ finalSteps . Add ( step ) ;
138+ }
139+ }
140+
141+ for ( int i = 0 ; i < 10 ; i ++ )
142+ {
143+ Step [ ] steps = await checkout . GenerateOfferTransaction ( collection , ( i % 5 + 1 ) . ToString ( ) ,
144+ i + 1 ,
145+ ContractType . ERC1155 , possibleCurrencyAddresses . GetRandomObjectFromArray ( ) , 1 ,
146+ DateTime . Now + TimeSpan . FromDays ( 365 ) ) ;
147+ if ( i % 5 == 3 )
148+ {
149+ await Task . Delay ( 1000 ) ;
150+ }
151+
152+ foreach ( var step in steps )
153+ {
154+ finalSteps . Add ( step ) ;
155+ }
156+ }
157+
158+ Transaction [ ] transactions = new Transaction [ 10 ] ;
159+ for ( int j = 0 ; j < finalSteps . Count ; j += 10 )
160+ {
161+ for ( int i = 0 ; i < 10 ; i ++ )
162+ {
163+ transactions [ i ] = new RawTransaction ( finalSteps [ j + i ] . to , finalSteps [ j + i ] . value ,
164+ finalSteps [ j + i ] . data ) ;
165+ }
166+
167+ TransactionReturn result = await wallet . SendTransaction ( _chain , transactions ) ;
168+ Assert . IsNotNull ( result ) ;
169+ // Assert.IsTrue(result is SuccessfulTransactionReturn);
170+ if ( result is SuccessfulTransactionReturn success )
171+ {
172+ Debug . Log ( ChainDictionaries . BlockExplorerOf [ _chain ] . AppendTrailingSlashIfNeeded ( ) + "tx/" +
173+ success . txHash ) ;
174+ // Application.OpenURL(ChainDictionaries.BlockExplorerOf[_chain].AppendTrailingSlashIfNeeded() + "tx/" + success.txHash);
175+ }
176+ }
177+ }
106178 }
107179}
0 commit comments