-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
57 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
42 changes: 42 additions & 0 deletions
42
sdk/node/Libplanet.Node.Tests/Services/ReadChainServiceTest.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,42 @@ | ||
using Libplanet.Node.Services; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Libplanet.Node.Tests.Services; | ||
|
||
public class ReadChainServiceTest | ||
{ | ||
[Fact] | ||
public void Tip_Test() | ||
{ | ||
var serviceProvider = TestUtility.CreateServiceProvider(); | ||
var readChainService = serviceProvider.GetRequiredService<IReadChainService>(); | ||
var expectedBlock = readChainService.GetBlock(0); | ||
|
||
Assert.Equal(expectedBlock, readChainService.Tip); | ||
} | ||
|
||
[Fact] | ||
public async Task GetBlock_WithHash_TestAsync() | ||
{ | ||
var serviceProvider = TestUtility.CreateServiceProvider(); | ||
var blockChainService = serviceProvider.GetRequiredService<IBlockChainService>(); | ||
var blockChain = blockChainService.BlockChain; | ||
var readChainService = serviceProvider.GetRequiredService<IReadChainService>(); | ||
var expectedBlock = await BlockChainUtility.AppendBlockAsync(blockChain); | ||
|
||
Assert.Equal(expectedBlock, readChainService.GetBlock(expectedBlock.Hash)); | ||
} | ||
|
||
[Fact] | ||
public async Task GetBlock_WithHeight_TestAsync() | ||
{ | ||
var serviceProvider = TestUtility.CreateServiceProvider(); | ||
var blockChainService = serviceProvider.GetRequiredService<IBlockChainService>(); | ||
var blockChain = blockChainService.BlockChain; | ||
var readChainService = serviceProvider.GetRequiredService<IReadChainService>(); | ||
var height = blockChain.Count; | ||
var expectedBlock = await BlockChainUtility.AppendBlockAsync(blockChain); | ||
|
||
Assert.Equal(expectedBlock, readChainService.GetBlock(height)); | ||
} | ||
} |