better logging

This commit is contained in:
Ben 2024-06-17 15:59:54 +02:00
parent bed57dd35b
commit cb4cdfe69a
No known key found for this signature in database
GPG Key ID: 541B9D8C9F1426A1
2 changed files with 15 additions and 8 deletions

View File

@ -115,7 +115,7 @@ namespace CodexContractsPlugin.ChainMonitor
var r = FindRequest(request.RequestId); var r = FindRequest(request.RequestId);
if (r == null) return; if (r == null) return;
r.Hosts.Add(request.Host, (int)request.SlotIndex); r.Hosts.Add(request.Host, (int)request.SlotIndex);
r.Log($"[{request.Block.BlockNumber}] SlotFilled"); r.Log($"[{request.Block.BlockNumber}] SlotFilled (host:'{request.Host}', slotIndex:{request.SlotIndex})");
handler.OnSlotFilled(r, request.SlotIndex); handler.OnSlotFilled(r, request.SlotIndex);
} }
@ -124,7 +124,7 @@ namespace CodexContractsPlugin.ChainMonitor
var r = FindRequest(request.RequestId); var r = FindRequest(request.RequestId);
if (r == null) return; if (r == null) return;
r.Hosts.RemoveHost((int)request.SlotIndex); r.Hosts.RemoveHost((int)request.SlotIndex);
r.Log($"[{request.Block.BlockNumber}] SlotFreed"); r.Log($"[{request.Block.BlockNumber}] SlotFreed (slotIndex:{request.SlotIndex})");
handler.OnSlotFreed(r, request.SlotIndex); handler.OnSlotFreed(r, request.SlotIndex);
} }

View File

@ -4,6 +4,7 @@ using CodexDiscordBotPlugin;
using CodexPlugin; using CodexPlugin;
using Core; using Core;
using DiscordRewards; using DiscordRewards;
using DistTestCore;
using GethPlugin; using GethPlugin;
using KubernetesWorkflow.Types; using KubernetesWorkflow.Types;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -24,6 +25,7 @@ namespace CodexTests.UtilityTests
private readonly TimeSpan rewarderInterval = TimeSpan.FromMinutes(1); private readonly TimeSpan rewarderInterval = TimeSpan.FromMinutes(1);
[Test] [Test]
[DontDownloadLogs]
public void BotRewardTest() public void BotRewardTest()
{ {
var geth = Ci.StartGethNode(s => s.IsMiner().WithName("disttest-geth")); var geth = Ci.StartGethNode(s => s.IsMiner().WithName("disttest-geth"));
@ -31,11 +33,9 @@ namespace CodexTests.UtilityTests
var gethInfo = CreateGethInfo(geth, contracts); var gethInfo = CreateGethInfo(geth, contracts);
var botContainer = StartDiscordBot(gethInfo); var botContainer = StartDiscordBot(gethInfo);
StartHosts(geth, contracts);
var rewarderContainer = StartRewarderBot(gethInfo, botContainer); var rewarderContainer = StartRewarderBot(gethInfo, botContainer);
StartHosts(geth, contracts);
var client = StartClient(geth, contracts); var client = StartClient(geth, contracts);
var events = ChainEvents.FromTimeRange(contracts, GetTestRunTimeRange()); var events = ChainEvents.FromTimeRange(contracts, GetTestRunTimeRange());
@ -76,8 +76,15 @@ namespace CodexTests.UtilityTests
private void OnCommand(GiveRewardsCommand call) private void OnCommand(GiveRewardsCommand call)
{ {
if (call.Averages.Any()) Log($"API call: {call.Averages.Length} average."); Log($"API call:");
if (call.EventsOverview.Any()) Log($"API call: {call.EventsOverview.Length} events."); foreach (var a in call.Averages)
{
Log("Average: " + JsonConvert.SerializeObject(a));
}
foreach (var e in call.EventsOverview)
{
Log("Event: " + e);
}
foreach (var r in call.Rewards) foreach (var r in call.Rewards)
{ {
var reward = repo.Rewards.Single(a => a.RoleId == r.RewardId); var reward = repo.Rewards.Single(a => a.RoleId == r.RewardId);
@ -85,7 +92,7 @@ namespace CodexTests.UtilityTests
foreach (var address in r.UserAddresses) foreach (var address in r.UserAddresses)
{ {
var user = IdentifyAccount(address); var user = IdentifyAccount(address);
Log("API call: " + user + ": " + reward.Message); Log("Reward: " + user + ": " + reward.Message);
} }
} }
} }