Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
yerke26 committed Oct 28, 2024
1 parent dff9c77 commit a25d497
Show file tree
Hide file tree
Showing 8 changed files with 267 additions and 160 deletions.
250 changes: 250 additions & 0 deletions tools/Evm.Test/T8NOldTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using Evm.JsonTypes;
using Nethermind.Serialization.Json;
using Newtonsoft.Json.Linq;

namespace Evm.Test;
using T8NTool;

public class T8NOldTests
{
private T8NTool _t8NTool;
private readonly EthereumJsonSerializer _ethereumJsonSerializer = new();

[SetUp]
public void Setup()
{
_t8NTool = new T8NTool();
}

[Test]
public void Test1()
{
Execute(
new InputParams("testdata/1/", "alloc.json", "env.json", "txs.json", "Frontier+1346"),
new OutputParams(alloc: "stdout", result: "stdout"),
expectedExitCode: 3);
}

[Test]
public void Test2()
{
Execute(
new InputParams("testdata/1/", "alloc.json", "env.json", "txs.json", "Byzantium"),
new OutputParams(alloc: "stdout", result: "stdout"),
expectedExitCode: 0,
expectedOutputFile: "testdata/1/exp.json");
}

[Test]
public void Test3()
{
Execute(
new InputParams("testdata/3/", "alloc.json", "env.json", "txs.json", "Berlin"),
new OutputParams(alloc: "stdout", result: "stdout"),
expectedExitCode: 0,
expectedOutputFile: "testdata/3/exp.json");
}

[Test]
public void Test4()
{
Execute(
new InputParams("testdata/4/", "alloc.json", "env.json", "txs.json", "Berlin"),
new OutputParams(alloc: "stdout", result: "stdout"),
expectedExitCode: 4);
}

[Test]
public void Test5()
{
Execute(
new InputParams("testdata/5/", "alloc.json", "env.json", "txs.json", "Byzantium", "0x80"),
new OutputParams(alloc: "stdout", result: "stdout"),
expectedExitCode: 0,
expectedOutputFile: "testdata/5/exp.json");
}

[Test]
public void Test6()
{
Execute(
new InputParams("testdata/13/", "alloc.json", "env.json", "txs.json", "London"),
new OutputParams(body: "stdout"),
expectedExitCode: 0,
expectedOutputFile: "testdata/13/exp.json");
}

[Test]
public void Test7()
{
Execute(
new InputParams("testdata/13/", "alloc.json", "env.json", "signed_txs.rlp", "London"),
new OutputParams(result: "stdout"),
expectedExitCode: 0,
expectedOutputFile: "testdata/13/exp2.json");
}

[Test]
public void Test8()
{
Execute(
new InputParams("testdata/14/", "alloc.json", "env.json", "txs.json", "London"),
new OutputParams(result: "stdout"),
expectedExitCode: 0,
expectedOutputFile: "testdata/14/exp.json");
}

[Test]
public void Test9()
{
Execute(
new InputParams("testdata/14/", "alloc.json", "env.uncles.json", "txs.json", "London"),
new OutputParams(result: "stdout"),
expectedExitCode: 0,
expectedOutputFile: "testdata/14/exp2.json");
}

[Test]
public void Test10()
{
Execute(
new InputParams("testdata/14/", "alloc.json", "env.uncles.json", "txs.json", "Berlin"),
new OutputParams(result: "stdout"),
expectedExitCode: 0,
expectedOutputFile: "testdata/14/exp_berlin.json");
}

[Test]
public void Test11()
{
Execute(
new InputParams("testdata/19/", "alloc.json", "env.json", "txs.json", "London"),
new OutputParams(result: "stdout"),
expectedExitCode: 0,
expectedOutputFile: "testdata/19/exp_london.json");
}

[Test]
public void Test12()
{
Execute(
new InputParams("testdata/19/", "alloc.json", "env.json", "txs.json", "ArrowGlacier"),
new OutputParams(result: "stdout"),
expectedExitCode: 0,
expectedOutputFile: "testdata/19/exp_arrowglacier.json");
}

[Test]
public void Test13()
{
Execute(
new InputParams("testdata/19/", "alloc.json", "env.json", "txs.json", "GrayGlacier"),
new OutputParams(result: "stdout"),
expectedExitCode: 0,
expectedOutputFile: "testdata/19/exp_grayglacier.json");
}

[Test]
public void Test14()
{
Execute(
new InputParams("testdata/23/", "alloc.json", "env.json", "txs.json", "Berlin"),
new OutputParams(result: "stdout"),
expectedExitCode: 0,
expectedOutputFile: "testdata/23/exp.json");
}

[Test]
public void Test15()
{
Execute(
new InputParams("testdata/24/", "alloc.json", "env.json", "txs.json", "Merge"),
new OutputParams(result: "stdout", alloc: "stdout"),
expectedExitCode: 0,
expectedOutputFile: "testdata/24/exp.json");
}

[Test]
public void Test16()
{
Execute(
new InputParams("testdata/24/", "alloc.json", "env-missingrandom.json", "txs.json", "Merge"),
new OutputParams(result: "stdout", alloc: "stdout"),
expectedExitCode: 3);
}

[Test]
public void Test17()
{
Execute(
new InputParams("testdata/26/", "alloc.json", "env.json", "txs.json", "Shanghai"),
new OutputParams(result: "stdout", alloc: "stdout"),
expectedExitCode: 0,
expectedOutputFile: "testdata/26/exp.json");
}

[Test]
public void Test18()
{
Execute(
new InputParams("testdata/28/", "alloc.json", "env.json", "txs.rlp", "Cancun"),
new OutputParams(result: "stdout", alloc: "stdout"),
expectedExitCode: 0,
expectedOutputFile: "testdata/28/exp.json");
}

[Test]
public void Test19()
{
Execute(
new InputParams("testdata/29/", "alloc.json", "env.json", "txs.json", "Cancun"),
new OutputParams(result: "stdout", alloc: "stdout"),
expectedExitCode: 0,
expectedOutputFile: "testdata/29/exp.json");
}

[Test]
public void Test20()
{
Execute(
new InputParams("testdata/30/", "alloc.json", "env.json", "txs_more.rlp", "Cancun"),
new OutputParams(result: "stdout", alloc: "stdout"),
expectedExitCode: 0,
expectedOutputFile: "testdata/30/exp.json");
}

private void Execute(InputParams inputParams, OutputParams outputParams, int expectedExitCode, string? expectedOutputFile = null)
{
var output = _t8NTool.Execute(
inputParams.Alloc,
inputParams.Env,
inputParams.Txs,
null,
outputParams.Alloc,
outputParams.Body,
outputParams.Result,
1,
inputParams.StateFork,
inputParams.StateReward,
TraceOptions.Default
);

Assert.That(output.ExitCode, Is.EqualTo(expectedExitCode));

if (expectedOutputFile == null) return;

var outputString = _ethereumJsonSerializer.Serialize(output, true);
var fileContent = File.ReadAllText(expectedOutputFile);
Assert.That(AreEqual(fileContent, outputString));
}

private static bool AreEqual(string json1, string json2)
{
JToken expected = JToken.Parse(json1);
JToken actual = JToken.Parse(json2);
return JToken.DeepEquals(actual, expected);
}
}
6 changes: 0 additions & 6 deletions tools/Nethermind.Tools.Kute/gasLImit40.txt

This file was deleted.

36 changes: 0 additions & 36 deletions tools/Nethermind.Tools.Kute/nethermind_response_1_GasLimit_40M.txt

This file was deleted.

1 change: 0 additions & 1 deletion tools/evm/T8NTool/InputProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public static T8nTestCase ConvertToGeneralStateTest(string inputAlloc,
envInfo.ApplyChecks(specProvider, spec);

T8nTestCase generalStateTest = new();
generalStateTest.IsT8NTest = true;
generalStateTest.Fork = spec;
generalStateTest.Pre = allocJson;
generalStateTest.Transactions = transactions;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tools/evm/T8NTool/T8NTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private T8NExecutionResult Execute(

var res = RunTest(generalStateTest, isGnosis);

PostState postState = new PostState();
PostState postState = new();
postState.StateRoot = res.StateRoot;
postState.TxRoot = res.TxRoot;
postState.ReceiptsRoot = res.ReceiptsRoot;
Expand Down
Loading

0 comments on commit a25d497

Please sign in to comment.