mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-04 06:23:09 +00:00
Adds randomness to price per byte per second and contract duration
This commit is contained in:
parent
c68d4bb13f
commit
3fe2827080
@ -7,6 +7,7 @@ namespace AutoClient
|
||||
public class CodexWrapper
|
||||
{
|
||||
private readonly App app;
|
||||
private static readonly Random r = new Random();
|
||||
|
||||
public CodexWrapper(App app, ICodexNode node)
|
||||
{
|
||||
@ -26,11 +27,11 @@ namespace AutoClient
|
||||
var result = Node.Marketplace.RequestStorage(new StoragePurchaseRequest(cid)
|
||||
{
|
||||
CollateralPerByte = app.Config.CollateralPerByte.TstWei(),
|
||||
Duration = TimeSpan.FromMinutes(app.Config.ContractDurationMinutes),
|
||||
Duration = GetDuration(),
|
||||
Expiry = TimeSpan.FromMinutes(app.Config.ContractExpiryMinutes),
|
||||
MinRequiredNumberOfNodes = Convert.ToUInt32(app.Config.NumHosts),
|
||||
NodeFailureTolerance = Convert.ToUInt32(app.Config.HostTolerance),
|
||||
PricePerBytePerSecond = app.Config.PricePerBytePerSecond.TstWei(),
|
||||
PricePerBytePerSecond = GetPricePerBytePerSecond(),
|
||||
ProofProbability = 15
|
||||
});
|
||||
return result;
|
||||
@ -40,5 +41,25 @@ namespace AutoClient
|
||||
{
|
||||
return Node.GetPurchaseStatus(pid);
|
||||
}
|
||||
|
||||
private TestToken GetPricePerBytePerSecond()
|
||||
{
|
||||
var i = app.Config.PricePerBytePerSecond;
|
||||
i -= 100;
|
||||
i += r.Next(0, 1000);
|
||||
|
||||
return i.TstWei();
|
||||
}
|
||||
|
||||
private TimeSpan GetDuration()
|
||||
{
|
||||
var i = app.Config.ContractDurationMinutes;
|
||||
var day = 60 * 24;
|
||||
i -= day;
|
||||
i -= 10; // We don't want to accidentally hit exactly 7 days because that's the limit of the storage node availabilities.
|
||||
i += r.Next(0, day * 2);
|
||||
|
||||
return TimeSpan.FromMinutes(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user