Skip to content

Commit

Permalink
refactoring: remove VerkleBlockchainTestsRunner
Browse files Browse the repository at this point in the history
  • Loading branch information
yerke26 committed Sep 30, 2024
1 parent 506fa2c commit 01621fb
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 90 deletions.
4 changes: 2 additions & 2 deletions src/Nethermind/Ethereum.Test.Base/BlockchainTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

namespace Ethereum.Test.Base
{
public abstract class BlockchainTestBase
public class BlockchainTestBase: IBlockchainTestBase
{
private static InterfaceLogger _logger = new NUnitLogger(LogLevel.Trace);
// private static ILogManager _logManager = new OneLoggerLogManager(_logger);
Expand Down Expand Up @@ -74,7 +74,7 @@ public UInt256 Calculate(BlockHeader header, BlockHeader parent)
}
}

protected async Task<EthereumTestResult> RunTest(BlockchainTest test, Stopwatch? stopwatch = null, bool failOnInvalidRlp = true)
public async Task<EthereumTestResult> RunTest(BlockchainTest test, Stopwatch? stopwatch = null, bool failOnInvalidRlp = true)
{
TestContext.WriteLine($"Running {test.Name}, Network: [{test.Network.Name}] at {DateTime.UtcNow:HH:mm:ss.ffffff}");
if (test.NetworkAfterTransition is not null)
Expand Down
14 changes: 14 additions & 0 deletions src/Nethermind/Ethereum.Test.Base/IBlockchainTestBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using System.Diagnostics;
using System.Threading.Tasks;

namespace Ethereum.Test.Base;

public interface IBlockchainTestBase
{
public void Setup();

public Task<EthereumTestResult> RunTest(BlockchainTest test, Stopwatch? stopwatch = null, bool failOnInvalidRlp = true);
}
11 changes: 0 additions & 11 deletions src/Nethermind/Ethereum.Test.Base/TestSuffixDiffJson.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/Nethermind/Ethereum.Test.Base/VerkleBlockChainTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

namespace Ethereum.Test.Base
{
public abstract class VerkleBlockChainTestBase
public class VerkleBlockChainTestBase: IBlockchainTestBase
{
private static InterfaceLogger _logger = new NUnitLogger(LogLevel.Trace);
// private static ILogManager _logManager = new OneLoggerLogManager(_logger);
Expand Down Expand Up @@ -70,7 +70,7 @@ public UInt256 Calculate(BlockHeader header, BlockHeader parent)
}
}

protected async Task<EthereumTestResult> RunTest(BlockchainTest test, Stopwatch? stopwatch = null, bool failOnInvalidRlp = true)
public async Task<EthereumTestResult> RunTest(BlockchainTest test, Stopwatch? stopwatch = null, bool failOnInvalidRlp = true)
{
Assert.IsNull(test.LoadFailure, "test data loading failure");

Expand Down
10 changes: 6 additions & 4 deletions src/Nethermind/Nethermind.Test.Runner/BlockchainTestsRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@

namespace Nethermind.Test.Runner;

public class BlockchainTestsRunner : BlockchainTestBase, IBlockchainTestRunner
public class BlockchainTestsRunner : IBlockchainTestRunner
{
private readonly ConsoleColor _defaultColour;
private readonly ITestSourceLoader _testsSource;
private readonly string? _filter;
private readonly IBlockchainTestBase _blockchainTestBase;

public BlockchainTestsRunner(ITestSourceLoader testsSource, string? filter)
public BlockchainTestsRunner(ITestSourceLoader testsSource, string? filter, IBlockchainTestBase blockchainTestBase)
{
_testsSource = testsSource ?? throw new ArgumentNullException(nameof(testsSource));
_defaultColour = Console.ForegroundColor;
_filter = filter;
_blockchainTestBase = blockchainTestBase;
}

public async Task<IEnumerable<EthereumTestResult>> RunTestsAsync()
Expand All @@ -32,7 +34,7 @@ public async Task<IEnumerable<EthereumTestResult>> RunTestsAsync()
{
if (_filter is not null && !Regex.Match(test.Name, $"^({_filter})").Success)
continue;
Setup();
_blockchainTestBase.Setup();

Console.Write($"{test,-120} ");
if (test.LoadFailure != null)
Expand All @@ -42,7 +44,7 @@ public async Task<IEnumerable<EthereumTestResult>> RunTestsAsync()
}
else
{
EthereumTestResult result = await RunTest(test);
EthereumTestResult result = await _blockchainTestBase.RunTest(test);
testResults.Add(result);
if (result.Pass)
WriteGreen("PASS");
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Test.Runner/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ private static async Task Run(Options options)
while (!string.IsNullOrWhiteSpace(input))
{
if (options.VerkleTest)
await RunBlockTest(input, source => new VerkleBlockchainTestsRunner(source, options.Filter));
await RunBlockTest(input, source => new BlockchainTestsRunner(source, options.Filter, new VerkleBlockChainTestBase()));
else if (options.BlockTest)
await RunBlockTest(input, source => new BlockchainTestsRunner(source, options.Filter));
await RunBlockTest(input, source => new BlockchainTestsRunner(source, options.Filter, new BlockchainTestBase()));
else
RunStateTest(input, source => new StateTestsRunner(source, whenTrace, !options.ExcludeMemory, !options.ExcludeStack, options.Filter));
if (!options.Stdin)
Expand Down

This file was deleted.

0 comments on commit 01621fb

Please sign in to comment.