Skip to content

Commit

Permalink
unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
ak88 committed Mar 25, 2024
1 parent ad2bf4c commit ab6f5be
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Nethermind/Nethermind.Clique.Test/CliqueTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
using Nethermind.Int256;
using Nethermind.Logging;
using Nethermind.Serialization.Rlp;
using NSubstitute;
using NUnit.Framework;
using System.Threading.Tasks;
using BlockTree = Nethermind.Blockchain.BlockTree;

namespace Nethermind.Clique.Test
Expand Down Expand Up @@ -90,6 +92,22 @@ public void Test_no_signer_data_at_epoch_fails(string blockRlp)
Assert.True(validSeal);
}

[TestCase(Block4Rlp)]
public async Task SealBlock_SignerCanSignHeader_FullHeaderIsUsedToSign(string blockRlp)
{
ISigner signer = Substitute.For<ISigner>();
signer.CanSignHeader.Returns(true);
signer.CanSign.Returns(true);
signer.Address.Returns(new Address("0x7ffc57839b00206d1ad20c69a1981b489f772031"));
signer.Sign(Arg.Any<BlockHeader>()).Returns(new Signature(new byte[65]));
CliqueSealer sut = new CliqueSealer(signer, new CliqueConfig(), _snapshotManager, LimboLogs.Instance);
Block block = Rlp.Decode<Block>(new Rlp(Bytes.FromHexString(blockRlp)));

await sut.SealBlock(block, System.Threading.CancellationToken.None);

signer.Received().Sign(Arg.Any<BlockHeader>());
}

public static Block GetGenesis()
{
Hash256 parentHash = Keccak.Zero;
Expand Down

0 comments on commit ab6f5be

Please sign in to comment.