Skip to content

Commit fbb8db2

Browse files
committed
Test for partial dataset encoding
1 parent c12132d commit fbb8db2

File tree

3 files changed

+63
-7
lines changed

3 files changed

+63
-7
lines changed

Tests/CodexReleaseTests/DataTests/DecodeTest.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,54 @@ public void DecodeDataset()
4343

4444
file.AssertIsEqual(decoded);
4545
}
46+
47+
[Test]
48+
[Ignore("Crashes node attempting encoding. Issue: https://github.com/codex-storage/nim-codex/issues/1185")]
49+
public void PartiallyDeletedDatasets()
50+
{
51+
var clients = StartClients(s => s
52+
.WithBlockMaintenanceNumber(1)
53+
.WithBlockMaintenanceInterval(TimeSpan.FromSeconds(10.0))
54+
.WithBlockTTL(TimeSpan.FromSeconds(30.0)));
55+
56+
57+
var file = GenerateTestFile(2.MB());
58+
var bCid = clients[0].UploadFile(file);
59+
60+
var space = clients[0].Space();
61+
var update = space;
62+
while (space.QuotaUsedBytes == update.QuotaUsedBytes)
63+
{
64+
Thread.Sleep(TimeSpan.FromSeconds(3.0));
65+
update = clients[0].Space();
66+
}
67+
68+
Assert.That(update.QuotaUsedBytes, Is.LessThan(space.QuotaUsedBytes));
69+
// The dataset is partially deleted.
70+
71+
// What happens when we request storage for it?
72+
var request = clients[0].Marketplace.RequestStorage(new CodexClient.StoragePurchaseRequest(bCid)
73+
{
74+
Expiry = TimeSpan.FromMinutes(5.0),
75+
Duration = TimeSpan.FromMinutes(100.0),
76+
CollateralPerByte = 100.Tst(),
77+
MinRequiredNumberOfNodes = 6,
78+
NodeFailureTolerance = 3,
79+
PricePerBytePerSecond = 100.Tst(),
80+
ProofProbability = 20
81+
});
82+
var eCid = request.ContentId;
83+
84+
Assert.That(bCid.Id, Is.Not.EqualTo(eCid.Id));
85+
86+
var basic = clients[0].DownloadManifestOnly(bCid);
87+
var encoded = clients[0].DownloadManifestOnly(eCid);
88+
Assert.That(basic.Manifest.Protected, Is.False);
89+
Assert.That(encoded.Manifest.Protected, Is.True);
90+
91+
var decoded = clients[1].DownloadContent(eCid);
92+
93+
file.AssertIsEqual(decoded);
94+
}
4695
}
4796
}

Tests/CodexReleaseTests/MarketTests/MarketplaceAutoBootstrapDistTest.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,19 @@ private Ether GetEthBalance(EthAddress address)
143143

144144
public ICodexNodeGroup StartClients()
145145
{
146-
return StartCodex(NumberOfClients, s => s
147-
.WithName("client")
148-
.EnableMarketplace(GetGeth(), GetContracts(), m => m
149-
.WithInitial(StartingBalanceEth.Eth(), StartingBalanceTST.Tst())
150-
)
151-
);
146+
return StartClients(s => { });
147+
}
148+
149+
public ICodexNodeGroup StartClients(Action<ICodexSetup> additional)
150+
{
151+
return StartCodex(NumberOfClients, s =>
152+
{
153+
s.WithName("client")
154+
.EnableMarketplace(GetGeth(), GetContracts(), m => m
155+
.WithInitial(StartingBalanceEth.Eth(), StartingBalanceTST.Tst()));
156+
157+
additional(s);
158+
});
152159
}
153160

154161
public ICodexNode StartValidator()

Tools/AutoClient/Modes/FolderStore/FileSaver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ private IStoragePurchaseContract CreateNewStorageRequest()
187187
try
188188
{
189189
var request = instance.RequestStorage(new ContentId(entry.BasicCid));
190-
entry.EncodedCid = request.Purchase.ContentId.Id;
190+
entry.EncodedCid = request.ContentId.Id;
191191
entry.PurchaseId = request.PurchaseId;
192192
entry.PurchaseFinishedUtc = DateTime.UtcNow + request.Purchase.Duration;
193193

0 commit comments

Comments
 (0)