From 29fa554146160849911f20924acfd1aa26f84de7 Mon Sep 17 00:00:00 2001 From: benbierens Date: Thu, 18 Jan 2024 09:55:07 +0100 Subject: [PATCH] Adds log topics for block exchange --- ProjectPlugins/CodexPlugin/CodexSetup.cs | 8 ++++++++ ProjectPlugins/CodexPlugin/CodexStartupConfig.cs | 13 +++++++++++++ Tests/CodexTests/BasicTests/ExampleTests.cs | 5 +++++ 3 files changed, 26 insertions(+) diff --git a/ProjectPlugins/CodexPlugin/CodexSetup.cs b/ProjectPlugins/CodexPlugin/CodexSetup.cs index a491fb3..ccac252 100644 --- a/ProjectPlugins/CodexPlugin/CodexSetup.cs +++ b/ProjectPlugins/CodexPlugin/CodexSetup.cs @@ -27,6 +27,13 @@ namespace CodexPlugin public class CodexLogCustomTopics { + public CodexLogCustomTopics(CodexLogLevel discV5, CodexLogLevel libp2p, CodexLogLevel blockExchange) + { + DiscV5 = discV5; + Libp2p = libp2p; + BlockExchange = blockExchange; + } + public CodexLogCustomTopics(CodexLogLevel discV5, CodexLogLevel libp2p) { DiscV5 = discV5; @@ -35,6 +42,7 @@ namespace CodexPlugin public CodexLogLevel DiscV5 { get; set; } public CodexLogLevel Libp2p { get; set; } + public CodexLogLevel? BlockExchange { get; } } public class CodexSetup : CodexStartupConfig, ICodexSetup diff --git a/ProjectPlugins/CodexPlugin/CodexStartupConfig.cs b/ProjectPlugins/CodexPlugin/CodexStartupConfig.cs index ed840d0..bd508c1 100644 --- a/ProjectPlugins/CodexPlugin/CodexStartupConfig.cs +++ b/ProjectPlugins/CodexPlugin/CodexStartupConfig.cs @@ -54,10 +54,23 @@ namespace CodexPlugin "websock", "ws-session" }; + var blockExchangeTopics = new[] + { + "codex", + "pendingblocks", + "peerctxstore", + "discoveryengine", + "repostore" + }; level = $"{level};" + $"{CustomTopics.DiscV5.ToString()!.ToLowerInvariant()}:{string.Join(",", discV5Topics)};" + $"{CustomTopics.Libp2p.ToString()!.ToLowerInvariant()}:{string.Join(",", libp2pTopics)}"; + + if (CustomTopics.BlockExchange != null) + { + level += $";{CustomTopics.BlockExchange.ToString()!.ToLowerInvariant()}:{string.Join(",", blockExchangeTopics)}"; + } } return level; } diff --git a/Tests/CodexTests/BasicTests/ExampleTests.cs b/Tests/CodexTests/BasicTests/ExampleTests.cs index ef3f7ac..7916d38 100644 --- a/Tests/CodexTests/BasicTests/ExampleTests.cs +++ b/Tests/CodexTests/BasicTests/ExampleTests.cs @@ -112,6 +112,11 @@ namespace CodexTests.BasicTests AssertBalance(contracts, seller, Is.GreaterThan(sellerInitialBalance), "Seller was not paid for storage."); AssertBalance(contracts, buyer, Is.LessThan(buyerInitialBalance), "Buyer was not charged for storage."); + var log = Ci.DownloadLog(seller); + log.AssertLogContains("Received a request to store a slot!"); + log.AssertLogContains("Received proof challenge"); + log.AssertLogContains("Collecting input for proof"); + //CheckLogForErrors(seller, buyer); }