2
0
mirror of synced 2025-01-11 09:06:56 +00:00

Adds method for getting request-fulfilled events

This commit is contained in:
benbierens 2024-01-22 16:05:04 +01:00
parent 678b719cef
commit 890cff93d5
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
3 changed files with 21 additions and 2 deletions

View File

@ -19,9 +19,9 @@ namespace CodexContractsPlugin
TestToken GetTestTokenBalance(IHasEthAddress owner);
TestToken GetTestTokenBalance(EthAddress ethAddress);
Request[] GetStorageRequests(TimeRange range);
Request[] GetStorageRequests(TimeRange timeRange);
EthAddress GetSlotHost(Request storageRequest, decimal slotIndex);
// add 'RequestFulfilled' to see request is started.
RequestFulfilledEventDTO[] GetRequestFulfilledEvents(TimeRange timeRange);
SlotFilledEventDTO[] GetSlotFilledEvents(TimeRange timeRange);
SlotFreedEventDTO[] GetSlotFreedEvents(TimeRange timeRange);
}
@ -82,6 +82,17 @@ namespace CodexContractsPlugin
.ToArray();
}
public RequestFulfilledEventDTO[] GetRequestFulfilledEvents(TimeRange timeRange)
{
var events = gethNode.GetEvents<RequestFulfilledEventDTO>(Deployment.MarketplaceAddress, timeRange);
return events.Select(e =>
{
var result = e.Event;
result.BlockNumber = e.Log.BlockNumber.ToUlong();
return result;
}).ToArray();
}
public SlotFilledEventDTO[] GetSlotFilledEvents(TimeRange timeRange)
{
var events = gethNode.GetEvents<SlotFilledEventDTO>(Deployment.MarketplaceAddress, timeRange);

View File

@ -11,6 +11,11 @@ namespace CodexContractsPlugin.Marketplace
public EthAddress ClientAddress { get { return new EthAddress(Client); } }
}
public partial class RequestFulfilledEventDTO
{
public ulong BlockNumber { get; set; }
}
public partial class SlotFilledEventDTO
{
public ulong BlockNumber { get; set; }

View File

@ -98,6 +98,9 @@ namespace CodexTests.BasicTests
AssertBalance(contracts, seller, Is.LessThan(sellerInitialBalance), "Collateral was not placed.");
var requestFulfilledEvents = contracts.GetRequestFulfilledEvents(GetTestRunTimeRange());
Assert.That(requestFulfilledEvents.Length, Is.EqualTo(1));
CollectionAssert.AreEqual(request.RequestId, requestFulfilledEvents[0].RequestId);
var filledSlotEvents = contracts.GetSlotFilledEvents(GetTestRunTimeRange());
Assert.That(filledSlotEvents.Length, Is.EqualTo(1));
var filledSlotEvent = filledSlotEvents.Single();