-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Ruben Buniatyan <[email protected]> Co-authored-by: Amirul Ashraf <[email protected]> Co-authored-by: Lukasz Rozmej <[email protected]> Co-authored-by: Alexey Osipov <[email protected]>
- Loading branch information
1 parent
50a6218
commit f9960a8
Showing
84 changed files
with
3,424 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/Nethermind/Nethermind.Era.Test/AccumulatorCalculatorTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Runtime.Intrinsics.Arm; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Nethermind.Core.Crypto; | ||
|
||
namespace Nethermind.Era1.Test; | ||
public class AccumulatorCalculatorTests | ||
{ | ||
[Test] | ||
public void Add_AddOneHashAndUInt256_DoesNotThrow() | ||
{ | ||
using var sut = new AccumulatorCalculator(); | ||
|
||
Assert.That(() => sut.Add(Keccak.Zero, 0), Throws.Nothing); | ||
} | ||
[Test] | ||
public void ComputeRoot_AddValues_ReturnsExpectedResult() | ||
{ | ||
using var sut = new AccumulatorCalculator(); | ||
sut.Add(Keccak.Zero, 1); | ||
sut.Add(Keccak.MaxValue, 2); | ||
|
||
var result = sut.ComputeRoot().ToByteArray(); | ||
|
||
Assert.That(result, Is.EquivalentTo(new[] { 0x3E, 0xD6, 0x26, 0x52, 0xDF, 0xB7, 0xE1, 0x07, 0x2D, 0x0F, 0x04, 0x0F, 0xEB, 0x6D, 0x00, 0x2A, 0x9F, 0x7C, 0xE3, 0x7C, 0xF8, 0xDD, 0xB1, 0x65, 0x49, 0xA7, 0xAC, 0x5C, 0xF8, 0xE3, 0xB7, 0x91 })); | ||
} | ||
|
||
[Test] | ||
public void ComputeRoot_AddOneHashAndUInt256_DoesNotThrow() | ||
{ | ||
using var sut = new AccumulatorCalculator(); | ||
sut.Add(Keccak.Zero, 1); | ||
sut.Add(Keccak.MaxValue, 2); | ||
|
||
var result = sut.ComputeRoot().ToByteArray(); | ||
|
||
Assert.That(result, Is.EquivalentTo(new[] { 0x3E, 0xD6, 0x26, 0x52, 0xDF, 0xB7, 0xE1, 0x07, 0x2D, 0x0F, 0x04, 0x0F, 0xEB, 0x6D, 0x00, 0x2A, 0x9F, 0x7C, 0xE3, 0x7C, 0xF8, 0xDD, 0xB1, 0x65, 0x49, 0xA7, 0xAC, 0x5C, 0xF8, 0xE3, 0xB7, 0x91 })); | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
src/Nethermind/Nethermind.Era.Test/AdminEraServiceTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using Nethermind.Config; | ||
using Nethermind.Logging; | ||
using NSubstitute; | ||
|
||
namespace Nethermind.Era1.Test; | ||
|
||
public class AdminEraServiceTests | ||
{ | ||
[Test] | ||
public void CanCallcExport() | ||
{ | ||
IEraImporter importer = Substitute.For<IEraImporter>(); | ||
AdminEraService adminEraService = new AdminEraService( | ||
importer, | ||
Substitute.For<IEraExporter>(), | ||
Substitute.For<IProcessExitSource>(), | ||
LimboLogs.Instance); | ||
|
||
adminEraService.ImportHistory("somewhere", 99, 999, null); | ||
importer.Received().Import("somewhere", 99, 999, null); | ||
} | ||
|
||
[Test] | ||
public void ThrowsWhenExistingImportIsRunning() | ||
{ | ||
IEraImporter importer = Substitute.For<IEraImporter>(); | ||
TaskCompletionSource importTcs = new TaskCompletionSource(); | ||
importer.Import("somewhere", 99, 999, null).Returns(importTcs.Task); | ||
AdminEraService adminEraService = new AdminEraService( | ||
importer, | ||
Substitute.For<IEraExporter>(), | ||
Substitute.For<IProcessExitSource>(), | ||
LimboLogs.Instance); | ||
|
||
adminEraService.ImportHistory("somewhere", 99, 999, null); | ||
|
||
Assert.That(() => adminEraService.ImportHistory("somewhere", 99, 999, null), Throws.Exception); | ||
|
||
importTcs.TrySetResult(); | ||
|
||
// Not throw | ||
adminEraService.ImportHistory("somewhere", 99, 999, null); | ||
} | ||
|
||
[Test] | ||
public void CanCallExport() | ||
{ | ||
IEraExporter exporter = Substitute.For<IEraExporter>(); | ||
AdminEraService adminEraService = new AdminEraService( | ||
Substitute.For<IEraImporter>(), | ||
exporter, | ||
Substitute.For<IProcessExitSource>(), | ||
LimboLogs.Instance); | ||
|
||
adminEraService.ExportHistory("somewhere", 99, 999); | ||
exporter.Received().Export("somewhere", 99, 999); | ||
} | ||
|
||
[Test] | ||
public void ThrowsWhenExistingExportIsRunning() | ||
{ | ||
IEraExporter exporter = Substitute.For<IEraExporter>(); | ||
TaskCompletionSource importTcs = new TaskCompletionSource(); | ||
exporter.Export("somewhere", 99, 999).Returns(importTcs.Task); | ||
AdminEraService adminEraService = new AdminEraService( | ||
Substitute.For<IEraImporter>(), | ||
exporter, | ||
Substitute.For<IProcessExitSource>(), | ||
LimboLogs.Instance); | ||
|
||
adminEraService.ExportHistory("somewhere", 99, 999); | ||
|
||
Assert.That(() => adminEraService.ExportHistory("somewhere", 99, 999), Throws.Exception); | ||
|
||
importTcs.TrySetResult(); | ||
|
||
// Not throw | ||
adminEraService.ExportHistory("somewhere", 99, 999); | ||
} | ||
} |
Oops, something went wrong.