From 8fc8a3f7cf3fab9249b033c8dbc7793736e8b85b Mon Sep 17 00:00:00 2001 From: benbierens Date: Tue, 12 Dec 2023 14:18:26 +0100 Subject: [PATCH] Adds check for block verification failures --- Tests/CodexTests/BasicTests/ExampleTests.cs | 2 ++ Tests/CodexTests/BasicTests/OneClientTests.cs | 2 +- Tests/CodexTests/BasicTests/TwoClientTests.cs | 4 ++-- Tests/CodexTests/CodexDistTest.cs | 13 +++++++++++++ Tests/DistTestCore/DownloadedLogExtensions.cs | 5 +++++ 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Tests/CodexTests/BasicTests/ExampleTests.cs b/Tests/CodexTests/BasicTests/ExampleTests.cs index 44c6dc6..13e93bf 100644 --- a/Tests/CodexTests/BasicTests/ExampleTests.cs +++ b/Tests/CodexTests/BasicTests/ExampleTests.cs @@ -94,6 +94,8 @@ 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."); + + CheckLogForErrors(seller, buyer); } } } diff --git a/Tests/CodexTests/BasicTests/OneClientTests.cs b/Tests/CodexTests/BasicTests/OneClientTests.cs index de9c24e..26cf84e 100644 --- a/Tests/CodexTests/BasicTests/OneClientTests.cs +++ b/Tests/CodexTests/BasicTests/OneClientTests.cs @@ -6,7 +6,7 @@ using Utils; namespace CodexTests.BasicTests { [TestFixture] - public class OneClientTests : DistTest + public class OneClientTests : CodexDistTest { [Test] public void OneClientTest() diff --git a/Tests/CodexTests/BasicTests/TwoClientTests.cs b/Tests/CodexTests/BasicTests/TwoClientTests.cs index c781582..458f1e1 100644 --- a/Tests/CodexTests/BasicTests/TwoClientTests.cs +++ b/Tests/CodexTests/BasicTests/TwoClientTests.cs @@ -1,12 +1,11 @@ using CodexPlugin; -using DistTestCore; using NUnit.Framework; using Utils; namespace CodexTests.BasicTests { [TestFixture] - public class TwoClientTests : DistTest + public class TwoClientTests : CodexDistTest { [Test] public void TwoClientTest() @@ -51,6 +50,7 @@ namespace CodexTests.BasicTests var downloadedFile = secondary.DownloadContent(contentId); testFile.AssertIsEqual(downloadedFile); + CheckLogForErrors(primary, secondary); } } } diff --git a/Tests/CodexTests/CodexDistTest.cs b/Tests/CodexTests/CodexDistTest.cs index a8b406c..2711a83 100644 --- a/Tests/CodexTests/CodexDistTest.cs +++ b/Tests/CodexTests/CodexDistTest.cs @@ -85,6 +85,19 @@ namespace CodexTests AssertHelpers.RetryAssert(constraint, () => contracts.GetTestTokenBalance(codexNode), nameof(AssertBalance) + msg); } + public void CheckLogForErrors(params ICodexNode[] nodes) + { + foreach (var node in nodes) CheckLogForErrors(node); + } + + public void CheckLogForErrors(ICodexNode node) + { + var log = Ci.DownloadLog(node); + + log.AssertLogDoesNotContain("Block validation failed"); + log.AssertLogDoesNotContain("ERR "); + } + protected virtual void OnCodexSetup(ICodexSetup setup) { } diff --git a/Tests/DistTestCore/DownloadedLogExtensions.cs b/Tests/DistTestCore/DownloadedLogExtensions.cs index 59b020a..30a45b1 100644 --- a/Tests/DistTestCore/DownloadedLogExtensions.cs +++ b/Tests/DistTestCore/DownloadedLogExtensions.cs @@ -9,5 +9,10 @@ namespace DistTestCore { Assert.That(log.DoesLogContain(expectedString), $"Did not find '{expectedString}' in log."); } + + public static void AssertLogDoesNotContain(this IDownloadedLog log, string unexpectedString) + { + Assert.That(!log.DoesLogContain(unexpectedString), $"Did find '{unexpectedString}' in log."); + } } }