-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add test code for delegator state query
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
NineChronicles.Headless.Tests/GraphTypes/DelegatorTypeTest.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,45 @@ | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Numerics; | ||
using System.Threading.Tasks; | ||
using GraphQL.Execution; | ||
using Lib9c; | ||
using Libplanet.Types.Tx; | ||
using Nekoyume.ValidatorDelegation; | ||
using NineChronicles.Headless.GraphTypes; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace NineChronicles.Headless.Tests.GraphTypes | ||
{ | ||
public class DelegatorTypeTest | ||
{ | ||
[Fact] | ||
public async Task ExecuteQuery() | ||
{ | ||
var lastDistributeHeight = 1L; | ||
var share = new BigInteger(1000000000000000000) * 10; | ||
var fav = Currencies.GuildGold * 10; | ||
|
||
var result = await GraphQLTestUtils.ExecuteQueryAsync<DelegatorType>( | ||
"{ lastDistributeHeight share fav { currency quantity } }", | ||
source: new DelegatorType | ||
{ | ||
LastDistributeHeight = lastDistributeHeight, | ||
Share = share, | ||
Fav = fav, | ||
} | ||
); | ||
|
||
// Then | ||
var data = (Dictionary<string, object>)((ExecutionNode)result.Data!).ToValue()!; | ||
|
||
Assert.Equal(lastDistributeHeight, data["lastDistributeHeight"]); | ||
Assert.Equal(share.ToString("N0"), data["share"]); | ||
|
||
var favResult = (Dictionary<string, object>)data["fav"]; | ||
Assert.Equal(fav.Currency.Ticker, favResult["currency"]); | ||
Assert.Equal(fav.GetQuantityString(minorUnit: true), favResult["quantity"]); | ||
} | ||
} | ||
} |