Fixes crash in marketBuffer

This commit is contained in:
benbierens 2024-06-21 09:33:52 +02:00
parent 2b7ba61543
commit 0c4d3be912
No known key found for this signature in database
GPG Key ID: 877D2C2E09A22F3A
2 changed files with 15 additions and 5 deletions

View File

@ -50,10 +50,10 @@ namespace CodexTests.UtilityTests
apiCalls.Stop();
Assert.That(receivedEvents.Count(e => e.Contains("Created as New.")), Is.EqualTo(1));
Assert.That(receivedEvents.Count(e => e.Contains("SlotFilled")), Is.EqualTo(GetNumberOfRequiredHosts()));
Assert.That(receivedEvents.Count(e => e.Contains("Transit: New -> Started")), Is.EqualTo(1));
Assert.That(receivedEvents.Count(e => e.Contains("Transit: Started -> Finished")), Is.EqualTo(1));
AssertEventOccurance("Created as New.", 1);
AssertEventOccurance("SlotFilled", Convert.ToInt32(GetNumberOfRequiredHosts()));
AssertEventOccurance("Transit: New -> Started", 1);
AssertEventOccurance("Transit: Started -> Finished", 1);
foreach (var r in repo.Rewards)
{
@ -71,6 +71,12 @@ namespace CodexTests.UtilityTests
return $"({rewardId})'{reward.Message}'";
}
private void AssertEventOccurance(string msg, int expectedCount)
{
Assert.That(receivedEvents.Count(e => e.Contains(msg)), Is.EqualTo(expectedCount),
$"Event '{msg}' did not occure correct number of times.");
}
private void OnCommand(string timestamp, GiveRewardsCommand call)
{
Log($"<API call {timestamp}>");

View File

@ -44,7 +44,11 @@ namespace TestNetRewarder
private float Average(Func<IChainStateRequest, BigInteger> getValue)
{
return Average(s => Convert.ToInt32(getValue(s)));
return Average(s =>
{
var value = getValue(s);
return (int)value;
});
}
private float Average(Func<IChainStateRequest, int> getValue)