mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-02 13:33:07 +00:00
Adds checks to ensure contracts can be found onchain before and after they finish
This commit is contained in:
parent
54eb65594a
commit
60e2d03c62
@ -224,7 +224,7 @@ namespace CodexContractsPlugin.ChainMonitor
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var msg = "Failed to get request from chain: " + ex;
|
||||
var msg = $"Failed to get request with id '{request.RequestId.ToHex()}' from chain: {ex}";
|
||||
log.Error(msg);
|
||||
handler.OnError(msg);
|
||||
return null;
|
||||
|
||||
@ -35,7 +35,7 @@ namespace CodexContractsPlugin.Marketplace
|
||||
{
|
||||
get
|
||||
{
|
||||
return BitConverter.ToString(RequestId).Replace("-", "").ToLowerInvariant();
|
||||
return RequestId.ToHex();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@ namespace CodexReleaseTests.MarketTests
|
||||
|
||||
request.WaitForStorageContractStarted();
|
||||
AssertContractSlotsAreFilledByHosts(request, hosts);
|
||||
AssertContractIsOnChain(request);
|
||||
|
||||
hosts.Stop(waitTillStopped: true);
|
||||
|
||||
@ -42,6 +43,12 @@ namespace CodexReleaseTests.MarketTests
|
||||
|
||||
var config = GetContracts().Deployment.Config;
|
||||
request.WaitForContractFailed(config);
|
||||
|
||||
Thread.Sleep(GetPeriodDuration());
|
||||
AssertContractIsOnChain(request);
|
||||
|
||||
Thread.Sleep(GetPeriodDuration());
|
||||
AssertContractIsOnChain(request);
|
||||
}
|
||||
|
||||
private void WaitForSlotFreedEvents()
|
||||
|
||||
@ -41,13 +41,21 @@ namespace CodexReleaseTests.MarketTests
|
||||
|
||||
WaitForContractStarted(request);
|
||||
AssertContractSlotsAreFilledByHosts(request, hosts);
|
||||
AssertContractIsOnChain(request);
|
||||
|
||||
request.WaitForStorageContractFinished();
|
||||
AssertContractIsOnChain(request);
|
||||
|
||||
AssertClientHasPaidForContract(pricePerBytePerSecond, client, request, hosts);
|
||||
AssertHostsWerePaidForContract(pricePerBytePerSecond, request, hosts);
|
||||
AssertHostsCollateralsAreUnchanged(hosts);
|
||||
AssertHostAvailabilitiesAreEmpty(hosts);
|
||||
|
||||
Thread.Sleep(GetPeriodDuration());
|
||||
AssertContractIsOnChain(request);
|
||||
|
||||
Thread.Sleep(GetPeriodDuration());
|
||||
AssertContractIsOnChain(request);
|
||||
}
|
||||
|
||||
private IStoragePurchaseContract CreateStorageRequest(ICodexNode client)
|
||||
|
||||
@ -402,12 +402,21 @@ namespace CodexReleaseTests.Utils
|
||||
|
||||
protected void AssertContractIsOnChain(IStoragePurchaseContract contract)
|
||||
{
|
||||
// Check the creation event.
|
||||
AssertOnChainEvents(events =>
|
||||
{
|
||||
var onChainRequests = events.GetStorageRequests();
|
||||
if (onChainRequests.Any(r => r.Id == contract.PurchaseId)) return;
|
||||
throw new Exception($"OnChain request {contract.PurchaseId} not found...");
|
||||
}, nameof(AssertContractIsOnChain));
|
||||
|
||||
// Check that the getRequest call returns it.
|
||||
var rid = contract.PurchaseId.HexToByteArray();
|
||||
var r = GetContracts().GetRequest(rid);
|
||||
if (r == null) throw new Exception($"Failed to get Request from {nameof(GetRequestFunction)}");
|
||||
Assert.That(r.Ask.Duration, Is.EqualTo(contract.Purchase.Duration.TotalSeconds));
|
||||
Assert.That(r.Ask.Slots, Is.EqualTo(contract.Purchase.MinRequiredNumberOfNodes));
|
||||
Assert.That(((int)r.Ask.ProofProbability), Is.EqualTo(contract.Purchase.ProofProbability));
|
||||
}
|
||||
|
||||
protected void AssertOnChainEvents(Action<ICodexContractsEvents> onEvents, string description)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user