From b8ab96510b896fc507650c91d051226384be0fd4 Mon Sep 17 00:00:00 2001 From: Lukasz Rozmej Date: Tue, 15 Jun 2021 15:15:10 +0200 Subject: [PATCH] CI Test coverage need longer timeouts (#3124) * Increase timeout to 2s in test for code coverage on CI * fix BlockProcessorTests --- .../Nethermind.Blockchain.Test/BlockProcessorTests.cs | 3 ++- .../Nethermind.Core.Test/Blockchain/TestBlockchain.cs | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Nethermind/Nethermind.Blockchain.Test/BlockProcessorTests.cs b/src/Nethermind/Nethermind.Blockchain.Test/BlockProcessorTests.cs index fb34d3ae174..bbf27d2ff5d 100644 --- a/src/Nethermind/Nethermind.Blockchain.Test/BlockProcessorTests.cs +++ b/src/Nethermind/Nethermind.Blockchain.Test/BlockProcessorTests.cs @@ -39,6 +39,7 @@ using System.Threading.Tasks; using System.Threading; using FluentAssertions; +using Nethermind.Core.Test.Blockchain; namespace Nethermind.Blockchain.Test { @@ -171,7 +172,7 @@ public async Task Process_long_running_branch(int blocksAmount) var branchLength = blocksAmount + (int)testRpc.BlockTree.BestKnownNumber + 1; ((BlockTree)testRpc.BlockTree).AddBranch(branchLength, (int)testRpc.BlockTree.BestKnownNumber); - (await suggestedBlockResetEvent.WaitAsync(1000)).Should().BeTrue(); + (await suggestedBlockResetEvent.WaitAsync(TestBlockchain.DefaultTimeout)).Should().BeTrue(); Assert.AreEqual(branchLength - 1, (int)testRpc.BlockTree.BestKnownNumber); } } diff --git a/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs b/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs index 404e84b0be7..0e619ea1637 100644 --- a/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs +++ b/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs @@ -52,6 +52,7 @@ namespace Nethermind.Core.Test.Blockchain { public class TestBlockchain : IDisposable { + public const int DefaultTimeout = 2000; public IStateReader StateReader { get; private set; } public IEthereumEcdsa EthereumEcdsa { get; private set; } public TransactionProcessor TxProcessor { get; set; } @@ -177,7 +178,7 @@ protected virtual async Task Build(ISpecProvider specProvider = return this; } - private async Task WaitAsync(SemaphoreSlim semaphore, string error, int timeout = 1000) + private async Task WaitAsync(SemaphoreSlim semaphore, string error, int timeout = DefaultTimeout) { if (!await semaphore.WaitAsync(timeout)) { @@ -185,7 +186,7 @@ private async Task WaitAsync(SemaphoreSlim semaphore, string error, int timeout } } - private async Task WaitAsync(EventWaitHandle eventWaitHandle, string error, int timeout = 1000) + private async Task WaitAsync(EventWaitHandle eventWaitHandle, string error, int timeout = DefaultTimeout) { if (!await eventWaitHandle.WaitOneAsync(timeout, CancellationToken.None)) {