-
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.
Merge pull request #3738 from greymistcube/refactor/trie-metadata
♻️ Refactor `TrieMetadata`
- Loading branch information
Showing
3 changed files
with
83 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using Bencodex.Types; | ||
using Libplanet.Store.Trie; | ||
using Libplanet.Types.Blocks; | ||
using Xunit; | ||
|
||
namespace Libplanet.Tests.Store.Trie | ||
{ | ||
public class TrieMetadataTest | ||
{ | ||
[Fact] | ||
public void CannotCreateWithInvalidVersion() | ||
{ | ||
Assert.Throws<ArgumentException>( | ||
() => new TrieMetadata(BlockMetadata.WorldStateProtocolVersion - 1)); | ||
Assert.Throws<ArgumentException>( | ||
() => new TrieMetadata(BlockMetadata.CurrentProtocolVersion + 1)); | ||
} | ||
|
||
[Fact] | ||
public void Bencoded() | ||
{ | ||
var meta = new TrieMetadata(BlockMetadata.WorldStateProtocolVersion); | ||
IValue bencoded = meta.Bencoded; | ||
var decoded = new TrieMetadata(bencoded); | ||
Assert.Equal(meta.Version, decoded.Version); | ||
} | ||
} | ||
} |