mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-06 23:43: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)
|
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);
|
log.Error(msg);
|
||||||
handler.OnError(msg);
|
handler.OnError(msg);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -35,7 +35,7 @@ namespace CodexContractsPlugin.Marketplace
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return BitConverter.ToString(RequestId).Replace("-", "").ToLowerInvariant();
|
return RequestId.ToHex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,7 @@ namespace CodexReleaseTests.MarketTests
|
|||||||
|
|
||||||
request.WaitForStorageContractStarted();
|
request.WaitForStorageContractStarted();
|
||||||
AssertContractSlotsAreFilledByHosts(request, hosts);
|
AssertContractSlotsAreFilledByHosts(request, hosts);
|
||||||
|
AssertContractIsOnChain(request);
|
||||||
|
|
||||||
hosts.Stop(waitTillStopped: true);
|
hosts.Stop(waitTillStopped: true);
|
||||||
|
|
||||||
@ -42,6 +43,12 @@ namespace CodexReleaseTests.MarketTests
|
|||||||
|
|
||||||
var config = GetContracts().Deployment.Config;
|
var config = GetContracts().Deployment.Config;
|
||||||
request.WaitForContractFailed(config);
|
request.WaitForContractFailed(config);
|
||||||
|
|
||||||
|
Thread.Sleep(GetPeriodDuration());
|
||||||
|
AssertContractIsOnChain(request);
|
||||||
|
|
||||||
|
Thread.Sleep(GetPeriodDuration());
|
||||||
|
AssertContractIsOnChain(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WaitForSlotFreedEvents()
|
private void WaitForSlotFreedEvents()
|
||||||
|
|||||||
@ -41,13 +41,21 @@ namespace CodexReleaseTests.MarketTests
|
|||||||
|
|
||||||
WaitForContractStarted(request);
|
WaitForContractStarted(request);
|
||||||
AssertContractSlotsAreFilledByHosts(request, hosts);
|
AssertContractSlotsAreFilledByHosts(request, hosts);
|
||||||
|
AssertContractIsOnChain(request);
|
||||||
|
|
||||||
request.WaitForStorageContractFinished();
|
request.WaitForStorageContractFinished();
|
||||||
|
AssertContractIsOnChain(request);
|
||||||
|
|
||||||
AssertClientHasPaidForContract(pricePerBytePerSecond, client, request, hosts);
|
AssertClientHasPaidForContract(pricePerBytePerSecond, client, request, hosts);
|
||||||
AssertHostsWerePaidForContract(pricePerBytePerSecond, request, hosts);
|
AssertHostsWerePaidForContract(pricePerBytePerSecond, request, hosts);
|
||||||
AssertHostsCollateralsAreUnchanged(hosts);
|
AssertHostsCollateralsAreUnchanged(hosts);
|
||||||
AssertHostAvailabilitiesAreEmpty(hosts);
|
AssertHostAvailabilitiesAreEmpty(hosts);
|
||||||
|
|
||||||
|
Thread.Sleep(GetPeriodDuration());
|
||||||
|
AssertContractIsOnChain(request);
|
||||||
|
|
||||||
|
Thread.Sleep(GetPeriodDuration());
|
||||||
|
AssertContractIsOnChain(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IStoragePurchaseContract CreateStorageRequest(ICodexNode client)
|
private IStoragePurchaseContract CreateStorageRequest(ICodexNode client)
|
||||||
|
|||||||
@ -402,12 +402,21 @@ namespace CodexReleaseTests.Utils
|
|||||||
|
|
||||||
protected void AssertContractIsOnChain(IStoragePurchaseContract contract)
|
protected void AssertContractIsOnChain(IStoragePurchaseContract contract)
|
||||||
{
|
{
|
||||||
|
// Check the creation event.
|
||||||
AssertOnChainEvents(events =>
|
AssertOnChainEvents(events =>
|
||||||
{
|
{
|
||||||
var onChainRequests = events.GetStorageRequests();
|
var onChainRequests = events.GetStorageRequests();
|
||||||
if (onChainRequests.Any(r => r.Id == contract.PurchaseId)) return;
|
if (onChainRequests.Any(r => r.Id == contract.PurchaseId)) return;
|
||||||
throw new Exception($"OnChain request {contract.PurchaseId} not found...");
|
throw new Exception($"OnChain request {contract.PurchaseId} not found...");
|
||||||
}, nameof(AssertContractIsOnChain));
|
}, 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)
|
protected void AssertOnChainEvents(Action<ICodexContractsEvents> onEvents, string description)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user