From cb4cdfe69a621e954babe580e5a853743e8b0630 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 17 Jun 2024 15:59:54 +0200 Subject: [PATCH] better logging --- .../ChainMonitor/ChainState.cs | 4 ++-- .../UtilityTests/DiscordBotTests.cs | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ProjectPlugins/CodexContractsPlugin/ChainMonitor/ChainState.cs b/ProjectPlugins/CodexContractsPlugin/ChainMonitor/ChainState.cs index 0d6af67..bc284eb 100644 --- a/ProjectPlugins/CodexContractsPlugin/ChainMonitor/ChainState.cs +++ b/ProjectPlugins/CodexContractsPlugin/ChainMonitor/ChainState.cs @@ -115,7 +115,7 @@ namespace CodexContractsPlugin.ChainMonitor var r = FindRequest(request.RequestId); if (r == null) return; 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); } @@ -124,7 +124,7 @@ namespace CodexContractsPlugin.ChainMonitor var r = FindRequest(request.RequestId); if (r == null) return; 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); } diff --git a/Tests/CodexTests/UtilityTests/DiscordBotTests.cs b/Tests/CodexTests/UtilityTests/DiscordBotTests.cs index 7aafab6..18ba663 100644 --- a/Tests/CodexTests/UtilityTests/DiscordBotTests.cs +++ b/Tests/CodexTests/UtilityTests/DiscordBotTests.cs @@ -4,6 +4,7 @@ using CodexDiscordBotPlugin; using CodexPlugin; using Core; using DiscordRewards; +using DistTestCore; using GethPlugin; using KubernetesWorkflow.Types; using Newtonsoft.Json; @@ -24,6 +25,7 @@ namespace CodexTests.UtilityTests private readonly TimeSpan rewarderInterval = TimeSpan.FromMinutes(1); [Test] + [DontDownloadLogs] public void BotRewardTest() { var geth = Ci.StartGethNode(s => s.IsMiner().WithName("disttest-geth")); @@ -31,11 +33,9 @@ namespace CodexTests.UtilityTests var gethInfo = CreateGethInfo(geth, contracts); var botContainer = StartDiscordBot(gethInfo); - - StartHosts(geth, contracts); - var rewarderContainer = StartRewarderBot(gethInfo, botContainer); + StartHosts(geth, contracts); var client = StartClient(geth, contracts); var events = ChainEvents.FromTimeRange(contracts, GetTestRunTimeRange()); @@ -76,8 +76,15 @@ namespace CodexTests.UtilityTests private void OnCommand(GiveRewardsCommand call) { - if (call.Averages.Any()) Log($"API call: {call.Averages.Length} average."); - if (call.EventsOverview.Any()) Log($"API call: {call.EventsOverview.Length} events."); + Log($"API call:"); + 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) { var reward = repo.Rewards.Single(a => a.RoleId == r.RewardId); @@ -85,7 +92,7 @@ namespace CodexTests.UtilityTests foreach (var address in r.UserAddresses) { var user = IdentifyAccount(address); - Log("API call: " + user + ": " + reward.Message); + Log("Reward: " + user + ": " + reward.Message); } } }