@@ -12,11 +12,18 @@ namespace CodexTests.BasicTests
12
12
public class MarketplaceTests : AutoBootstrapDistTest
13
13
{
14
14
[ Test ]
15
- public void MarketplaceExample ( )
15
+ [ Combinatorial ]
16
+ public void MarketplaceExample (
17
+ [ Values ( 4 , 8 , 16 /* 1mb */ , 32 ) ] int numBlocks ,
18
+ [ Values ( - 3 , - 2 , - 1 , 0 , 1 , 2 , 3 ) ] int plusSizeKb
19
+ )
16
20
{
17
21
var hostInitialBalance = 234 . TstWei ( ) ;
18
22
var clientInitialBalance = 100000 . TstWei ( ) ;
19
- var fileSize = 10 . MB ( ) ;
23
+ var fileSize = new ByteSize (
24
+ numBlocks * ( 64 * 1024 ) +
25
+ plusSizeKb * 1024
26
+ ) ;
20
27
21
28
var geth = Ci . StartGethNode ( s => s . IsMiner ( ) . WithName ( "disttest-geth" ) ) ;
22
29
var contracts = Ci . StartCodexContracts ( geth ) ;
@@ -56,9 +63,9 @@ public void MarketplaceExample()
56
63
57
64
AssertBalance ( contracts , client , Is . EqualTo ( clientInitialBalance ) ) ;
58
65
59
- var contentId = client . UploadFile ( testFile ) ;
66
+ var uploadCid = client . UploadFile ( testFile ) ;
60
67
61
- var purchase = new StoragePurchaseRequest ( contentId )
68
+ var purchase = new StoragePurchaseRequest ( uploadCid )
62
69
{
63
70
PricePerSlotPerSecond = 2 . TstWei ( ) ,
64
71
RequiredCollateral = 10 . TstWei ( ) ,
@@ -70,6 +77,18 @@ public void MarketplaceExample()
70
77
} ;
71
78
72
79
var purchaseContract = client . Marketplace . RequestStorage ( purchase ) ;
80
+
81
+ var contractCid = purchaseContract . ContentId ;
82
+ Assert . That ( uploadCid . Id , Is . Not . EqualTo ( contractCid . Id ) ) ;
83
+
84
+ // Download both from client.
85
+ testFile . AssertIsEqual ( client . DownloadContent ( uploadCid ) ) ;
86
+ testFile . AssertIsEqual ( client . DownloadContent ( contractCid ) ) ;
87
+
88
+ // Download both from another node.
89
+ var downloader = StartCodex ( s => s . WithName ( "Downloader" ) ) ;
90
+ testFile . AssertIsEqual ( downloader . DownloadContent ( uploadCid ) ) ;
91
+ testFile . AssertIsEqual ( downloader . DownloadContent ( contractCid ) ) ;
73
92
74
93
WaitForAllSlotFilledEvents ( contracts , purchase , geth ) ;
75
94
@@ -86,6 +105,7 @@ public void MarketplaceExample()
86
105
}
87
106
88
107
[ Test ]
108
+ [ Ignore ( "Integrated into MarketplaceExample to speed up testing." ) ]
89
109
public void CanDownloadContentFromContractCid ( )
90
110
{
91
111
var fileSize = 10 . MB ( ) ;
0 commit comments