forked from stratisproject/StratisBitcoinFullNode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix the serialisation of the hash, add test (stratisproject#164)
- Loading branch information
1 parent
0f0e080
commit 15660b2
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
src/Stratis.FederatedPeg.Features.FederationGateway/Interfaces/IBlockTip.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
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,36 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using FluentAssertions; | ||
using Newtonsoft.Json; | ||
using Stratis.FederatedPeg.Features.FederationGateway.Interfaces; | ||
using Stratis.FederatedPeg.Features.FederationGateway.Models; | ||
using Stratis.FederatedPeg.Tests.Utils; | ||
using Xunit; | ||
|
||
namespace Stratis.FederatedPeg.Tests | ||
{ | ||
public class BlockTipModelTests | ||
{ | ||
public static IBlockTip PrepareBlockTip() | ||
{ | ||
var blockHash = TestingValues.GetUint256(); | ||
var blockHeight = TestingValues.GetPositiveInt(); | ||
|
||
var blockTip = new BlockTipModel(blockHash, blockHeight); | ||
return blockTip; | ||
} | ||
|
||
[Fact] | ||
public void ShouldSerialiseAsJson() | ||
{ | ||
var blockTip = PrepareBlockTip(); | ||
var asJson = blockTip.ToString(); | ||
|
||
var reconverted = JsonConvert.DeserializeObject<BlockTipModel>(asJson); | ||
|
||
reconverted.Hash.Should().Be(blockTip.Hash); | ||
reconverted.Height.Should().Be(blockTip.Height); | ||
} | ||
} | ||
} |